diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index ee441c695..31ec53ceb 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -1468,6 +1468,9 @@ bool StdCmdToggleNavigation::isActive(void) return false; } + + +#if 0 // old Axis command // Command to show/hide axis cross class StdCmdAxisCross : public Gui::Command { @@ -1549,6 +1552,50 @@ protected: } } }; +#else +//=========================================================================== +// Std_ViewExample1 +//=========================================================================== +DEF_STD_CMD_A(StdCmdAxisCross); + +StdCmdAxisCross::StdCmdAxisCross() + : Command("Std_AxisCross") +{ + sGroup = QT_TR_NOOP("Standard-View"); + sMenuText = QT_TR_NOOP("Toggle axis cross"); + sToolTipText = QT_TR_NOOP("Toggle axis cross"); + sStatusTip = QT_TR_NOOP("Toggle axis cross"); + sWhatsThis = "Std_AxisCross"; +} + +void StdCmdAxisCross::activated(int iMsg) +{ + Gui::View3DInventor* view = qobject_cast(Gui::getMainWindow()->activeWindow()); + if (view ){ + if(view->getViewer()->hasAxisCross()== false) + doCommand(Command::Gui,"Gui.ActiveDocument.ActiveView.setAxisCross(True)"); + else + doCommand(Command::Gui,"Gui.ActiveDocument.ActiveView.setAxisCross(False)"); + } +} + +bool StdCmdAxisCross::isActive(void) +{ + Gui::View3DInventor* view = qobject_cast(Gui::getMainWindow()->activeWindow()); + if (view && view->getViewer()->hasAxisCross()) { + if (!_pcAction->isChecked()) + _pcAction->setChecked(true); + } + else { + if (_pcAction->isChecked()) + _pcAction->setChecked(false); + } + if (view ) return true; + return false; + +} + +#endif //=========================================================================== // Std_ViewExample1 @@ -1556,7 +1603,7 @@ protected: DEF_STD_CMD_A(StdCmdViewExample1); StdCmdViewExample1::StdCmdViewExample1() - : Command("Std_ViewExample1") + : Command("Std_AxisCross") { sGroup = QT_TR_NOOP("Standard-View"); sMenuText = QT_TR_NOOP("Inventor example #1"); diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 80796f003..05cd13e26 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -100,6 +100,8 @@ #include "SoFCUnifiedSelection.h" #include "SoFCInteractiveElement.h" #include "SoFCBoundingBox.h" +#include "SoAxisCrossKit.h" + #include "Selection.h" #include "SoFCSelectionAction.h" #include "SoFCVectorizeU3DAction.h" @@ -140,7 +142,7 @@ SOQT_OBJECT_ABSTRACT_SOURCE(View3DInventorViewer); View3DInventorViewer::View3DInventorViewer (QWidget *parent, const char *name, SbBool embed, Type type, SbBool build) : inherited (parent, name, embed, type, build), editViewProvider(0), navigation(0), - framebuffer(0), editing(FALSE), redirected(FALSE), allowredir(FALSE) + framebuffer(0), editing(FALSE), redirected(FALSE), allowredir(FALSE),axisCross(0),axisGroup(0) { Gui::Selection().Attach(this); @@ -457,6 +459,38 @@ void View3DInventorViewer::setEnabledFPSCounter(bool on) #endif } +void View3DInventorViewer::setAxisCross(bool b) +{ + SoNode* scene = getSceneGraph(); + SoSeparator* sep = static_cast(scene); + + if(b){ + if(!axisGroup){ + axisCross = new Gui::SoShapeScale; + Gui::SoAxisCrossKit* axisKit = new Gui::SoAxisCrossKit(); + axisKit->set("xAxis.appearance.drawStyle", "lineWidth 2"); + axisKit->set("yAxis.appearance.drawStyle", "lineWidth 2"); + axisKit->set("zAxis.appearance.drawStyle", "lineWidth 2"); + axisCross->setPart("shape", axisKit); + axisCross->scaleFactor = 1.0f; + axisGroup = new SoSkipBoundingGroup; + axisGroup->addChild(axisCross); + + sep->addChild(axisGroup); + } + }else{ + if(axisGroup){ + sep->removeChild(axisGroup); + axisGroup = 0; + } + } +} +bool View3DInventorViewer::hasAxisCross(void) +{ + return axisGroup; +} + + void View3DInventorViewer::setNavigationType(Base::Type t) { if (t.isBad()) diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index 44c474761..f78081a79 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -48,6 +48,7 @@ class SbBox2s; class SoVectorizeAction; class QGLFramebufferObject; class QImage; +class SoGroup; namespace Gui { @@ -58,6 +59,7 @@ class SoFCUnifiedSelection; class Document; class SoFCUnifiedSelection; class GLGraphicsItem; +class SoShapeScale; /** The Inventor viewer * @@ -272,6 +274,10 @@ public: const SbColor& midColor); void setEnabledFPSCounter(bool b); void setNavigationType(Base::Type); + + void setAxisCross(bool b); + bool hasAxisCross(void); + NavigationStyle* navigationStyle() const; void setDocument(Gui::Document *pcDocument); @@ -304,6 +310,7 @@ private: static void drawArrow(void); void setCursorRepresentation(int mode); + private: std::set _ViewProviderSet; std::map _ViewProviderMap; @@ -321,8 +328,13 @@ private: SoFCUnifiedSelection* selectionRoot; QGLFramebufferObject* framebuffer; + // small axis cross in the corner SbBool axiscrossEnabled; int axiscrossSize; + // big one in the middle + SoShapeScale* axisCross; + SoGroup* axisGroup; + SbBool editing; QCursor editCursor; diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 9f008bacd..c4f6e25f0 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -140,6 +140,9 @@ void View3DInventorPy::init_type() add_varargs_method("listNavigationTypes",&View3DInventorPy::listNavigationTypes,"listNavigationTypes()"); add_varargs_method("getNavigationType",&View3DInventorPy::getNavigationType,"getNavigationType()"); add_varargs_method("setNavigationType",&View3DInventorPy::setNavigationType,"setNavigationType()"); + add_varargs_method("setAxisCross",&View3DInventorPy::setAxisCross,"switch the big axis-cross on and off"); + add_varargs_method("hasAxisCross",&View3DInventorPy::hasAxisCross,"check if the big axis-cross is on or off()"); + } View3DInventorPy::View3DInventorPy(View3DInventor *vi) @@ -2047,3 +2050,20 @@ Py::Object View3DInventorPy::removeEventCallbackPivy(const Py::Tuple& args) throw; } } + +Py::Object View3DInventorPy::setAxisCross(const Py::Tuple& args) +{ + int ok; + if (!PyArg_ParseTuple(args.ptr(), "i", &ok)) + throw Py::Exception(); + _view->getViewer()->setAxisCross(ok!=0); + return Py::None(); +} + +Py::Object View3DInventorPy::hasAxisCross(const Py::Tuple& args) +{ + if (!PyArg_ParseTuple(args.ptr(), "")) + throw Py::Exception(); + SbBool ok = _view->getViewer()->hasAxisCross(); + return Py::Boolean(ok ? true : false); +} \ No newline at end of file diff --git a/src/Gui/View3DPy.h b/src/Gui/View3DPy.h index 5b0920f59..547415121 100644 --- a/src/Gui/View3DPy.h +++ b/src/Gui/View3DPy.h @@ -93,6 +93,8 @@ public: Py::Object listNavigationTypes(const Py::Tuple&); Py::Object getNavigationType(const Py::Tuple&); Py::Object setNavigationType(const Py::Tuple&); + Py::Object setAxisCross(const Py::Tuple&); + Py::Object hasAxisCross(const Py::Tuple&); private: static void eventCallback(void * ud, SoEventCallback * n);