better pipe view handling
This commit is contained in:
parent
a727a9b93d
commit
d796ca2bf9
|
@ -166,7 +166,6 @@ protected:
|
|||
/// Applies the menu text, tool and status tip to the passed action object
|
||||
void applyCommandData(const char* context, Action* );
|
||||
const char* keySequenceToAccel(int) const;
|
||||
void adjustCameraPosition();
|
||||
//@}
|
||||
|
||||
public:
|
||||
|
@ -286,6 +285,12 @@ public:
|
|||
const char* getGroupName() const { return sGroup; }
|
||||
void setGroupName(const char*);
|
||||
//@}
|
||||
|
||||
|
||||
/** @name arbitrary helper methods */
|
||||
//@{
|
||||
void adjustCameraPosition();
|
||||
//@}
|
||||
|
||||
protected:
|
||||
enum CmdType {
|
||||
|
|
|
@ -938,7 +938,7 @@ void finishFeature(const Gui::Command* cmd, const std::string& FeatName, const b
|
|||
cmd->doCommand(cmd->Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)",
|
||||
pcActiveBody->getNameInDocument(), FeatName.c_str());
|
||||
|
||||
if (cmd->isActiveObjectValid() && (pcActiveBody != NULL)) {
|
||||
if (pcActiveBody != NULL) {
|
||||
App::DocumentObject* prevSolidFeature = pcActiveBody->getPrevSolidFeature(NULL, false);
|
||||
if (hidePrevSolid && (prevSolidFeature != NULL))
|
||||
cmd->doCommand(cmd->Gui,"Gui.activeDocument().hide(\"%s\")", prevSolidFeature->getNameInDocument());
|
||||
|
@ -1108,9 +1108,7 @@ void prepareSketchBased(Gui::Command* cmd, const std::string& which,
|
|||
|
||||
void finishSketchBased(const Gui::Command* cmd, const Part::Part2DObject* sketch, const std::string& FeatName)
|
||||
{
|
||||
if (cmd->isActiveObjectValid())
|
||||
cmd->doCommand(cmd->Gui,"Gui.activeDocument().hide(\"%s\")", sketch->getNameInDocument());
|
||||
|
||||
cmd->doCommand(cmd->Gui,"Gui.activeDocument().hide(\"%s\")", sketch->getNameInDocument());
|
||||
finishFeature(cmd, FeatName);
|
||||
}
|
||||
|
||||
|
@ -1308,15 +1306,7 @@ void CmdPartDesignAdditivePipe::activated(int iMsg)
|
|||
|
||||
if (FeatName.empty()) return;
|
||||
|
||||
// specific parameters for Pad
|
||||
//Gui::Command::doCommand(Doc,"App.activeDocument().%s.Length = 10.0",FeatName.c_str());
|
||||
App::DocumentObjectGroup* grp = sketch->getGroup();
|
||||
if (grp) {
|
||||
Gui::Command::doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)"
|
||||
,grp->getNameInDocument(),FeatName.c_str());
|
||||
Gui::Command::doCommand(Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)"
|
||||
,grp->getNameInDocument(),sketch->getNameInDocument());
|
||||
}
|
||||
// specific parameters for pipe
|
||||
Gui::Command::updateActive();
|
||||
|
||||
finishSketchBased(cmd, sketch, FeatName);
|
||||
|
@ -1356,15 +1346,7 @@ void CmdPartDesignSubtractivePipe::activated(int iMsg)
|
|||
|
||||
if (FeatName.empty()) return;
|
||||
|
||||
// specific parameters for Pad
|
||||
//Gui::Command::doCommand(Doc,"App.activeDocument().%s.Length = 10.0",FeatName.c_str());
|
||||
App::DocumentObjectGroup* grp = sketch->getGroup();
|
||||
if (grp) {
|
||||
Gui::Command::doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)"
|
||||
,grp->getNameInDocument(),FeatName.c_str());
|
||||
Gui::Command::doCommand(Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)"
|
||||
,grp->getNameInDocument(),sketch->getNameInDocument());
|
||||
}
|
||||
// specific parameters for pipe
|
||||
Gui::Command::updateActive();
|
||||
|
||||
finishSketchBased(cmd, sketch, FeatName);
|
||||
|
|
|
@ -84,9 +84,21 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView,bool newObj, Q
|
|||
this, SLOT(onBaseButton(bool)));
|
||||
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
//add initial values
|
||||
|
||||
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(PipeView->getObject());
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
|
||||
//make sure th euser sees al important things: the base feature to select edges and the
|
||||
//spine/auxillery spine he already selected
|
||||
if(pipe->BaseFeature.getValue())
|
||||
doc->getViewProvider(pipe->BaseFeature.getValue())->show();
|
||||
if(pipe->Spine.getValue()) {
|
||||
auto* svp = doc->getViewProvider(pipe->Spine.getValue());
|
||||
spineShow = svp->isShow();
|
||||
svp->setVisible(true);
|
||||
}
|
||||
|
||||
//add initial values
|
||||
std::vector<std::string> strings = pipe->Spine.getSubValues();
|
||||
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
|
||||
ui->listWidgetReferences->addItem(QString::fromStdString(*i));
|
||||
|
@ -127,7 +139,8 @@ void TaskPipeParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
|||
ui->listWidgetReferences->clear();
|
||||
ui->profileBaseEdit->setText(QString::fromAscii(msg.pObjectName));
|
||||
}
|
||||
//clearButtons(none);
|
||||
clearButtons();
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, false);
|
||||
recomputeFeature();
|
||||
}
|
||||
clearButtons();
|
||||
|
@ -137,6 +150,20 @@ void TaskPipeParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
|||
|
||||
TaskPipeParameters::~TaskPipeParameters()
|
||||
{
|
||||
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject());
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
|
||||
//make sure th euser sees al important things: the base feature to select edges and the
|
||||
//spine/auxillery spine he already selected
|
||||
if(pipe->BaseFeature.getValue())
|
||||
doc->getViewProvider(pipe->BaseFeature.getValue())->hide();
|
||||
if(pipe->Spine.getValue()) {
|
||||
auto* svp = doc->getViewProvider(pipe->Spine.getValue());
|
||||
svp->setVisible(spineShow);
|
||||
spineShow = false;
|
||||
}
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, false);
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
@ -153,7 +180,7 @@ void TaskPipeParameters::onButtonRefAdd(bool checked) {
|
|||
//hideObject();
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = refAdd;
|
||||
//DressUpView->highlightReferences(true);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,7 +191,7 @@ void TaskPipeParameters::onButtonRefRemove(bool checked) {
|
|||
//hideObject();
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = refRemove;
|
||||
//DressUpView->highlightReferences(true);
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,9 +318,19 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, bool newObj
|
|||
this, SLOT(onBinormalChanged(double)));
|
||||
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(PipeView->getObject());
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
|
||||
//make sure th euser sees al important things: the base feature to select edges and the
|
||||
//spine/auxillery spine he already selected
|
||||
if(pipe->AuxillerySpine.getValue()) {
|
||||
auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue());
|
||||
auxSpineShow = svp->isShow();
|
||||
svp->show();
|
||||
}
|
||||
|
||||
//add initial values
|
||||
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(PipeView->getObject());
|
||||
std::vector<std::string> strings = pipe->AuxillerySpine.getSubValues();
|
||||
for (std::vector<std::string>::const_iterator i = strings.begin(); i != strings.end(); i++)
|
||||
ui->listWidgetReferences->addItem(QString::fromStdString(*i));
|
||||
|
@ -307,6 +344,18 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, bool newObj
|
|||
|
||||
TaskPipeOrientation::~TaskPipeOrientation() {
|
||||
|
||||
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject());
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
|
||||
//make sure th euser sees al important things: the base feature to select edges and the
|
||||
//spine/auxillery spine he already selected
|
||||
if(pipe->AuxillerySpine.getValue()) {
|
||||
auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue());
|
||||
svp->setVisible(auxSpineShow);
|
||||
auxSpineShow = false;
|
||||
}
|
||||
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, true);
|
||||
}
|
||||
|
||||
void TaskPipeOrientation::onOrientationChanged(int idx) {
|
||||
|
@ -328,6 +377,7 @@ void TaskPipeOrientation::onButtonRefAdd(bool checked) {
|
|||
if (checked) {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = refAdd;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,6 +386,7 @@ void TaskPipeOrientation::onButtonRefRemove(bool checked) {
|
|||
if (checked) {
|
||||
Gui::Selection().clearSelection();
|
||||
selectionMode = refRemove;
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -394,7 +445,8 @@ void TaskPipeOrientation::onSelectionChanged(const SelectionChanges& msg) {
|
|||
ui->listWidgetReferences->clear();
|
||||
ui->profileBaseEdit->setText(QString::fromAscii(msg.pObjectName));
|
||||
}
|
||||
//clearButtons(none);
|
||||
clearButtons();
|
||||
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, true);
|
||||
recomputeFeature();
|
||||
}
|
||||
clearButtons();
|
||||
|
|
|
@ -78,6 +78,8 @@ private:
|
|||
void clearButtons();
|
||||
void exitSelectionMode();
|
||||
|
||||
bool spineShow = false;
|
||||
|
||||
private:
|
||||
QWidget* proxy;
|
||||
Ui_TaskPipeParameters* ui;
|
||||
|
@ -113,6 +115,8 @@ private:
|
|||
void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
void clearButtons();
|
||||
void exitSelectionMode();
|
||||
|
||||
bool auxSpineShow = false;
|
||||
|
||||
private:
|
||||
QWidget* proxy;
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
|
@ -142,3 +144,48 @@ bool ViewProviderPipe::onDelete(const std::vector<std::string> &s)
|
|||
return ViewProvider::onDelete(s);*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ViewProviderPipe::highlightReferences(const bool on, bool auxillery)
|
||||
{
|
||||
PartDesign::Pipe* pcPipe = static_cast<PartDesign::Pipe*>(getObject());
|
||||
Part::Feature* base;
|
||||
if(!auxillery)
|
||||
base = static_cast<Part::Feature*>(pcPipe->Spine.getValue());
|
||||
else
|
||||
base = static_cast<Part::Feature*>(pcPipe->AuxillerySpine.getValue());
|
||||
|
||||
if (base == NULL) return;
|
||||
PartGui::ViewProviderPart* svp = dynamic_cast<PartGui::ViewProviderPart*>(
|
||||
Gui::Application::Instance->getViewProvider(base));
|
||||
if (svp == NULL) return;
|
||||
|
||||
std::vector<std::string> edges;
|
||||
if(!auxillery)
|
||||
edges = pcPipe->Spine.getSubValuesStartsWith("Edge");
|
||||
else
|
||||
edges = pcPipe->AuxillerySpine.getSubValuesStartsWith("Edge");
|
||||
|
||||
if (on) {
|
||||
if (!edges.empty() && originalLineColors.empty()) {
|
||||
TopTools_IndexedMapOfShape eMap;
|
||||
TopExp::MapShapes(base->Shape.getValue(), TopAbs_EDGE, eMap);
|
||||
originalLineColors = svp->LineColorArray.getValues();
|
||||
std::vector<App::Color> colors = originalLineColors;
|
||||
colors.resize(eMap.Extent(), LineColor.getValue());
|
||||
|
||||
for (std::string e : edges) {
|
||||
int idx = atoi(e.substr(4).c_str()) - 1;
|
||||
if (idx < colors.size())
|
||||
colors[idx] = App::Color(1.0,0.0,1.0); // magenta
|
||||
}
|
||||
svp->LineColorArray.setValues(colors);
|
||||
}
|
||||
} else {
|
||||
if (!edges.empty() && !originalLineColors.empty()) {
|
||||
svp->LineColorArray.setValues(originalLineColors);
|
||||
originalLineColors.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,11 +44,14 @@ public:
|
|||
bool doubleClicked();
|
||||
|
||||
virtual bool onDelete(const std::vector<std::string> &);
|
||||
|
||||
void highlightReferences(const bool on, bool auxillery);
|
||||
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
|
||||
|
||||
private:
|
||||
std::vector<App::Color> originalLineColors;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user