Added switch implementation in svg
This commit is contained in:
Kirill Polyakov
2024-06-25 16:39:42 +03:00
parent 6d9bccee65
commit 3d528bf8b5
6 changed files with 57 additions and 0 deletions

View File

@ -106,6 +106,7 @@ METAFILE_PATH = $$PWD/../../raster/Metafile
$$METAFILE_PATH/svg/SvgObjects/CMask.h \
$$METAFILE_PATH/svg/SvgObjects/CPattern.h \
$$METAFILE_PATH/svg/SvgObjects/CSymbol.h \
$$METAFILE_PATH/svg/SvgObjects/CSwitch.h \
$$METAFILE_PATH/svg/SvgObjects/CMarker.h \
$$METAFILE_PATH/svg/SvgObjects/CImage.h \
$$METAFILE_PATH/svg/SvgObjects/CLine.h \
@ -130,6 +131,7 @@ METAFILE_PATH = $$PWD/../../raster/Metafile
$$METAFILE_PATH/svg/SvgObjects/CMarker.cpp \
$$METAFILE_PATH/svg/SvgObjects/CPattern.cpp \
$$METAFILE_PATH/svg/SvgObjects/CSymbol.cpp \
$$METAFILE_PATH/svg/SvgObjects/CSwitch.cpp \
$$METAFILE_PATH/svg/SvgObjects/CImage.cpp \
$$METAFILE_PATH/svg/SvgObjects/CLine.cpp \
$$METAFILE_PATH/svg/SvgObjects/CRect.cpp \

View File

@ -13,6 +13,7 @@
#include "SvgObjects/CPattern.h"
#include "SvgObjects/CEllipse.h"
#include "SvgObjects/CSymbol.h"
#include "SvgObjects/CSwitch.h"
#include "SvgObjects/CMarker.h"
#include "SvgObjects/CCircle.h"
#include "SvgObjects/CStyle.h"
@ -168,6 +169,11 @@ namespace SVG
pObject = CTextPath::Create(oElement, pParent, m_pFontManager, pFile);
ReadChildrens(oElement, (CTextPath*)pObject, pFile);
}
else if (L"switch" == wsElementName)
{
pObject = new CSwitch(oElement, pParent);
ReadChildrens(oElement, (CSwitch*)pObject, pFile);
}
//defs
else if (L"defs" == wsElementName)
return ReadChildrens<CRenderedObject>(oElement, NULL, pFile);

View File

@ -70,6 +70,7 @@ namespace SVG
friend class CMask;
friend class CTSpan;
friend class CMarker;
friend class CSwitch;
friend class CPattern;
friend class CGradient;
friend class CClipPath;

View File

@ -135,6 +135,7 @@ namespace SVG
friend class CTSpan;
friend class CImage;
friend class CCircle;
friend class CSwitch;
friend class CPolygon;
friend class CEllipse;
friend class CPolyline;

View File

@ -0,0 +1,29 @@
#include "CSwitch.h"
namespace SVG
{
CSwitch::CSwitch(XmlUtils::CXmlNode &oNode, CRenderedObject *pParent)
: CRenderedObject(oNode, pParent)
{
}
bool CSwitch::Draw(IRenderer *pRenderer, const CSvgFile *pFile, CommandeMode oMode, const TSvgStyles *pStyles) const
{
for (const CRenderedObject* pObject : m_arObjects)
{
if (NULL != pObject && pObject->Draw(pRenderer, pFile, oMode, pStyles))
return true;
}
return false;
}
TBounds CSwitch::GetBounds() const
{
for (const CRenderedObject* pObject : m_arObjects)
if (NULL != pObject)
return pObject->GetBounds();
return TBounds{0., 0., 0., 0.};
}
}

View File

@ -0,0 +1,18 @@
#ifndef CSWITCH_H
#define CSWITCH_H
#include "CContainer.h"
namespace SVG
{
class CSwitch : public CRenderedObject, public CContainer<CRenderedObject>
{
public:
CSwitch(XmlUtils::CXmlNode& oNode, CRenderedObject* pParent = NULL);
bool Draw(IRenderer* pRenderer, const CSvgFile *pFile, CommandeMode oMode = CommandeModeDraw, const TSvgStyles* pStyles = NULL) const override;
TBounds GetBounds() const override;
};
}
#endif // CSWITCH_H