From fe333b219fd2238a20269b1b3e48031159974a3c Mon Sep 17 00:00:00 2001 From: donovaly Date: Mon, 30 Mar 2020 03:34:44 +0200 Subject: [PATCH] fix tile properties - make TileColumn read-only - restrict TileRow to what is possible - improve tooltips - add button to flip the sides (the symbol is not mirrored, just flipped) --- src/Mod/TechDraw/App/DrawTile.cpp | 25 ++++++++- src/Mod/TechDraw/App/DrawTile.h | 5 +- src/Mod/TechDraw/App/DrawTileWeld.cpp | 11 ++-- src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp | 57 +++++++++++++++++++- src/Mod/TechDraw/Gui/TaskWeldingSymbol.h | 2 + src/Mod/TechDraw/Gui/TaskWeldingSymbol.ui | 62 +++++++++++++++++----- 6 files changed, 136 insertions(+), 26 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawTile.cpp b/src/Mod/TechDraw/App/DrawTile.cpp index 51af3ca07c..fbeb6b4c27 100644 --- a/src/Mod/TechDraw/App/DrawTile.cpp +++ b/src/Mod/TechDraw/App/DrawTile.cpp @@ -49,8 +49,17 @@ DrawTile::DrawTile(void) ADD_PROPERTY_TYPE(TileParent,(0),group,(App::PropertyType)(App::Prop_None), "Object to which this tile is attached"); - ADD_PROPERTY_TYPE(TileRow, (0), group, App::Prop_None, "Row in parent"); - ADD_PROPERTY_TYPE(TileColumn, (0), group, App::Prop_None, "Column in parent"); + ADD_PROPERTY_TYPE(TileRow, (0), group, App::Prop_None, "Row in parent object\n 0 for arrow side, -1 for other side"); + ADD_PROPERTY_TYPE(TileColumn, (0), group, App::Prop_None, "Column in parent object"); + + // there is currently only one column, this don't allow to edit + TileColumn.setStatus(App::Property::ReadOnly, true); + // the row can only have the value 0 or -1 + // allow its editing because this way the tiles can be flipped + TileRowConstraints.LowerBound = -1; + TileRowConstraints.UpperBound = 0; + TileRowConstraints.StepSize = 1; + TileRow.setConstraints(&TileRowConstraints); } DrawTile::~DrawTile() @@ -77,6 +86,18 @@ App::DocumentObjectExecReturn *DrawTile::execute(void) return DocumentObject::execute(); } +void DrawTile::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +// transforms properties that had been changed +{ + // property TileRow had App::PropertyInteger and was changed to App::PropertyIntegerConstraint + if (prop == &TileRow && strcmp(TypeName, "App::PropertyInteger") == 0) { + App::PropertyInteger TileRowProperty; + // restore the PropertyInteger to be able to set its value + TileRowProperty.Restore(reader); + TileRow.setValue(TileRowProperty.getValue()); + } +} + DrawView* DrawTile::getParent(void) const { // Base::Console().Message("DT::getParent() - %s\n", getNameInDocument()); diff --git a/src/Mod/TechDraw/App/DrawTile.h b/src/Mod/TechDraw/App/DrawTile.h index 1f3de65d43..221a35782d 100644 --- a/src/Mod/TechDraw/App/DrawTile.h +++ b/src/Mod/TechDraw/App/DrawTile.h @@ -40,9 +40,9 @@ public: virtual ~DrawTile(); App::PropertyLink TileParent; //eg DrawWeldSymbol - App::PropertyInteger TileRow; + App::PropertyIntegerConstraint TileRow; + App::PropertyIntegerConstraint::Constraints TileRowConstraints; App::PropertyInteger TileColumn; -/* App::PropertyVector TileOrigin; //sb call to TileParent - WeldingSymbol*/ virtual short mustExecute() const; virtual App::DocumentObjectExecReturn *execute(void); @@ -55,6 +55,7 @@ public: protected: virtual void onChanged(const App::Property* prop); + virtual void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property * prop); private: }; diff --git a/src/Mod/TechDraw/App/DrawTileWeld.cpp b/src/Mod/TechDraw/App/DrawTileWeld.cpp index 8be2991608..8d737d002e 100644 --- a/src/Mod/TechDraw/App/DrawTileWeld.cpp +++ b/src/Mod/TechDraw/App/DrawTileWeld.cpp @@ -53,18 +53,17 @@ DrawTileWeld::DrawTileWeld(void) static const char *group = "TileWeld"; ADD_PROPERTY_TYPE(LeftText,(""),group,(App::PropertyType)(App::Prop_None), - "Text LHS"); - ADD_PROPERTY_TYPE(RightText, (0), group, App::Prop_None, "Text RHS"); - ADD_PROPERTY_TYPE(CenterText, (0), group, App::Prop_None, "Text above Symbol"); - ADD_PROPERTY_TYPE(SymbolFile, (prefSymbol()), group, App::Prop_None, "Symbol Symbol File"); - ADD_PROPERTY_TYPE(SymbolIncluded, (""), group,App::Prop_None, + "Text before symbol"); + ADD_PROPERTY_TYPE(RightText, (0), group, App::Prop_None, "Text after symbol"); + ADD_PROPERTY_TYPE(CenterText, (0), group, App::Prop_None, "Text above/below symbol"); + ADD_PROPERTY_TYPE(SymbolFile, (prefSymbol()), group, App::Prop_None, "Symbol File"); + ADD_PROPERTY_TYPE(SymbolIncluded, (""), group, App::Prop_None, "Embedded Symbol. System use only."); // n/a to end users // SymbolFile.setStatus(App::Property::ReadOnly,true); std::string svgFilter("Symbol files (*.svg *.SVG);;All files (*)"); SymbolFile.setFilter(svgFilter); - } DrawTileWeld::~DrawTileWeld() diff --git a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp index 1e49c58d7b..a2a236b2b5 100644 --- a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp +++ b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp @@ -102,6 +102,8 @@ TaskWeldingSymbol::TaskWeldingSymbol(TechDraw::DrawLeaderLine* leader) : this, SLOT(onOtherSymbolCreateClicked())); connect(ui->pbOtherErase, SIGNAL(clicked(bool)), this, SLOT(onOtherEraseCreateClicked())); + connect(ui->pbFlipSides, SIGNAL(clicked(bool)), + this, SLOT(onFlipSidesCreateClicked())); connect(ui->fcSymbolDir, SIGNAL(fileNameSelected(const QString&)), this, SLOT(onDirectorySelected(const QString&))); } @@ -136,11 +138,12 @@ TaskWeldingSymbol::TaskWeldingSymbol(TechDraw::DrawWeldSymbol* weld) : connect(ui->pbArrowSymbol, SIGNAL(clicked(bool)), this, SLOT(onArrowSymbolClicked())); - connect(ui->pbOtherSymbol, SIGNAL(clicked(bool)), this, SLOT(onOtherSymbolClicked())); connect(ui->pbOtherErase, SIGNAL(clicked(bool)), this, SLOT(onOtherEraseClicked())); + connect(ui->pbFlipSides, SIGNAL(clicked(bool)), + this, SLOT(onFlipSidesClicked())); connect(ui->fcSymbolDir, SIGNAL(fileNameSelected(const QString&)), this, SLOT(onDirectorySelected(const QString&))); @@ -231,7 +234,7 @@ void TaskWeldingSymbol::setUiEdit() if (fi.isReadable()) { qTemp = QString::fromUtf8(m_arrowFeat->SymbolFile.getValue()); QIcon targetIcon(qTemp); - QSize iconSize(32,32); + QSize iconSize(32, 32); ui->pbArrowSymbol->setIcon(targetIcon); ui->pbArrowSymbol->setIconSize(iconSize); ui->pbArrowSymbol->setText(QString()); @@ -335,6 +338,56 @@ void TaskWeldingSymbol::onOtherEraseClicked() m_weldFeat->requestPaint(); } +void TaskWeldingSymbol::onFlipSidesCreateClicked() +{ + QString tempText = ui->leOtherTextL->text(); + ui->leOtherTextL->setText(ui->leArrowTextL->text()); + ui->leArrowTextL->setText(tempText); + tempText = ui->leOtherTextC->text(); + ui->leOtherTextC->setText(ui->leArrowTextC->text()); + ui->leArrowTextC->setText(tempText); + tempText = ui->leOtherTextR->text(); + ui->leOtherTextR->setText(ui->leArrowTextR->text()); + ui->leArrowTextR->setText(tempText); + + QString tempPathArrow = m_otherPath; + m_otherPath = m_arrowPath; + m_arrowPath = tempPathArrow; + tempText = ui->pbOtherSymbol->text(); + ui->pbOtherSymbol->setText(ui->pbArrowSymbol->text()); + ui->pbArrowSymbol->setText(tempText); + QIcon tempIcon = ui->pbOtherSymbol->icon(); + ui->pbOtherSymbol->setIcon(ui->pbArrowSymbol->icon()); + ui->pbArrowSymbol->setIcon(tempIcon); +} + +void TaskWeldingSymbol::onFlipSidesClicked() +{ + QString tempText = ui->leOtherTextL->text(); + ui->leOtherTextL->setText(ui->leArrowTextL->text()); + ui->leArrowTextL->setText(tempText); + tempText = ui->leOtherTextC->text(); + ui->leOtherTextC->setText(ui->leArrowTextC->text()); + ui->leArrowTextC->setText(tempText); + tempText = ui->leOtherTextR->text(); + ui->leOtherTextR->setText(ui->leArrowTextR->text()); + ui->leArrowTextR->setText(tempText); + + // one cannot get the path from the icon therfore read out + // the path property + auto tempPathArrow = m_arrowFeat->SymbolFile.getValue(); + auto tempPathOther = m_otherFeat->SymbolFile.getValue(); + m_otherPath = QString::fromLatin1(tempPathArrow); + m_arrowPath = QString::fromLatin1(tempPathOther); + QIcon tempIcon = ui->pbOtherSymbol->icon(); + ui->pbOtherSymbol->setIcon(ui->pbArrowSymbol->icon()); + ui->pbArrowSymbol->setIcon(tempIcon); + + m_otherDirty = true; + updateTiles(); + m_weldFeat->requestPaint(); +} + void TaskWeldingSymbol::onArrowTextChanged() { updateTiles(); diff --git a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.h b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.h index 84f4b44530..6702f82bd4 100644 --- a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.h +++ b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.h @@ -108,6 +108,8 @@ public Q_SLOTS: void onOtherSymbolClicked(); void onOtherEraseCreateClicked(); void onOtherEraseClicked(); + void onFlipSidesCreateClicked(); + void onFlipSidesClicked(); void onArrowTextChanged(); void onOtherTextChanged(); void onWeldingChanged(); diff --git a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.ui b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.ui index c1955ee51a..504f12f6b9 100644 --- a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.ui +++ b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.ui @@ -112,13 +112,6 @@ - - - - Text after other side symbol - - - @@ -129,13 +122,6 @@ - - - - Text before other side symbol - - - @@ -143,6 +129,54 @@ + + + + Text after other side symbol + + + + + + + + 0 + 0 + + + + + 60 + 30 + + + + + 60 + 30 + + + + + 60 + 30 + + + + Flips the sides + + + Flip Sides + + + + + + + Text before other side symbol + + +