QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
elementpicturefactory.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef ELEMENTPICTUREFACTORY_H
19#define ELEMENTPICTUREFACTORY_H
20
21#include <QMutex>
22#include <QSharedPointer>
23#include <QHash>
24
26class QPicture;
27class QUuid;
28class QDomElement;
29class QPainter;
30class QGraphicsSimpleTextItem;
31
38{
39 public :
41 {
42 QList<QLineF> m_lines;
43 QList<QRectF> m_rectangles;
44 QList<QRectF> m_circles;
45 QList<QVector<QPointF>> m_polygons;
46 QList<QVector<qreal>> m_arcs;
47 QList<QGraphicsSimpleTextItem*> m_texts;
48 };
49
50
56 {
57 static QMutex mutex;
58 if (!m_factory)
59 {
60 mutex.lock();
61 if (!m_factory) {
63 }
64 mutex.unlock();
65 }
66 return m_factory;
67 }
68
73 static void dropInstance()
74 {
75 static QMutex mutex;
76 if (m_factory)
77 {
78 mutex.lock();
79 delete m_factory;
80 m_factory = nullptr;
81 mutex.unlock();
82 }
83 }
84
85 void getPictures(const ElementsLocation &location, QPicture &picture, QPicture &low_picture);
86 QPixmap pixmap(const ElementsLocation &location);
88
89 private:
94
95 bool build(const ElementsLocation &location, QPicture *picture=nullptr, QPicture *low_picture=nullptr);
96 void parseElement(const QDomElement &dom, QPainter &painter, primitives &prim) const;
97 void parseLine (const QDomElement &dom, QPainter &painter, primitives &prim) const;
98 void parseRect (const QDomElement &dom, QPainter &painter, primitives &prim) const;
99 void parseEllipse(const QDomElement &dom, QPainter &painter, primitives &prim) const;
100 void parseCircle (const QDomElement &dom, QPainter &painter, primitives &prim) const;
101 void parseArc (const QDomElement &dom, QPainter &painter, primitives &prim) const;
102 void parsePolygon(const QDomElement &dom, QPainter &painter, primitives &prim) const;
103 void parseText (const QDomElement &dom, QPainter &painter, primitives &prim) const;
104 void setPainterStyle(const QDomElement &dom, QPainter &painter) const;
105
106 QHash<QUuid, QPicture> m_pictures_H;
107 QHash<QUuid, QPicture> m_low_pictures_H;
108 QHash<QUuid, QPixmap> m_pixmap_H;
109 QHash<QUuid, primitives> m_primitives_H;
111};
112
113#endif // ELEMENTPICTUREFACTORY_H
The ElementPictureFactory class This class is singleton factory, use to create and get the picture us...
Definition elementpicturefactory.h:38
void parseRect(const QDomElement &dom, QPainter &painter, primitives &prim) const
Definition elementpicturefactory.cpp:360
void parseText(const QDomElement &dom, QPainter &painter, primitives &prim) const
Definition elementpicturefactory.cpp:489
bool build(const ElementsLocation &location, QPicture *picture=nullptr, QPicture *low_picture=nullptr)
ElementPictureFactory::build Build the picture from location.
Definition elementpicturefactory.cpp:150
ElementPictureFactory()
Definition elementpicturefactory.h:90
ElementPictureFactory(const ElementPictureFactory &)
ElementPictureFactory::primitives getPrimitives(const ElementsLocation &location)
ElementPictureFactory::getPrimitives.
Definition elementpicturefactory.cpp:122
~ElementPictureFactory()
Definition elementpicturefactory.cpp:131
void getPictures(const ElementsLocation &location, QPicture &picture, QPicture &low_picture)
ElementPictureFactory::getPictures Set the picture of the element at location. Note,...
Definition elementpicturefactory.cpp:44
void setPainterStyle(const QDomElement &dom, QPainter &painter) const
ElementPictureFactory::setPainterStyle apply the style store in dom to painter.
Definition elementpicturefactory.cpp:557
void parsePolygon(const QDomElement &dom, QPainter &painter, primitives &prim) const
Definition elementpicturefactory.cpp:452
static ElementPictureFactory * instance()
instance
Definition elementpicturefactory.h:55
void parseEllipse(const QDomElement &dom, QPainter &painter, primitives &prim) const
Definition elementpicturefactory.cpp:384
QHash< QUuid, QPicture > m_low_pictures_H
Definition elementpicturefactory.h:107
static void dropInstance()
dropInstance Drop the instance of factory
Definition elementpicturefactory.h:73
void parseArc(const QDomElement &dom, QPainter &painter, primitives &prim) const
Definition elementpicturefactory.cpp:425
QHash< QUuid, primitives > m_primitives_H
Definition elementpicturefactory.h:109
void parseCircle(const QDomElement &dom, QPainter &painter, primitives &prim) const
Definition elementpicturefactory.cpp:408
static ElementPictureFactory * m_factory
Definition elementpicturefactory.h:110
QPixmap pixmap(const ElementsLocation &location)
ElementPictureFactory::pixmap.
Definition elementpicturefactory.cpp:78
void parseElement(const QDomElement &dom, QPainter &painter, primitives &prim) const
Definition elementpicturefactory.cpp:250
void parseLine(const QDomElement &dom, QPainter &painter, primitives &prim) const
Definition elementpicturefactory.cpp:261
QHash< QUuid, QPicture > m_pictures_H
Definition elementpicturefactory.h:106
QHash< QUuid, QPixmap > m_pixmap_H
Definition elementpicturefactory.h:108
ElementPictureFactory operator=(const ElementPictureFactory &)
The ElementsLocation class This class represents the location, the location of an element or of a cat...
Definition elementslocation.h:47
Definition elementpicturefactory.h:41
QList< QRectF > m_circles
Definition elementpicturefactory.h:44
QList< QVector< QPointF > > m_polygons
Definition elementpicturefactory.h:45
QList< QVector< qreal > > m_arcs
Definition elementpicturefactory.h:46
QList< QRectF > m_rectangles
Definition elementpicturefactory.h:43
QList< QLineF > m_lines
Definition elementpicturefactory.h:42
QList< QGraphicsSimpleTextItem * > m_texts
Definition elementpicturefactory.h:47