PD: improve reference highlighting of a pipe
This change allows to highlight the spline, auxiliary spine, profile and sections of a pipe. This gives the user a much better feedback of what external shapes are already used to build the pipe
This commit is contained in:
@@ -98,6 +98,14 @@
|
||||
<item>
|
||||
<widget class="QLineEdit" name="profileBaseEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonProfileClear">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/edit-cleartext.svg</normaloff>:/icons/edit-cleartext.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -244,7 +252,9 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../../Gui/Icons/resource.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>comboBoxMode</sender>
|
||||
|
||||
@@ -156,7 +156,7 @@ TaskPipeParameters::~TaskPipeParameters()
|
||||
|
||||
//setting visibility to true is needed when preselecting profile and path prior to invoking sweep
|
||||
Gui::cmdGuiObject(pipe, "Visibility = True");
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, false);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Spine, false);
|
||||
}
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
@@ -224,7 +224,6 @@ void TaskPipeParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
}
|
||||
|
||||
clearButtons();
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, false);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
@@ -246,12 +245,12 @@ void TaskPipeParameters::onButtonRefAdd(bool checked) {
|
||||
//hideObject();
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = refAdd;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(true, false);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Spine, true);
|
||||
}
|
||||
else {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = none;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, false);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Spine, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,12 +261,12 @@ void TaskPipeParameters::onButtonRefRemove(bool checked) {
|
||||
//hideObject();
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = refRemove;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(true, false);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Spine, true);
|
||||
}
|
||||
else {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = none;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, false);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Spine, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +277,12 @@ void TaskPipeParameters::onBaseButton(bool checked) {
|
||||
//hideObject();
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = refObjAdd;
|
||||
//DressUpView->highlightReferences(true);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Spine, true);
|
||||
}
|
||||
else {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = none;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Spine, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,12 +297,16 @@ void TaskPipeParameters::onProfileButton(bool checked)
|
||||
pvp->setVisible(true);
|
||||
}
|
||||
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, false);
|
||||
//clearButtons(refRemove);
|
||||
//hideObject();
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = refProfile;
|
||||
//DressUpView->highlightReferences(true);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Profile, true);
|
||||
}
|
||||
else {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = none;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Profile, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,6 +367,8 @@ bool TaskPipeParameters::referenceSelected(const SelectionChanges& msg) const {
|
||||
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject());
|
||||
Gui::Document* doc = vp->getDocument();
|
||||
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Profile, false);
|
||||
|
||||
bool success = true;
|
||||
App::DocumentObject* profile = pipe->getDocument()->getObject(msg.pObjectName);
|
||||
if (profile) {
|
||||
@@ -385,6 +395,7 @@ bool TaskPipeParameters::referenceSelected(const SelectionChanges& msg) const {
|
||||
std::vector<std::string>::iterator f = std::find(refs.begin(), refs.end(), subName);
|
||||
|
||||
if (selectionMode == refObjAdd) {
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Spine, false);
|
||||
refs.clear();
|
||||
}
|
||||
else if (selectionMode == refAdd) {
|
||||
@@ -446,6 +457,8 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, bool /*newO
|
||||
this, SLOT(onButtonRefRemove(bool)));
|
||||
connect(ui->buttonProfileBase, SIGNAL(toggled(bool)),
|
||||
this, SLOT(onBaseButton(bool)));
|
||||
connect(ui->buttonProfileClear, SIGNAL(clicked()),
|
||||
this, SLOT(onClearButton()));
|
||||
connect(ui->stackedWidget, SIGNAL(currentChanged(int)),
|
||||
this, SLOT(updateUI(int)));
|
||||
connect(ui->curvelinear, SIGNAL(toggled(bool)),
|
||||
@@ -517,7 +530,7 @@ TaskPipeOrientation::~TaskPipeOrientation()
|
||||
auxSpineShow = false;
|
||||
}
|
||||
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, true);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::AuxiliarySpine, false);
|
||||
}
|
||||
}
|
||||
catch (const Base::RuntimeError&) {
|
||||
@@ -549,12 +562,12 @@ void TaskPipeOrientation::onButtonRefAdd(bool checked) {
|
||||
if (checked) {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = refAdd;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(true, true);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::AuxiliarySpine, true);
|
||||
}
|
||||
else {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = none;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, true);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::AuxiliarySpine, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,12 +576,12 @@ void TaskPipeOrientation::onButtonRefRemove(bool checked) {
|
||||
if (checked) {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = refRemove;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(true, true);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::AuxiliarySpine, true);
|
||||
}
|
||||
else {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = none;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, true);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::AuxiliarySpine, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,7 +590,22 @@ void TaskPipeOrientation::onBaseButton(bool checked)
|
||||
if (checked) {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = refObjAdd;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::AuxiliarySpine, true);
|
||||
}
|
||||
else {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = none;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::AuxiliarySpine, false);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskPipeOrientation::onClearButton()
|
||||
{
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::AuxiliarySpine, false);
|
||||
|
||||
ui->listWidgetReferences->clear();
|
||||
ui->profileBaseEdit->clear();
|
||||
static_cast<PartDesign::Pipe*>(vp->getObject())->AuxillerySpine.setValue(nullptr);
|
||||
}
|
||||
|
||||
void TaskPipeOrientation::onCurvelinearChanged(bool checked)
|
||||
@@ -639,7 +667,7 @@ void TaskPipeOrientation::onSelectionChanged(const SelectionChanges& msg) {
|
||||
}
|
||||
|
||||
clearButtons();
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, true);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::AuxiliarySpine, false);
|
||||
recomputeFeature();
|
||||
}
|
||||
|
||||
@@ -808,7 +836,12 @@ void TaskPipeScaling::onButtonRefAdd(bool checked) {
|
||||
if (checked) {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = refAdd;
|
||||
//static_cast<ViewProviderPipe*>(vp)->highlightReferences(true, true);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Section, true);
|
||||
}
|
||||
else {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = none;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Section, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -817,7 +850,12 @@ void TaskPipeScaling::onButtonRefRemove(bool checked) {
|
||||
if (checked) {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = refRemove;
|
||||
//static_cast<ViewProviderPipe*>(vp)->highlightReferences(true, true);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Section, true);
|
||||
}
|
||||
else {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = none;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Section, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -850,7 +888,6 @@ void TaskPipeScaling::onSelectionChanged(const SelectionChanges& msg) {
|
||||
}
|
||||
|
||||
clearButtons();
|
||||
//static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, true);
|
||||
recomputeFeature();
|
||||
}
|
||||
clearButtons();
|
||||
@@ -892,6 +929,7 @@ bool TaskPipeScaling::referenceSelected(const SelectionChanges& msg) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(ViewProviderPipe::Section, false);
|
||||
static_cast<PartDesign::Pipe*>(vp->getObject())->Sections.setValues(refs);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ private Q_SLOTS:
|
||||
void onButtonRefRemove(bool checked);
|
||||
void updateUI(int idx);
|
||||
void onBaseButton(bool checked);
|
||||
void onClearButton();
|
||||
void onCurvelinearChanged(bool checked);
|
||||
void onBinormalChanged(double);
|
||||
void onDeleteItem();
|
||||
|
||||
@@ -129,46 +129,71 @@ bool ViewProviderPipe::onDelete(const std::vector<std::string> &s)
|
||||
|
||||
|
||||
|
||||
void ViewProviderPipe::highlightReferences(const bool on, bool auxiliary)
|
||||
void ViewProviderPipe::highlightReferences(ViewProviderPipe::Reference mode, bool on)
|
||||
{
|
||||
PartDesign::Pipe* pcPipe = static_cast<PartDesign::Pipe*>(getObject());
|
||||
Part::Feature* base;
|
||||
if(!auxiliary)
|
||||
base = static_cast<Part::Feature*>(pcPipe->Spine.getValue());
|
||||
else
|
||||
base = static_cast<Part::Feature*>(pcPipe->AuxillerySpine.getValue());
|
||||
|
||||
if (base == NULL) return;
|
||||
switch (mode) {
|
||||
case Spine:
|
||||
highlightReferences(dynamic_cast<Part::Feature*>(pcPipe->Spine.getValue()),
|
||||
pcPipe->Spine.getSubValuesStartsWith("Edge"), on);
|
||||
break;
|
||||
case AuxiliarySpine:
|
||||
highlightReferences(dynamic_cast<Part::Feature*>(pcPipe->AuxillerySpine.getValue()),
|
||||
pcPipe->AuxillerySpine.getSubValuesStartsWith("Edge"), on);
|
||||
break;
|
||||
case Profile:
|
||||
highlightReferences(dynamic_cast<Part::Feature*>(pcPipe->Profile.getValue()),
|
||||
pcPipe->Profile.getSubValuesStartsWith("Edge"), on);
|
||||
break;
|
||||
case Section:
|
||||
{
|
||||
std::vector<App::DocumentObject*> sections = pcPipe->Sections.getValues();
|
||||
for (auto it : sections) {
|
||||
highlightReferences(dynamic_cast<Part::Feature*>(it),
|
||||
std::vector<std::string>(), on);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderPipe::highlightReferences(Part::Feature* base, const std::vector<std::string>& edges, bool on) {
|
||||
|
||||
PartGui::ViewProviderPart* svp = dynamic_cast<PartGui::ViewProviderPart*>(
|
||||
Gui::Application::Instance->getViewProvider(base));
|
||||
if (svp == NULL) return;
|
||||
if (svp == nullptr)
|
||||
return;
|
||||
|
||||
std::vector<std::string> edges;
|
||||
if(!auxiliary)
|
||||
edges = pcPipe->Spine.getSubValuesStartsWith("Edge");
|
||||
else
|
||||
edges = pcPipe->AuxillerySpine.getSubValuesStartsWith("Edge");
|
||||
std::vector<App::Color>& edgeColors = originalLineColors[base->getID()];
|
||||
|
||||
if (on) {
|
||||
if (!edges.empty() && originalLineColors.empty()) {
|
||||
if (edgeColors.empty()) {
|
||||
TopTools_IndexedMapOfShape eMap;
|
||||
TopExp::MapShapes(base->Shape.getValue(), TopAbs_EDGE, eMap);
|
||||
originalLineColors = svp->LineColorArray.getValues();
|
||||
std::vector<App::Color> colors = originalLineColors;
|
||||
edgeColors = svp->LineColorArray.getValues();
|
||||
std::vector<App::Color> colors = edgeColors;
|
||||
colors.resize(eMap.Extent(), svp->LineColor.getValue());
|
||||
|
||||
for (std::string e : edges) {
|
||||
int idx = std::stoi(e.substr(4)) - 1;
|
||||
assert ( idx >= 0 );
|
||||
if ( idx < (ssize_t) colors.size() )
|
||||
colors[idx] = App::Color(1.0,0.0,1.0); // magenta
|
||||
if (!edges.empty()) {
|
||||
for (std::string e : edges) {
|
||||
int idx = std::stoi(e.substr(4)) - 1;
|
||||
assert ( idx >= 0 );
|
||||
if ( idx < (ssize_t) colors.size() )
|
||||
colors[idx] = App::Color(1.0,0.0,1.0); // magenta
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::fill(colors.begin(), colors.end(), App::Color(0.6,0.0,1.0)); // purple
|
||||
}
|
||||
svp->LineColorArray.setValues(colors);
|
||||
}
|
||||
} else {
|
||||
if (!edges.empty() && !originalLineColors.empty()) {
|
||||
svp->LineColorArray.setValues(originalLineColors);
|
||||
originalLineColors.clear();
|
||||
if (!edgeColors.empty()) {
|
||||
svp->LineColorArray.setValues(edgeColors);
|
||||
edgeColors.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#define PARTGUI_ViewProviderPipe_H
|
||||
|
||||
#include "ViewProviderAddSub.h"
|
||||
#include <map>
|
||||
|
||||
namespace PartDesignGui {
|
||||
|
||||
@@ -33,6 +34,13 @@ class PartDesignGuiExport ViewProviderPipe : public ViewProviderAddSub
|
||||
PROPERTY_HEADER(PartDesignGui::ViewProviderPipe);
|
||||
|
||||
public:
|
||||
enum Reference {
|
||||
Spine,
|
||||
AuxiliarySpine,
|
||||
Profile,
|
||||
Section
|
||||
};
|
||||
|
||||
/// constructor
|
||||
ViewProviderPipe();
|
||||
/// destructor
|
||||
@@ -44,7 +52,7 @@ public:
|
||||
bool doubleClicked();
|
||||
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
void highlightReferences(const bool on, bool auxiliary);
|
||||
void highlightReferences(Reference mode, bool on);
|
||||
|
||||
protected:
|
||||
virtual QIcon getIcon(void) const;
|
||||
@@ -53,9 +61,12 @@ protected:
|
||||
|
||||
/// Returns a newly created TaskDlgPipeParameters
|
||||
virtual TaskDlgFeatureParameters *getEditDialog();
|
||||
|
||||
|
||||
private:
|
||||
std::vector<App::Color> originalLineColors;
|
||||
void highlightReferences(Part::Feature*, const std::vector<std::string>&, bool);
|
||||
|
||||
private:
|
||||
std::map<long, std::vector<App::Color>> originalLineColors;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user