Skip to content

Commit

Permalink
[TD] improve RichAnno and LeaderLine dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
donovaly authored and WandererFan committed Jan 28, 2020
1 parent 1991a08 commit 42e6aeb
Show file tree
Hide file tree
Showing 4 changed files with 363 additions and 162 deletions.
12 changes: 10 additions & 2 deletions src/Mod/TechDraw/Gui/TaskLeaderLine.cpp
Expand Up @@ -120,6 +120,10 @@ TaskLeaderLine::TaskLeaderLine(TechDrawGui::ViewProviderLeader* leadVP) :
this, SLOT(onCancelEditClicked(bool)));
ui->pbCancelEdit->setEnabled(false);

ui->dsbWeight->setUnit(Base::Unit::Length);
ui->dsbWeight->setMinimum(0);
ui->dsbWeight->setValue(0.5);

saveState();

m_trackerMode = QGTracker::TrackerMode::Line;
Expand Down Expand Up @@ -165,6 +169,10 @@ TaskLeaderLine::TaskLeaderLine(TechDraw::DrawView* baseFeat,
this, SLOT(onCancelEditClicked(bool)));
ui->pbCancelEdit->setEnabled(false);

ui->dsbWeight->setUnit(Base::Unit::Length);
ui->dsbWeight->setMinimum(0);
ui->dsbWeight->setValue(0.5);

m_trackerMode = QGTracker::TrackerMode::Line;
m_saveContextPolicy = m_mdi->contextMenuPolicy();

Expand Down Expand Up @@ -297,7 +305,7 @@ void TaskLeaderLine::createLeaderFeature(std::vector<Base::Vector3d> converted)
App::Color ac;
ac.setValue<QColor>(ui->cpLineColor->color());
leadVP->Color.setValue(ac);
leadVP->LineWidth.setValue(ui->dsbWeight->value());
leadVP->LineWidth.setValue(ui->dsbWeight->rawValue());
leadVP->LineStyle.setValue(ui->cboxStyle->currentIndex());
}
}
Expand All @@ -324,7 +332,7 @@ void TaskLeaderLine::updateLeaderFeature(void)
App::Color ac;
ac.setValue<QColor>(ui->cpLineColor->color());
m_lineVP->Color.setValue(ac);
m_lineVP->LineWidth.setValue(ui->dsbWeight->value());
m_lineVP->LineWidth.setValue(ui->dsbWeight->rawValue());
m_lineVP->LineStyle.setValue(ui->cboxStyle->currentIndex());

Gui::Command::updateActive();
Expand Down
25 changes: 21 additions & 4 deletions src/Mod/TechDraw/Gui/TaskLeaderLine.ui
Expand Up @@ -313,6 +313,9 @@
</item>
<item row="3" column="1">
<widget class="Gui::ColorButton" name="cpLineColor">
<property name="toolTip">
<string>Line color</string>
</property>
<property name="color" stdset="0">
<color>
<red>0</red>
Expand All @@ -325,16 +328,22 @@
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Weight</string>
<string>Width</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="dsbWeight">
<property name="singleStep">
<widget class="Gui::QuantitySpinBox" name="dsbWeight" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Line width</string>
</property>
<property name="singleStep" stdset="0">
<double>0.100000000000000</double>
</property>
<property name="value">
<property name="value" stdset="0">
<double>0.500000000000000</double>
</property>
</widget>
Expand All @@ -348,6 +357,9 @@
</item>
<item row="5" column="1">
<widget class="QComboBox" name="cboxStyle">
<property name="toolTip">
<string>Line style</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
Expand Down Expand Up @@ -414,6 +426,11 @@
<extends>QPushButton</extends>
<header>Gui/Widgets.h</header>
</customwidget>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="Resources/TechDraw.qrc"/>
Expand Down
31 changes: 31 additions & 0 deletions src/Mod/TechDraw/Gui/TaskRichAnno.cpp
Expand Up @@ -123,6 +123,9 @@ TaskRichAnno::TaskRichAnno(TechDrawGui::ViewProviderRichAnno* annoVP) :

connect(ui->pbEditor, SIGNAL(clicked(bool)),
this, SLOT(onEditorClicked(bool)));
ui->dsbWidth->setUnit(Base::Unit::Length);
ui->dsbWidth->setMinimum(0);
ui->dsbWidth->setValue(0.5);
}

//ctor for creation
Expand Down Expand Up @@ -165,6 +168,9 @@ TaskRichAnno::TaskRichAnno(TechDraw::DrawView* baseFeat,

connect(ui->pbEditor, SIGNAL(clicked(bool)),
this, SLOT(onEditorClicked(bool)));
ui->dsbWidth->setUnit(Base::Unit::Length);
ui->dsbWidth->setMinimum(0);
ui->dsbWidth->setValue(0.5);
}

TaskRichAnno::~TaskRichAnno()
Expand Down Expand Up @@ -204,6 +210,8 @@ void TaskRichAnno::enableTextUi(bool b)
ui->teAnnoText->setEnabled(b);
}

//switch widgets related to ViewProvider on/off
//there is no ViewProvider until some time after feature is created.
void TaskRichAnno::enableVPUi(bool b)
{
Q_UNUSED(b);
Expand All @@ -230,6 +238,12 @@ void TaskRichAnno::setUiEdit()
ui->dsbMaxWidth->setValue(m_annoFeat->MaxWidth.getValue());
ui->cbShowFrame->setChecked(m_annoFeat->ShowFrame.getValue());
}

if (m_annoVP != nullptr) {
ui->cpFrameColor->setColor(m_annoVP->LineColor.getValue().asValue<QColor>());
ui->dsbWidth->setValue(m_annoVP->LineWidth.getValue());
ui->cFrameStyle->setCurrentIndex(m_annoVP->LineStyle.getValue());
}
}

void TaskRichAnno::onEditorClicked(bool b)
Expand Down Expand Up @@ -309,6 +323,18 @@ void TaskRichAnno::createAnnoFeature()
m_annoFeat->Y.setValue(Rez::appX(vTemp.y));
}

if (m_annoFeat != nullptr) {
Gui::ViewProvider* vp = QGIView::getViewProvider(m_annoFeat);
auto annoVP = dynamic_cast<ViewProviderRichAnno*>(vp);
if (annoVP != nullptr) {
App::Color ac;
ac.setValue<QColor>(ui->cpFrameColor->color());
annoVP->LineColor.setValue(ac);
annoVP->LineWidth.setValue(ui->dsbWidth->rawValue());
annoVP->LineStyle.setValue(ui->cFrameStyle->currentIndex());
}
}

Gui::Command::updateActive();
Gui::Command::commitCommand();

Expand All @@ -327,6 +353,11 @@ void TaskRichAnno::updateAnnoFeature()
// Base::Console().Message("TRA::updateAnnoFeature()\n");
Gui::Command::openCommand("Edit Anno");
commonFeatureUpdate();
App::Color ac;
ac.setValue<QColor>(ui->cpFrameColor->color());
m_annoVP->LineColor.setValue(ac);
m_annoVP->LineWidth.setValue(ui->dsbWidth->rawValue());
m_annoVP->LineStyle.setValue(ui->cFrameStyle->currentIndex());

Gui::Command::commitCommand();
m_annoFeat->requestPaint();
Expand Down

0 comments on commit 42e6aeb

Please sign in to comment.