19 #include <QGraphicsItem> 43 m_selected_items(diagram->selectedItems())
45 QList <QGraphicsItem *> item_list;
49 item_list = diagram->items();
53 for (QGraphicsItem *item : item_list)
55 if (
Element *elmt = qgraphicsitem_cast<Element *>(item))
59 else if (
Conductor *c = qgraphicsitem_cast<Conductor *>(item))
62 if (!c->terminal1->parentItem()->isSelected() &&\
63 !c->terminal2->parentItem()->isSelected()) {
76 else if (
DiagramImageItem *dii = qgraphicsitem_cast<DiagramImageItem *>(item))
78 else if (
QetShapeItem *dsi = qgraphicsitem_cast<QetShapeItem *>(item))
82 else if (QGraphicsItemGroup *group = qgraphicsitem_cast<QGraphicsItemGroup *>(item))
91 for(
Terminal *terminal : elmt->terminals())
93 for(
Conductor *conductor : terminal->conductors())
96 if (conductor->terminal1 == terminal)
97 other_terminal = conductor->terminal2;
99 other_terminal = conductor->terminal1;
117 m_elements(other.m_elements),
118 m_text_fields(other.m_text_fields),
119 m_images(other.m_images),
120 m_shapes(other.m_shapes),
121 m_conductors_to_update(other.m_conductors_to_update),
122 m_conductors_to_move(other.m_conductors_to_move),
123 m_other_conductors(other.m_other_conductors),
124 m_potential_conductors(other.m_potential_conductors),
125 m_element_texts(other.m_element_texts),
126 m_texts_groups(other.m_texts_groups),
127 m_selected_items(other.m_selected_items)
142 QList<DiagramTextItem *> selected_texts;
148 selected_texts << static_cast<DiagramTextItem *>(qgi);
150 return(selected_texts);
162 QList<ElementTextItemGroup *> groups;
165 if(qgi->type() == QGraphicsItemGroup::Type)
179 QList<Conductor *> result;
186 if (!conductor->isSelected())
187 result.removeAll(conductor);
211 if(qgi->type() == QGraphicsItemGroup::Type)
212 if(dynamic_cast<ElementTextItemGroup *>(qgi))
224 if(!
m_images.isEmpty())
return true;
225 if(!
m_shapes.isEmpty())
return true;
259 const QList<Element *> elements_set =
m_elements;
260 for(
Element *elmt : elements_set) {
261 if (!elmt->isMovable()) {
267 const QSet<DiagramImageItem *> images_set =
m_images;
269 if (!img->isMovable()) {
275 const QSet<QetShapeItem *> shapes_set =
m_shapes;
277 if (!shape->isMovable()) {
365 if (dti->textInteractionFlags() == Qt::TextEditorInteraction) {
380 QList<QGraphicsItem *> items_list;
382 for(QGraphicsItem *qgi :
conductors(filter)) items_list << qgi;
386 if (filter &
Images)
for(QGraphicsItem *qgi :
m_images) items_list << qgi;
387 if (filter &
Shapes)
for(QGraphicsItem *qgi :
m_shapes) items_list << qgi;
392 for(QGraphicsItem *qgi : items_list) {
393 if (!qgi -> isSelected()) items_list.removeOne(qgi);
441 int conductors_count =
conductors(filter).count();
467 d <<
"DiagramContent {" <<
"\n";
QList< Conductor * > m_potential_conductors
bool hasCopiableItems() const
DiagramContent::hasCopiableItems.
The DynamicElementTextItem class This class provide a simple text field of element who can be added o...
QList< DiagramTextItem * > selectedTexts() const
DiagramContent::selectedTexts.
QSet< QetShapeItem * > m_shapes
QString sentence(int=All) const
DiagramContent::sentence.
QSet< Conductor * > relatedPotentialConductors(const bool all_diagram=true, QList< Terminal *> *t_list=nullptr)
Conductor::relatedPotentialConductors Return all conductors at the same potential of this conductor...
QList< Conductor * > m_conductors_to_move
bool potentialIsManaged(QList< Conductor *>conductors)
DiagramContent::potentialIsManaged.
QList< QGraphicsItem * > items(int=All) const
DiagramContent::items.
QSet< IndependentTextItem * > m_text_fields
int removeNonMovableItems()
DiagramContent::removeNonMovableItems Remove all non movable item.
QList< Conductor * > m_other_conductors
QString ElementsAndConductorsSentence(int, int, int=0, int=0, int=0, int=0)
QSet< DynamicElementTextItem * > m_element_texts
QList< ElementTextItemGroup * > selectedTextsGroup() const
DiagramContent::selectedTextsGroup.
The ElementTextItemGroup class This class represent a group of element text Texts in the group can be...
QList< Element * > m_elements
QList< Conductor * > m_conductors_to_update
The QetShapeItem class this class is used to draw a basic shape (line, rectangle, ellipse) into a dia...
QList< QGraphicsItem * > m_selected_items
DiagramContent()
DiagramContent::DiagramContent.
bool hasTextEditing()
DiagramContent::hasTextEditing.
void clear()
DiagramContent::clear Remove all items from the diagram content.
QDebug & operator<<(QDebug d, DiagramContent &content)
operator << Use to debug a diagram content
QSet< DiagramImageItem * > m_images
bool hasDeletableItems() const
DiagramContent::hasDeletableItems.
QList< Conductor * > conductors(int=AnyConductor) const
DiagramContent::conductors.
int count(int=All) const
DiagramContent::count.
QSet< ElementTextItemGroup * > m_texts_groups
DiagramContent & operator+=(const DiagramContent &other)