Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
PathGui: speed up path marker display
User SoPointSet instead of SoMarkerSet
  • Loading branch information
realthunder authored and wwmayer committed Mar 22, 2017
1 parent 3f7c4bc commit b091acd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Mod/Path/Gui/ViewProviderPath.cpp
Expand Up @@ -34,7 +34,7 @@
# include <Inventor/nodes/SoCoordinate3.h>
# include <Inventor/nodes/SoDrawStyle.h>
# include <Inventor/nodes/SoIndexedLineSet.h>
# include <Inventor/nodes/SoMarkerSet.h>
# include <Inventor/nodes/SoPointSet.h>
# include <Inventor/nodes/SoShapeHints.h>
# include <Inventor/details/SoLineDetail.h>
# include <Inventor/nodes/SoSwitch.h>
Expand Down Expand Up @@ -90,6 +90,8 @@ ViewProviderPath::ViewProviderPath()
ADD_PROPERTY_TYPE(NormalColor,(lr,lg,lb),"Path",App::Prop_None,"The color of the feed rate moves");
ADD_PROPERTY_TYPE(MarkerColor,(mr,mg,mb),"Path",App::Prop_None,"The color of the markers");
ADD_PROPERTY_TYPE(LineWidth,(lwidth),"Path",App::Prop_None,"The line width of this path");
int markerSize = hGrp->GetInt("DefaultPathMarkerSize",4);
ADD_PROPERTY_TYPE(MarkerSize,(markerSize),"Path",App::Prop_None,"The point size of the markers");
ADD_PROPERTY_TYPE(ShowNodes,(false),"Path",App::Prop_None,"Turns the display of nodes on/off");


Expand All @@ -115,6 +117,11 @@ ViewProviderPath::ViewProviderPath()
pcMarkerCoords = new SoCoordinate3();
pcMarkerCoords->ref();

pcMarkerStyle = new SoDrawStyle();
pcMarkerStyle->ref();
pcMarkerStyle->style = SoDrawStyle::POINTS;
pcMarkerStyle->pointSize = MarkerSize.getValue();

pcDrawStyle = new SoDrawStyle();
pcDrawStyle->ref();
pcDrawStyle->style = SoDrawStyle::LINES;
Expand Down Expand Up @@ -169,6 +176,7 @@ ViewProviderPath::~ViewProviderPath()
pcMarkerCoords->unref();
pcMarkerSwitch->unref();
pcDrawStyle->unref();
pcMarkerStyle->unref();
pcLines->unref();
pcLineColor->unref();
pcMatBind->unref();
Expand All @@ -190,10 +198,10 @@ void ViewProviderPath::attach(App::DocumentObject *pcObj)

// Draw markers
SoSeparator* markersep = new SoSeparator;
SoMarkerSet* marker = new SoMarkerSet;
marker->markerIndex=SoMarkerSet::PLUS_7_7;
SoPointSet* marker = new SoPointSet;
markersep->addChild(pcMarkerColor);
markersep->addChild(pcMarkerCoords);
markersep->addChild(pcMarkerStyle);
markersep->addChild(marker);
pcMarkerSwitch->addChild(markersep);

Expand Down Expand Up @@ -288,6 +296,8 @@ void ViewProviderPath::onChanged(const App::Property* prop)

if (prop == &LineWidth) {
pcDrawStyle->lineWidth = LineWidth.getValue();
} else if (prop == &MarkerSize) {
pcMarkerStyle->pointSize = MarkerSize.getValue();
} else if (prop == &NormalColor) {
if (colorindex.size() > 0 && coordStart>=0 && coordStart<(int)colorindex.size()) {
const App::Color& c = NormalColor.getValue();
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Path/Gui/ViewProviderPath.h
Expand Up @@ -58,6 +58,7 @@ class PathGuiExport ViewProviderPath : public Gui::ViewProviderGeometryObject
App::PropertyInteger LineWidth;
App::PropertyColor NormalColor;
App::PropertyColor MarkerColor;
App::PropertyInteger MarkerSize;
App::PropertyBool ShowNodes;
App::PropertyVector StartPosition;

Expand Down Expand Up @@ -89,6 +90,7 @@ class PathGuiExport ViewProviderPath : public Gui::ViewProviderGeometryObject
SoCoordinate3 * pcLineCoords;
SoCoordinate3 * pcMarkerCoords;
SoDrawStyle * pcDrawStyle;
SoDrawStyle * pcMarkerStyle;
PartGui::SoBrepEdgeSet * pcLines;
SoMaterial * pcLineColor;
SoBaseColor * pcMarkerColor;
Expand Down

0 comments on commit b091acd

Please sign in to comment.