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)
This commit is contained in:
donovaly
2020-03-30 03:34:44 +02:00
committed by WandererFan
parent cb27fc0715
commit 42aa4560c5
6 changed files with 136 additions and 26 deletions

View File

@@ -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());

View File

@@ -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:
};

View File

@@ -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()

View File

@@ -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();

View File

@@ -108,6 +108,8 @@ public Q_SLOTS:
void onOtherSymbolClicked();
void onOtherEraseCreateClicked();
void onOtherEraseClicked();
void onFlipSidesCreateClicked();
void onFlipSidesClicked();
void onArrowTextChanged();
void onOtherTextChanged();
void onWeldingChanged();

View File

@@ -112,13 +112,6 @@
<layout class="QHBoxLayout" name="hlOtherSideLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="2">
<widget class="QLineEdit" name="leOtherTextR">
<property name="toolTip">
<string>Text after other side symbol</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pbOtherSymbol">
<property name="toolTip">
@@ -129,13 +122,6 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLineEdit" name="leOtherTextL">
<property name="toolTip">
<string>Text before other side symbol</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leOtherTextC">
<property name="toolTip">
@@ -143,6 +129,54 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="leOtherTextR">
<property name="toolTip">
<string>Text after other side symbol</string>
</property>
</widget>
</item>
<item row="1" column="2" alignment="Qt::AlignRight">
<widget class="QPushButton" name="pbFlipSides">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="baseSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>Flips the sides</string>
</property>
<property name="text">
<string>Flip Sides</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLineEdit" name="leOtherTextL">
<property name="toolTip">
<string>Text before other side symbol</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pbOtherErase">
<property name="sizePolicy">