Compare commits

...

9 Commits

Author SHA1 Message Date
Laurent Trinques 16dea9f3de Update Polish translation, thanks Paweł 2025-02-16 17:49:15 +01:00
Laurent Trinques 20e852cbaf Merge pull request #358 from plc-user/master
some more rotation, mirror and flip
2025-02-16 17:24:33 +01:00
plc-user 51225d5f59 element-editor: add rotation with smaller increments for "line", "polygon", "text" and "dynamic_text" with shortcut <Ctrl>+<Space> 2025-02-16 16:31:18 +01:00
plc-user 3fc5469aee element-editor: add mirror and flip for "dynamic_text" 2025-02-16 16:15:46 +01:00
plc-user 6fdc243552 fix indention - no code-change 2025-02-16 15:43:58 +01:00
plc-user da109b1522 element-editor: add rotation-functions to "text" and "dynamic_text" 2025-02-16 15:42:33 +01:00
plc-user 2aeae1fe46 use Qt-functions to rotate lines and polygons 2025-02-16 15:28:15 +01:00
plc-user e98ce4de1d add English comments 2025-02-16 10:02:19 +01:00
plc-user da0951d5a0 fix typo in variable-name (mixture of French and English) 2025-02-15 20:36:21 +01:00
15 changed files with 288 additions and 106 deletions
BIN
View File
Binary file not shown.
+77 -41
View File
@@ -5815,7 +5815,7 @@ Dostępne opcje:
<location filename="../sources/qetapp.cpp" line="2540"/> <location filename="../sources/qetapp.cpp" line="2540"/>
<source> --data-dir=DIR Definir le dossier de data <source> --data-dir=DIR Definir le dossier de data
</source> </source>
<translation type="unfinished"></translation> <translation> --data-dir=DIR Zdefiniuj folder data</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetapp.cpp" line="2542"/> <location filename="../sources/qetapp.cpp" line="2542"/>
@@ -6938,12 +6938,13 @@ Dostępne opcje:
<message> <message>
<location filename="../sources/editor/ui/qetelementeditor.ui" line="504"/> <location filename="../sources/editor/ui/qetelementeditor.ui" line="504"/>
<source>Mirror</source> <source>Mirror</source>
<translation type="unfinished"></translation> <translation>Mirror</translation>
</message> </message>
<message> <message>
<location filename="../sources/editor/ui/qetelementeditor.ui" line="513"/> <location filename="../sources/editor/ui/qetelementeditor.ui" line="513"/>
<source>Flip</source> <source>Flip</source>
<translation type="unfinished"></translation> <translatorcomment>do zrobienia</translatorcomment>
<translation>Flip</translation>
</message> </message>
<message> <message>
<location filename="../sources/editor/ui/qetelementeditor.ui" line="522"/> <location filename="../sources/editor/ui/qetelementeditor.ui" line="522"/>
@@ -8096,13 +8097,13 @@ Co chcesz zrobić?</translation>
<location filename="../sources/editor/editorcommands.cpp" line="595"/> <location filename="../sources/editor/editorcommands.cpp" line="595"/>
<source>Miroir de sélection</source> <source>Miroir de sélection</source>
<comment>undo caption</comment> <comment>undo caption</comment>
<translation type="unfinished"></translation> <translation>Odbicie zaznaczenia</translation>
</message> </message>
<message> <message>
<location filename="../sources/editor/editorcommands.cpp" line="640"/> <location filename="../sources/editor/editorcommands.cpp" line="640"/>
<source>Retourner la sélection</source> <source>Retourner la sélection</source>
<comment>undo caption</comment> <comment>undo caption</comment>
<translation type="unfinished"></translation> <translation>Powrót do zaznaczenia</translation>
</message> </message>
<message> <message>
<location filename="../sources/editor/graphicspart/partarc.h" line="52"/> <location filename="../sources/editor/graphicspart/partarc.h" line="52"/>
@@ -8917,42 +8918,50 @@ Czy chcesz ją zastąpić?</translation>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="273"/> <location filename="../sources/qetinformation.cpp" line="273"/>
<source>Description textuelle auxiliaire 1</source> <source>Description textuelle auxiliaire 1</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Oznaczenie wyposażenia pomocniczego 1</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="274"/> <location filename="../sources/qetinformation.cpp" line="274"/>
<source>Numéro d&apos;article auxiliaire 1</source> <source>Numéro d&apos;article auxiliaire 1</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer wyposażenia pomocniczego 1</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="275"/> <location filename="../sources/qetinformation.cpp" line="275"/>
<source>Fabricant auxiliaire 1</source> <source>Fabricant auxiliaire 1</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Producent wyposażenia pomocniczego 1</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="276"/> <location filename="../sources/qetinformation.cpp" line="276"/>
<source>Numéro de commande auxiliaire 1</source> <source>Numéro de commande auxiliaire 1</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer sterowania pomocniczego 1</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="277"/> <location filename="../sources/qetinformation.cpp" line="277"/>
<source>Numéro interne auxiliaire 1</source> <source>Numéro interne auxiliaire 1</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer wewnętrzny wyposażenia pomocniczego 1</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="278"/> <location filename="../sources/qetinformation.cpp" line="278"/>
<source>Fournisseur auxiliaire 1</source> <source>Fournisseur auxiliaire 1</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Dostawca wyposażenia pomocniczego 1</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="279"/> <location filename="../sources/qetinformation.cpp" line="279"/>
<source>Quantité auxiliaire 1</source> <source>Quantité auxiliaire 1</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Ilość wyposażenia pomocniczego 1</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="280"/> <location filename="../sources/qetinformation.cpp" line="280"/>
<source>Unité auxiliaire 1</source> <source>Unité auxiliaire 1</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Jednostka wyposażenia pomocniczego 1</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="281"/> <location filename="../sources/qetinformation.cpp" line="281"/>
@@ -8962,132 +8971,157 @@ Czy chcesz ją zastąpić?</translation>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="282"/> <location filename="../sources/qetinformation.cpp" line="282"/>
<source>Description textuelle auxiliaire 2</source> <source>Description textuelle auxiliaire 2</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Oznaczenie wyposażenia pomocniczego 2</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="283"/> <location filename="../sources/qetinformation.cpp" line="283"/>
<source>Numéro d&apos;article auxiliaire 2</source> <source>Numéro d&apos;article auxiliaire 2</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer wyposażenia pomocniczego 2</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="284"/> <location filename="../sources/qetinformation.cpp" line="284"/>
<source>Fabricant auxiliaire 2</source> <source>Fabricant auxiliaire 2</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Producent wyposażenia pomocniczego 2</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="285"/> <location filename="../sources/qetinformation.cpp" line="285"/>
<source>Numéro de commande auxiliaire 2</source> <source>Numéro de commande auxiliaire 2</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer sterowania pomocniczego 2</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="286"/> <location filename="../sources/qetinformation.cpp" line="286"/>
<source>Numéro interne auxiliaire 2</source> <source>Numéro interne auxiliaire 2</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer wewnętrzny wyposażenia pomocniczego 2</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="287"/> <location filename="../sources/qetinformation.cpp" line="287"/>
<source>Fournisseur auxiliaire 2</source> <source>Fournisseur auxiliaire 2</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Dostawca wyposażenia pomocniczego 2</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="288"/> <location filename="../sources/qetinformation.cpp" line="288"/>
<source>Quantité auxiliaire 2</source> <source>Quantité auxiliaire 2</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Ilość wyposażenia pomocniczego 2</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="289"/> <location filename="../sources/qetinformation.cpp" line="289"/>
<source>Unité auxiliaire 2</source> <source>Unité auxiliaire 2</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Jednostka wyposażenia pomocniczego 2</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="290"/> <location filename="../sources/qetinformation.cpp" line="290"/>
<source>Bloc auxiliaire 3</source> <source>Bloc auxiliaire 3</source>
<translation type="unfinished">Zestyki pomocnicze 3</translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Zestyki pomocnicze 3</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="291"/> <location filename="../sources/qetinformation.cpp" line="291"/>
<source>Description textuelle auxiliaire 3</source> <source>Description textuelle auxiliaire 3</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Oznaczenie wyposażenia pomocniczego 3</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="292"/> <location filename="../sources/qetinformation.cpp" line="292"/>
<source>Numéro d&apos;article auxiliaire 3</source> <source>Numéro d&apos;article auxiliaire 3</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer wyposażenia pomocniczego 3</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="293"/> <location filename="../sources/qetinformation.cpp" line="293"/>
<source>Fabricant auxiliaire 3</source> <source>Fabricant auxiliaire 3</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer wyposażenia pomocniczego 3</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="294"/> <location filename="../sources/qetinformation.cpp" line="294"/>
<source>Numéro de commande auxiliaire 3</source> <source>Numéro de commande auxiliaire 3</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer sterowania pomocniczego 3</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="295"/> <location filename="../sources/qetinformation.cpp" line="295"/>
<source>Numéro interne auxiliaire 3</source> <source>Numéro interne auxiliaire 3</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer wewnętrzny wyposażenia pomocniczego 3</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="296"/> <location filename="../sources/qetinformation.cpp" line="296"/>
<source>Fournisseur auxiliaire 3</source> <source>Fournisseur auxiliaire 3</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Dostawca wyposażenia pomocniczego 2</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="297"/> <location filename="../sources/qetinformation.cpp" line="297"/>
<source>Quantité auxiliaire 3</source> <source>Quantité auxiliaire 3</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Ilość wyposażenia pomocniczego 3</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="298"/> <location filename="../sources/qetinformation.cpp" line="298"/>
<source>Unité auxiliaire 3</source> <source>Unité auxiliaire 3</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Jednostka wyposażenia pomocniczego 3</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="299"/> <location filename="../sources/qetinformation.cpp" line="299"/>
<source>Bloc auxiliaire 4</source> <source>Bloc auxiliaire 4</source>
<translation type="unfinished">Zestyki pomocnicze 4</translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Zestyki pomocnicze 4</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="300"/> <location filename="../sources/qetinformation.cpp" line="300"/>
<source>Description textuelle auxiliaire 4</source> <source>Description textuelle auxiliaire 4</source>
<translation type="unfinished"></translation> <translation>Oznaczenie wyposażenia pomocniczego 4</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="301"/> <location filename="../sources/qetinformation.cpp" line="301"/>
<source>Numéro d&apos;article auxiliaire 4</source> <source>Numéro d&apos;article auxiliaire 4</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer wyposażenia pomocniczego 4</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="302"/> <location filename="../sources/qetinformation.cpp" line="302"/>
<source>Fabricant auxiliaire 4</source> <source>Fabricant auxiliaire 4</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer wyposażenia pomocniczego 4</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="303"/> <location filename="../sources/qetinformation.cpp" line="303"/>
<source>Numéro de commande auxiliaire 4</source> <source>Numéro de commande auxiliaire 4</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer sterowania pomocniczego 4</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="304"/> <location filename="../sources/qetinformation.cpp" line="304"/>
<source>Numéro interne auxiliaire 4</source> <source>Numéro interne auxiliaire 4</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer wewnętrzny wyposażenia pomocniczego 4</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="305"/> <location filename="../sources/qetinformation.cpp" line="305"/>
<source>Fournisseur auxiliaire 4</source> <source>Fournisseur auxiliaire 4</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Numer wewnętrzny wyposażenia pomocniczego 4</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="306"/> <location filename="../sources/qetinformation.cpp" line="306"/>
<source>Quantité auxiliaire 4</source> <source>Quantité auxiliaire 4</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Ilość wyposażenia pomocniczego 4</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="307"/> <location filename="../sources/qetinformation.cpp" line="307"/>
<source>Unité auxiliaire 4</source> <source>Unité auxiliaire 4</source>
<translation type="unfinished"></translation> <translatorcomment>Niepewne</translatorcomment>
<translation>Jednostka wyposażenia pomocniczego 4</translation>
</message> </message>
<message> <message>
<location filename="../sources/qetinformation.cpp" line="257"/> <location filename="../sources/qetinformation.cpp" line="257"/>
@@ -9491,7 +9525,8 @@ Czy chcesz ją zastąpić?</translation>
<location filename="../sources/qet_elementscaler/qet_elementscaler.cpp" line="100"/> <location filename="../sources/qet_elementscaler/qet_elementscaler.cpp" line="100"/>
<source>QET_ElementScaler: <source>QET_ElementScaler:
additional information about %1 import / scaling</source> additional information about %1 import / scaling</source>
<translation type="unfinished"></translation> <translation>QET_ElementScaler:
dodatkowe informacje o %1 imporcie/skalowaniu</translation>
</message> </message>
<message> <message>
<location filename="../sources/qet_elementscaler/qet_elementscaler.cpp" line="149"/> <location filename="../sources/qet_elementscaler/qet_elementscaler.cpp" line="149"/>
@@ -9504,7 +9539,8 @@ Pobierz go, klikając poniższy link i rozpakuj w folderze instalacyjnym</transl
<location filename="../sources/dxf/dxftoelmt.cpp" line="58"/> <location filename="../sources/dxf/dxftoelmt.cpp" line="58"/>
<source>Dxf2elmt: <source>Dxf2elmt:
Error: Make sure the file %1 is a valid .dxf file</source> Error: Make sure the file %1 is a valid .dxf file</source>
<translation type="unfinished"></translation> <translation>Dxf2elmt:
Błąd: Upewnij się, że plik %1 jest prawidłowym plikiem .dxf</translation>
</message> </message>
<message> <message>
<location filename="../sources/dxf/dxftoelmt.cpp" line="59"/> <location filename="../sources/dxf/dxftoelmt.cpp" line="59"/>
+97 -10
View File
@@ -541,11 +541,19 @@ void RotateElementsCommand::undo()
} }
else if (item->type() == PartLine::Type) { else if (item->type() == PartLine::Type) {
PartLine* line = qgraphicsitem_cast<PartLine*>(item); PartLine* line = qgraphicsitem_cast<PartLine*>(item);
line->setRotation(line->rotation()-90); line->setRotation(-90);
} }
else if (item->type() == PartPolygon::Type) { else if (item->type() == PartPolygon::Type) {
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item); PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
poly->setRotation(poly->rotation()-90); poly->setRotation(-90);
}
else if (item->type() == PartText::Type) {
PartText* text = qgraphicsitem_cast<PartText*>(item);
text->setRotation(-90);
}
else if (item->type() == PartDynamicTextField::Type) {
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
dyntext->setRotation(-90);
} }
else { else {
item->setRotation(item->rotation()-90); item->setRotation(item->rotation()-90);
@@ -578,11 +586,19 @@ void RotateElementsCommand::redo()
} }
else if (item->type() == PartLine::Type) { else if (item->type() == PartLine::Type) {
PartLine* line = qgraphicsitem_cast<PartLine*>(item); PartLine* line = qgraphicsitem_cast<PartLine*>(item);
line->setRotation(line->rotation()+90); line->setRotation(+90);
} }
else if (item->type() == PartPolygon::Type) { else if (item->type() == PartPolygon::Type) {
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item); PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
poly->setRotation(poly->rotation()+90); poly->setRotation(+90);
}
else if (item->type() == PartText::Type) {
PartText* text = qgraphicsitem_cast<PartText*>(item);
text->setRotation(+90);
}
else if (item->type() == PartDynamicTextField::Type) {
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
dyntext->setRotation(+90);
} }
else { else {
item->setRotation(item->rotation()+90); item->setRotation(item->rotation()+90);
@@ -591,6 +607,71 @@ void RotateElementsCommand::redo()
} }
RotateFineElementsCommand::RotateFineElementsCommand(ElementScene *scene, QUndoCommand *parent) :
ElementEditionCommand(QObject::tr("Pivoter la selection", "undo caption"), scene, nullptr, parent)
{
m_items = scene->selectedItems();
}
/**
@brief RotateFineElementsCommand::undo
*/
void RotateFineElementsCommand::undo()
{
for (QGraphicsItem *item : m_items)
{
if (item->type() == PartLine::Type) {
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
line->setRotation(-5);
}
else if (item->type() == PartPolygon::Type) {
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
poly->setRotation(-5);
}
else if (item->type() == PartText::Type) {
PartText* text = qgraphicsitem_cast<PartText*>(item);
text->setRotation(-5);
}
else if (item->type() == PartDynamicTextField::Type) {
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
dyntext->setRotation(-5);
}
else {
//item->setRotation(-5);
}
}
}
/**
@brief RotateFineElementsCommand::redo
*/
void RotateFineElementsCommand::redo()
{
for (QGraphicsItem *item : m_items)
{
if (item->type() == PartLine::Type) {
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
line->setRotation(+5);
}
else if (item->type() == PartPolygon::Type) {
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
poly->setRotation(+5);
}
else if (item->type() == PartText::Type) {
PartText* text = qgraphicsitem_cast<PartText*>(item);
text->setRotation(+5);
}
else if (item->type() == PartDynamicTextField::Type) {
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
dyntext->setRotation(+5);
}
else {
//item->setRotation(+5);
}
}
}
MirrorElementsCommand::MirrorElementsCommand(ElementScene *scene, QUndoCommand *parent) : MirrorElementsCommand::MirrorElementsCommand(ElementScene *scene, QUndoCommand *parent) :
ElementEditionCommand(QObject::tr("Miroir de sélection", "undo caption"), scene, nullptr, parent) ElementEditionCommand(QObject::tr("Miroir de sélection", "undo caption"), scene, nullptr, parent)
{ {
@@ -603,9 +684,12 @@ ElementEditionCommand(QObject::tr("Miroir de sélection", "undo caption"), scene
void MirrorElementsCommand::redo() void MirrorElementsCommand::redo()
{ {
foreach (auto *item, m_items) { foreach (auto *item, m_items) {
if ((item->type() == PartText::Type) || if (item->type() == PartText::Type) {
(item->type() == PartDynamicTextField::Type)) { PartText* staticText = qgraphicsitem_cast<PartText*>(item);
continue; //staticText->mirror();
} else if (item->type() == PartDynamicTextField::Type) {
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
dyntext->mirror();
} else if (item->type() == PartArc::Type) { } else if (item->type() == PartArc::Type) {
PartArc* arc = qgraphicsitem_cast<PartArc*>(item); PartArc* arc = qgraphicsitem_cast<PartArc*>(item);
arc->mirror(); arc->mirror();
@@ -648,9 +732,12 @@ ElementEditionCommand(QObject::tr("Retourner la sélection", "undo caption"), sc
void FlipElementsCommand::redo() void FlipElementsCommand::redo()
{ {
foreach (auto *item, m_items) { foreach (auto *item, m_items) {
if ((item->type() == PartText::Type) || if (item->type() == PartText::Type) {
(item->type() == PartDynamicTextField::Type)) { PartText* staticText = qgraphicsitem_cast<PartText*>(item);
continue; //staticText->flip();
} else if (item->type() == PartDynamicTextField::Type) {
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
dyntext->flip();
} else if (item->type() == PartArc::Type) { } else if (item->type() == PartArc::Type) {
PartArc* arc = qgraphicsitem_cast<PartArc*>(item); PartArc* arc = qgraphicsitem_cast<PartArc*>(item);
arc->flip(); arc->flip();
+14
View File
@@ -265,6 +265,20 @@ private:
}; };
class RotateFineElementsCommand : public ElementEditionCommand
{
public:
RotateFineElementsCommand(ElementScene *scene, QUndoCommand *parent=nullptr);
void undo() override;
void redo() override;
private:
ElementScene *m_scene =nullptr;
QList<QGraphicsItem*> m_items;
};
class MirrorElementsCommand : public ElementEditionCommand class MirrorElementsCommand : public ElementEditionCommand
{ {
public: public:
@@ -33,7 +33,7 @@ PartDynamicTextField::PartDynamicTextField(QETElementEditor *editor, QGraphicsIt
setDefaultTextColor(Qt::black); setDefaultTextColor(Qt::black);
setFont(QETApp::dynamicTextsItemFont()); setFont(QETApp::dynamicTextsItemFont());
QSettings settings; QSettings settings;
setRotation(settings.value("diagrameditor/dynamic_text_rotation", 0).toInt()); QGraphicsObject::setRotation(QET::correctAngle(settings.value("diagrameditor/dynamic_text_rotation", 0).toInt()));
setTextWidth(settings.value("diagrameditor/dynamic_text_width", -1).toInt()); setTextWidth(settings.value("diagrameditor/dynamic_text_width", -1).toInt());
setText("_"); setText("_");
setTextFrom(DynamicElementTextItem::UserText); setTextFrom(DynamicElementTextItem::UserText);
@@ -60,6 +60,41 @@ QString PartDynamicTextField::xmlName() const
return QString("dynamic_text"); return QString("dynamic_text");
} }
/**
Redefines setRotation
@param angle
*/
void PartDynamicTextField::setRotation(qreal angle) {
QGraphicsObject::setRotation(QET::correctAngle(rotation()+angle, true));
setPos(QTransform().rotate(angle).map(pos()));
}
void PartDynamicTextField::mirror() {
// at first: rotate the text:
QGraphicsObject::setRotation(QET::correctAngle(360-rotation(), true));
// then see, where we need to re-position depending on the angle!
qreal rot = qRound(QET::correctAngle(rotation(), true));
qreal c = qCos(qDegreesToRadians(rot));
qreal s = qSin(qDegreesToRadians(rot));
qreal x = (-1) * pos().x() - c * boundingRect().width();
qreal y = pos().y() - s * boundingRect().width();
setPos(x, y);
}
void PartDynamicTextField::flip() {
// at first: rotate the text:
QGraphicsObject::setRotation(QET::correctAngle(360-rotation(), true));
// then see, where we need to re-position depending on the angle!
qreal rot = qRound(QET::correctAngle(rotation(), true));
qreal c = qCos(qDegreesToRadians(rot));
qreal s = qSin(qDegreesToRadians(rot));
qreal x = pos().x() + s * boundingRect().height();
qreal y = (-1) * pos().y() - c * boundingRect().height();
setPos(x, y);
}
/** /**
@brief PartDynamicTextField::startUserTransformation @brief PartDynamicTextField::startUserTransformation
@param initial_selection_rect @param initial_selection_rect
@@ -172,7 +207,7 @@ void PartDynamicTextField::fromXml(const QDomElement &dom_elmt) {
dom_elmt.attribute("y", QString::number(0)).toDouble() dom_elmt.attribute("y", QString::number(0)).toDouble()
); );
setZValue(dom_elmt.attribute("z", QString::number(zValue())).toDouble()); setZValue(dom_elmt.attribute("z", QString::number(zValue())).toDouble());
QGraphicsTextItem::setRotation(dom_elmt.attribute("rotation", QString::number(0)).toDouble()); QGraphicsObject::setRotation(QET::correctAngle(dom_elmt.attribute("rotation", QString::number(0)).toDouble()));
setKeepVisualRotation(dom_elmt.attribute("keep_visual_rotation", "true") == "true"? true : false); setKeepVisualRotation(dom_elmt.attribute("keep_visual_rotation", "true") == "true"? true : false);
if (dom_elmt.hasAttribute("font")) { if (dom_elmt.hasAttribute("font")) {
@@ -255,7 +290,7 @@ void PartDynamicTextField::fromTextFieldXml(const QDomElement &dom_element)
setInfoName(dom_element.attribute("tagg", "label")); setInfoName(dom_element.attribute("tagg", "label"));
} }
QGraphicsTextItem::setRotation(dom_element.attribute("rotation", "0").toDouble()); QGraphicsObject::setRotation(QET::correctAngle(dom_element.attribute("rotation", "0").toDouble()));
//the origin transformation point of PartDynamicTextField is the top left corner, no matter the font size //the origin transformation point of PartDynamicTextField is the top left corner, no matter the font size
//The origin transformation point of PartTextField is the middle of left edge, and so by definition, change with the size of the font //The origin transformation point of PartTextField is the middle of left edge, and so by definition, change with the size of the font
@@ -460,7 +495,7 @@ bool PartDynamicTextField::keepVisualRotation() const {
*/ */
void PartDynamicTextField::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { void PartDynamicTextField::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
if((event -> buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable)) { if((event -> buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable)) {
QPointF pos = event -> scenePos() + (m_origine_pos - event -> buttonDownScenePos(Qt::LeftButton)); QPointF pos = event -> scenePos() + (m_origin_pos - event -> buttonDownScenePos(Qt::LeftButton));
event -> modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene() -> snapToGrid(pos)); event -> modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene() -> snapToGrid(pos));
} }
else else
@@ -473,7 +508,7 @@ void PartDynamicTextField::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
*/ */
void PartDynamicTextField::mousePressEvent(QGraphicsSceneMouseEvent *event) { void PartDynamicTextField::mousePressEvent(QGraphicsSceneMouseEvent *event) {
if(event -> button() == Qt::LeftButton) if(event -> button() == Qt::LeftButton)
m_origine_pos = this -> pos(); m_origin_pos = this -> pos();
QGraphicsObject::mousePressEvent(event); QGraphicsObject::mousePressEvent(event);
} }
@@ -485,9 +520,9 @@ void PartDynamicTextField::mousePressEvent(QGraphicsSceneMouseEvent *event) {
void PartDynamicTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { void PartDynamicTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if((event -> button() & Qt::LeftButton) && if((event -> button() & Qt::LeftButton) &&
(flags() & QGraphicsItem::ItemIsMovable) && (flags() & QGraphicsItem::ItemIsMovable) &&
m_origine_pos != pos()) { m_origin_pos != pos()) {
QPropertyUndoCommand *undo =\ QPropertyUndoCommand *undo =\
new QPropertyUndoCommand(this, "pos", QVariant(m_origine_pos), QVariant(pos())); new QPropertyUndoCommand(this, "pos", QVariant(m_origin_pos), QVariant(pos()));
undo -> setText(tr("Déplacer un champ texte")); undo -> setText(tr("Déplacer un champ texte"));
undo -> enableAnimation(); undo -> enableAnimation();
elementScene() -> undoStack().push(undo); elementScene() -> undoStack().push(undo);
@@ -101,6 +101,11 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
void setKeepVisualRotation(const bool &keep); void setKeepVisualRotation(const bool &keep);
bool keepVisualRotation() const; bool keepVisualRotation() const;
void setRotation(qreal angle);
void mirror();
void flip();
protected: protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
void mousePressEvent(QGraphicsSceneMouseEvent *event) override; void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
@@ -114,7 +119,7 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
void finishAlignment(); void finishAlignment();
private: private:
QPointF m_origine_pos, QPointF m_origin_pos,
m_saved_point; m_saved_point;
QString m_text, QString m_text,
m_info_name, m_info_name,
+4 -4
View File
@@ -251,10 +251,10 @@ void PartEllipse::setRotation(qreal angle) {
qreal x = m_rect.y(); qreal x = m_rect.y();
qreal y = (m_rect.x() + m_rect.width()) * (-1); qreal y = (m_rect.x() + m_rect.width()) * (-1);
m_rect = QRectF(x, y, width, height); m_rect = QRectF(x, y, width, height);
} }
prepareGeometryChange(); prepareGeometryChange();
adjustHandlerPos(); adjustHandlerPos();
emit rectChanged(); emit rectChanged();
} }
qreal PartEllipse::rotation() const { qreal PartEllipse::rotation() const {
+3 -20
View File
@@ -579,26 +579,9 @@ void PartLine::setSecondEndLength(const qreal &l)
} }
void PartLine::setRotation(qreal angle) { void PartLine::setRotation(qreal angle) {
double tmp, x, y; m_rot += angle;
if (angle > 0) { m_line.setP1(QTransform().rotate(angle).map(m_line.p1()));
tmp = m_line.p1().y(); m_line.setP2(QTransform().rotate(angle).map(m_line.p2()));
y = m_line.p1().x();
x = (-1) * tmp;
m_line.setP1(QPointF(x, y));
tmp = m_line.p2().y();
y = m_line.p2().x();
x = (-1) * tmp;
m_line.setP2(QPointF(x, y));
} else {
tmp = m_line.p1().x();
x = m_line.p1().y();
y = (-1) * tmp;
m_line.setP1(QPointF(x, y));
tmp = m_line.p2().x();
x = m_line.p2().y();
y = (-1) * tmp;
m_line.setP2(QPointF(x, y));
}
prepareGeometryChange(); prepareGeometryChange();
setLine(m_line); setLine(m_line);
adjustHandlerPos(); adjustHandlerPos();
+3 -15
View File
@@ -297,21 +297,9 @@ void PartPolygon::resetAllHandlerColor()
void PartPolygon::setRotation(qreal angle) { void PartPolygon::setRotation(qreal angle) {
for (auto &punkt : m_polygon) { QTransform rotation = QTransform().rotate(angle);
double tmp, x, y; m_rot += angle;
if (angle > 0) { setPolygon(rotation.map(m_polygon));
tmp = punkt.y();
y = punkt.x();
x = (-1) * tmp;
} else {
tmp = punkt.x();
x = punkt.y();
y = (-1) * tmp;
}
punkt = QPointF(x, y);
}
setPolygon(m_polygon);
prepareGeometryChange(); prepareGeometryChange();
adjustHandlerPos(); adjustHandlerPos();
emit polygonChanged(); emit polygonChanged();
+17 -5
View File
@@ -63,6 +63,15 @@ PartText::~PartText()
{ {
} }
/**
Redefines setRotation
@param angle
*/
void PartText::setRotation(qreal angle) {
QGraphicsObject::setRotation(QET::correctAngle(rotation()+angle, true));
setPos(QTransform().rotate(angle).map(pos()));
}
/** /**
Importe les proprietes d'un texte statique depuis un element XML Importe les proprietes d'un texte statique depuis un element XML
@param xml_element Element XML a lire @param xml_element Element XML a lire
@@ -89,7 +98,7 @@ void PartText::fromXml(const QDomElement &xml_element) {
setPlainText(xml_element.attribute("text")); setPlainText(xml_element.attribute("text"));
setPos(xml_element.attribute("x").toDouble(), setPos(xml_element.attribute("x").toDouble(),
xml_element.attribute("y").toDouble()); xml_element.attribute("y").toDouble());
setRotation(xml_element.attribute("rotation", QString::number(0)).toDouble()); QGraphicsObject::setRotation(QET::correctAngle(xml_element.attribute("rotation", QString::number(0)).toDouble()));
} }
/** /**
@@ -116,6 +125,7 @@ const QDomElement PartText::toXml(QDomDocument &xml_document) const
/** /**
@return Les coordonnees du point situe en bas a gauche du texte. @return Les coordonnees du point situe en bas a gauche du texte.
The coordinates of the point at the bottom left of the text.
*/ */
QPointF PartText::margin() const QPointF PartText::margin() const
{ {
@@ -124,8 +134,10 @@ QPointF PartText::margin() const
qreal document_margin = document() -> documentMargin(); qreal document_margin = document() -> documentMargin();
QPointF margin( QPointF margin(
// margin around the text
// marge autour du texte // marge autour du texte
document_margin, document_margin,
// margin above the text + distance between the top of the text and the baseline
// marge au-dessus du texte + distance entre le plafond du texte et la baseline // marge au-dessus du texte + distance entre le plafond du texte et la baseline
document_margin + qfm.ascent() document_margin + qfm.ascent()
); );
@@ -273,7 +285,7 @@ void PartText::setFont(const QFont &font) {
void PartText::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { void PartText::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
if((event -> buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable)) { if((event -> buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable)) {
QPointF pos = event -> scenePos() + (m_origine_pos - event -> buttonDownScenePos(Qt::LeftButton)); QPointF pos = event -> scenePos() + (m_origin_pos - event -> buttonDownScenePos(Qt::LeftButton));
event -> modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene() -> snapToGrid(pos)); event -> modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene() -> snapToGrid(pos));
} }
else { else {
@@ -283,7 +295,7 @@ void PartText::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
void PartText::mousePressEvent(QGraphicsSceneMouseEvent *event) { void PartText::mousePressEvent(QGraphicsSceneMouseEvent *event) {
if(event -> button() == Qt::LeftButton) if(event -> button() == Qt::LeftButton)
m_origine_pos = this -> pos(); m_origin_pos = this -> pos();
QGraphicsObject::mousePressEvent(event); QGraphicsObject::mousePressEvent(event);
} }
@@ -291,9 +303,9 @@ void PartText::mousePressEvent(QGraphicsSceneMouseEvent *event) {
void PartText::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { void PartText::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if((event -> button() & Qt::LeftButton) && if((event -> button() & Qt::LeftButton) &&
(flags() & QGraphicsItem::ItemIsMovable) && (flags() & QGraphicsItem::ItemIsMovable) &&
m_origine_pos != pos()) m_origin_pos != pos())
{ {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "pos", QVariant(m_origine_pos), QVariant(pos())); QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "pos", QVariant(m_origin_pos), QVariant(pos()));
undo -> setText(tr("Déplacer un texte")); undo -> setText(tr("Déplacer un texte"));
undo -> enableAnimation(); undo -> enableAnimation();
elementScene() -> undoStack().push(undo); elementScene() -> undoStack().push(undo);
+2 -2
View File
@@ -61,7 +61,7 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
QString xmlName() const override { return(QString("text")); } QString xmlName() const override { return(QString("text")); }
void fromXml(const QDomElement &) override; void fromXml(const QDomElement &) override;
const QDomElement toXml(QDomDocument &) const override; const QDomElement toXml(QDomDocument &) const override;
void setRotation(qreal angle) {(QGraphicsObject::setRotation(QET::correctAngle(angle)));} void setRotation(qreal angle);
bool isUseless() const override; bool isUseless() const override;
QRectF sceneGeometricRect() const override; QRectF sceneGeometricRect() const override;
void startUserTransformation(const QRectF &) override; void startUserTransformation(const QRectF &) override;
@@ -100,6 +100,6 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
QPointF saved_point_; QPointF saved_point_;
qreal saved_font_size_; qreal saved_font_size_;
QGraphicsItem *decorator_; QGraphicsItem *decorator_;
QPointF m_origine_pos; QPointF m_origin_pos;
}; };
#endif #endif
+5
View File
@@ -1002,6 +1002,10 @@ void QETElementEditor::setupActions()
ui->m_rotate_action -> setShortcut(Qt::Key_Space); ui->m_rotate_action -> setShortcut(Qt::Key_Space);
connect(ui->m_rotate_action, &QAction::triggered, [this]() {this -> elementScene() -> undoStack().push(new RotateElementsCommand(this->elementScene()));}); connect(ui->m_rotate_action, &QAction::triggered, [this]() {this -> elementScene() -> undoStack().push(new RotateElementsCommand(this->elementScene()));});
//Rotate Fine action = rotate with smaller inkrement
ui->m_rotateFine_action -> setShortcut(Qt::CTRL | Qt::Key_Space);
connect(ui->m_rotateFine_action, &QAction::triggered, [this]() {this -> elementScene() -> undoStack().push(new RotateFineElementsCommand(this->elementScene()));});
//Flip action //Flip action
ui->m_flip_action -> setShortcut(Qt::Key_F); ui->m_flip_action -> setShortcut(Qt::Key_F);
connect(ui->m_flip_action, &QAction::triggered, [this]() {this -> elementScene() -> undoStack().push(new FlipElementsCommand(this->elementScene()));}); connect(ui->m_flip_action, &QAction::triggered, [this]() {this -> elementScene() -> undoStack().push(new FlipElementsCommand(this->elementScene()));});
@@ -1076,6 +1080,7 @@ void QETElementEditor::updateAction()
<< ui->m_copy_action << ui->m_copy_action
<< ui->m_delete_action << ui->m_delete_action
<< ui->m_rotate_action << ui->m_rotate_action
<< ui->m_rotateFine_action
<< ui->m_flip_action << ui->m_flip_action
<< ui->m_mirror_action; << ui->m_mirror_action;
auto items_selected = !m_read_only && m_elmt_scene->selectedItems().count(); auto items_selected = !m_read_only && m_elmt_scene->selectedItems().count();
+10
View File
@@ -77,6 +77,7 @@
<addaction name="m_edit_author_action"/> <addaction name="m_edit_author_action"/>
<addaction name="m_edit_element_properties_action"/> <addaction name="m_edit_element_properties_action"/>
<addaction name="m_rotate_action"/> <addaction name="m_rotate_action"/>
<addaction name="m_rotateFine_action"/>
<addaction name="m_mirror_action"/> <addaction name="m_mirror_action"/>
<addaction name="m_flip_action"/> <addaction name="m_flip_action"/>
</widget> </widget>
@@ -495,6 +496,15 @@
<string>Rotation</string> <string>Rotation</string>
</property> </property>
</action> </action>
<action name="m_rotateFine_action">
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/orientations.png</normaloff>:/ico/16x16/orientations.png</iconset>
</property>
<property name="text">
<string>Fine-Rotation</string>
</property>
</action>
<action name="m_mirror_action"> <action name="m_mirror_action">
<property name="icon"> <property name="icon">
<iconset resource="../../../qelectrotech.qrc"> <iconset resource="../../../qelectrotech.qrc">
@@ -519,6 +519,10 @@ void ElementPictureFactory::parseText(const QDomElement &dom, QPainter &painter,
painter.rotate(dom.attribute("rotation", "0").toDouble()); painter.rotate(dom.attribute("rotation", "0").toDouble());
/* /*
Moves the QPainter's coordinate system to render in the right place;
note: the font's ascent() is subtracted to determine the top left
corner of the text, whereas the position indicated corresponds
to the baseline.
Deplace le systeme de coordonnees du QPainter pour effectuer le rendu au Deplace le systeme de coordonnees du QPainter pour effectuer le rendu au
bon endroit ; note : on soustrait l'ascent() de la police pour bon endroit ; note : on soustrait l'ascent() de la police pour
determiner le coin superieur gauche du texte alors que la position determiner le coin superieur gauche du texte alors que la position
+4 -1
View File
@@ -576,8 +576,11 @@ qreal QET::round(qreal x, qreal epsilon) {
} }
/** /**
@param angle Un angle quelconque @param angle Un angle quelconque / any angle in degrees
@param positive (bool)
@return l'angle passe en parametre, mais ramene entre -360.0 + 360.0 degres @return l'angle passe en parametre, mais ramene entre -360.0 + 360.0 degres
the angle passed as a parameter, but reduced to between -360.0 +360.0 degrees
reduced to 0.0 .. 360.0, when bool-parameter is true
*/ */
qreal QET::correctAngle(const qreal &angle, const bool &positive) { qreal QET::correctAngle(const qreal &angle, const bool &positive) {
// ramene l'angle demande entre -360.0 et +360.0 degres // ramene l'angle demande entre -360.0 et +360.0 degres