PD: highlight current profile and sections of a loft when selecting a new profile/section
This commit is contained in:
@@ -26,14 +26,12 @@
|
||||
#ifndef _PreComp_
|
||||
# include <QMessageBox>
|
||||
# include <QMenu>
|
||||
# include <TopExp.hxx>
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
#endif
|
||||
|
||||
#include "Utils.h"
|
||||
#include "ViewProviderLoft.h"
|
||||
//#include "TaskLoftParameters.h"
|
||||
#include "TaskLoftParameters.h"
|
||||
#include "ReferenceHighlighter.h"
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include <Mod/PartDesign/App/FeatureLoft.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
@@ -115,47 +113,63 @@ bool ViewProviderLoft::onDelete(const std::vector<std::string> & /*s*/)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderLoft::highlightReferences(const bool /*on*/, bool /*auxiliary*/)
|
||||
{/*
|
||||
void ViewProviderLoft::highlightProfile(bool on)
|
||||
{
|
||||
PartDesign::Loft* pcLoft = static_cast<PartDesign::Loft*>(getObject());
|
||||
Part::Feature* base;
|
||||
if(!auxiliary)
|
||||
base = static_cast<Part::Feature*>(pcLoft->Spine.getValue());
|
||||
else
|
||||
base = static_cast<Part::Feature*>(pcLoft->AuxillerySpine.getValue());
|
||||
highlightReferences(dynamic_cast<Part::Feature*>(pcLoft->Profile.getValue()),
|
||||
pcLoft->Profile.getSubValues(), on);
|
||||
}
|
||||
|
||||
if (base == NULL) return;
|
||||
void ViewProviderLoft::highlightSection(bool on)
|
||||
{
|
||||
PartDesign::Loft* pcLoft = static_cast<PartDesign::Loft*>(getObject());
|
||||
auto sections = pcLoft->Sections.getSubListValues();
|
||||
for (auto it : sections) {
|
||||
if (it.second.size() == 1 && it.second[0].empty())
|
||||
it.second.clear();
|
||||
highlightReferences(dynamic_cast<Part::Feature*>(it.first), it.second, on);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderLoft::highlightReferences(ViewProviderLoft::Reference mode, bool on)
|
||||
{
|
||||
switch (mode) {
|
||||
case Profile:
|
||||
highlightProfile(on);
|
||||
break;
|
||||
case Section:
|
||||
highlightSection(on);
|
||||
break;
|
||||
case Both:
|
||||
highlightProfile(on);
|
||||
highlightSection(on);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderLoft::highlightReferences(Part::Feature* base, const std::vector<std::string>& elements, 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 = pcLoft->Spine.getSubValuesStartsWith("Edge");
|
||||
else
|
||||
edges = pcLoft->AuxillerySpine.getSubValuesStartsWith("Edge");
|
||||
std::vector<App::Color>& edgeColors = originalLineColors[base->getID()];
|
||||
|
||||
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(), svp->LineColor.getValue());
|
||||
edgeColors = svp->LineColorArray.getValues();
|
||||
std::vector<App::Color> colors = edgeColors;
|
||||
|
||||
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();
|
||||
}
|
||||
}*/
|
||||
ReferenceHighlighter highlighter(base->Shape.getValue(), svp->LineColor.getValue());
|
||||
highlighter.getEdgeColors(elements, colors);
|
||||
svp->LineColorArray.setValues(colors);
|
||||
}
|
||||
else if (!edgeColors.empty()) {
|
||||
svp->LineColorArray.setValues(edgeColors);
|
||||
edgeColors.clear();
|
||||
}
|
||||
}
|
||||
|
||||
QIcon ViewProviderLoft::getIcon(void) const {
|
||||
|
||||
Reference in New Issue
Block a user