Skip to content

Commit

Permalink
+ add toggle action to context-menu of spline view provider
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Oct 31, 2015
1 parent ff320f4 commit 71be79e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/Mod/Part/Gui/ViewProviderSpline.cpp
Expand Up @@ -20,7 +20,7 @@
* *
***************************************************************************/


#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAdaptor_Curve.hxx>
Expand All @@ -42,11 +42,16 @@
# include <Inventor/nodes/SoCoordinate3.h>
# include <Inventor/nodes/SoSeparator.h>
# include <Inventor/nodes/SoSwitch.h>
# include <QAction>
# include <QMenu>
#endif

#include <boost/bind.hpp>


#include <App/PropertyStandard.h>
#include <Mod/Part/App/PartFeature.h>
#include <Gui/ActionFunction.h>
#include "SoFCShapeObject.h"
#include "ViewProviderSpline.h"

Expand All @@ -66,6 +71,23 @@ ViewProviderSpline::~ViewProviderSpline()
{
}

void ViewProviderSpline::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
ViewProviderPartExt::setupContextMenu(menu, receiver, member);

// toggle command to display components
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
QAction* act = menu->addAction(QObject::tr("Show control points"));
act->setCheckable(true);
act->setChecked(ControlPoints.getValue());
func->toggle(act, boost::bind(&ViewProviderSpline::toggleControlPoints, this, _1));
}

void ViewProviderSpline::toggleControlPoints(bool on)
{
ControlPoints.setValue(on);
}

void ViewProviderSpline::updateData(const App::Property* prop)
{
ViewProviderPartExt::updateData(prop);
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Part/Gui/ViewProviderSpline.h
Expand Up @@ -44,9 +44,11 @@ class PartGuiExport ViewProviderSpline : public ViewProviderPartExt
App::PropertyBool ControlPoints;

void updateData(const App::Property* prop);
void setupContextMenu(QMenu* menu, QObject* receiver, const char* member);

protected:
void onChanged(const App::Property* prop);
void toggleControlPoints(bool);
void showControlPoints(bool, const App::Property* prop);
void showControlPointsOfEdge(const TopoDS_Edge&);
void showControlPointsOfFace(const TopoDS_Face&);
Expand Down

0 comments on commit 71be79e

Please sign in to comment.