#include <QMap>
#include <AIS_InteractiveContext.hxx>
#include <V3d_View.hxx>
+#include <AIS_Trihedron.hxx>
class QMouseEvent;
class QKeyEvent;
//! Returns AIS_InteractiveContext from current OCCViewer
virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
+ //! Trihedron 3d object shown in the viewer
+ virtual Handle(AIS_Trihedron) trihedron() const = 0;
+
//! Retrurns V3d_Vioewer from current viewer
virtual Handle(V3d_Viewer) v3dViewer() const = 0;
/// \param theTransformation type of transformation (see AppElements_ViewWindow::OperationType)
void viewTransformed(int theTransformation);
+ /// Signal emited on selection changed
+ void trihedronVisibilityChanged(bool theState);
+
protected:
/// A map for storing a scale factors dependent on view object
QMap<Handle(V3d_View), double> myWindowScale;
#include <SUIT_ViewManager.h>
+#include <QtxActionToolMgr.h>
+
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
#include <QMouseEvent>
return Handle(V3d_Viewer)();
}
+//**********************************************
+Handle(AIS_Trihedron) NewGeom_SalomeViewer::trihedron() const
+{
+ return mySelector->viewer()->getTrihedron();
+}
+
//**********************************************
Handle(V3d_View) NewGeom_SalomeViewer::activeView() const
{
OCCViewer_ViewFrame* aView = dynamic_cast<OCCViewer_ViewFrame*>(theView);
OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW);
- if (aWnd)
+ if (aWnd) {
connect(aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)),
this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType)));
+ OCCViewer_ViewPort3d* aViewPort = aWnd->getViewPort();
+ if (aViewPort)
+ connect(aViewPort, SIGNAL(vpMapped(OCCViewer_ViewPort3d*)), this, SLOT(onViewPortMapped()));
+ }
+ reconnectActions(aWnd, true);
myWindowScale.insert (aView->getViewPort()->getView(), aView->getViewPort()->getView()->Camera()->Scale());
emit viewCreated(myView);
+
+
}
//**********************************************
return false;
}
+//**********************************************
+void NewGeom_SalomeViewer::reconnectActions(SUIT_ViewWindow* theWindow,
+ const bool theUseNewGeomSlot)
+{
+ OCCViewer_ViewWindow* aWindow = dynamic_cast<OCCViewer_ViewWindow*>(theWindow);
+ if (!aWindow)
+ return;
+
+ QAction* anAction = theWindow->toolMgr()->action(OCCViewer_ViewWindow::TrihedronShowId);
+ if (!anAction)
+ return;
+
+ if (theUseNewGeomSlot) {
+ anAction->disconnect(anAction, SIGNAL(toggled(bool)),
+ theWindow, SLOT(onTrihedronShow(bool)));
+ anAction->connect(anAction, SIGNAL(toggled(bool)),
+ this, SIGNAL(trihedronVisibilityChanged(bool)));
+ }
+ else {
+ anAction->connect(anAction, SIGNAL(toggled(bool)),
+ theWindow, SLOT(onTrihedronShow(bool)));
+ anAction->disconnect(anAction, SIGNAL(toggled(bool)),
+ this, SIGNAL(trihedronVisibilityChanged(bool)));
+ }
+}
+
//**********************************************
void NewGeom_SalomeViewer::fitAll()
{
emit viewTransformed((int) theType);
}
+//***************************************
+void NewGeom_SalomeViewer::onViewPortMapped()
+{
+ emit trihedronVisibilityChanged(true);
+}
+
//***************************************
void NewGeom_SalomeViewer::activateViewer(bool toActivate)
{
OCCViewer_ViewWindow* aWnd = aOCCView->getView(OCCViewer_ViewFrame::MAIN_VIEW);
connect(aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)),
this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType)));
+ reconnectActions(aWnd, true);
}
} else {
foreach (SUIT_ViewWindow* aView, aViews) {
OCCViewer_ViewWindow* aWnd = aOCCView->getView(OCCViewer_ViewFrame::MAIN_VIEW);
disconnect((OCCViewer_ViewWindow*)aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)),
this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType)));
+ reconnectActions(aWnd, false);
}
}
}
#include <OCCViewer_ViewWindow.h>
#include <V3d_View.hxx>
+#include <AIS_Trihedron.hxx>
class SUIT_ViewWindow;
class QMouseEvent;
//! Retrurns V3d_Vioewer from current viewer
virtual Handle(V3d_Viewer) v3dViewer() const;
+ //! Trihedron 3d object shown in the viewer
+ virtual Handle(AIS_Trihedron) trihedron() const;
+
//! Returns Vsd_View object from currently active view window
virtual Handle(V3d_View) activeView() const;
//! Enable or disable draw mode in the viewer
virtual bool enableDrawMode(bool isEnabled);
+ //! For some signals it disconnects the window from usual signal and connect it to the module ones
+ void reconnectActions(SUIT_ViewWindow* theWindow, const bool theUseNewGeomSlot);
+
//! Perfroms the fit all for the active view
virtual void fitAll();
void onSelectionChanged();
void onViewTransformed(OCCViewer_ViewWindow::OperationType);
+ /// Emit signal about trihedron visiblity change because SALOME sets the trihedron visible by this signal.
+ /// It is necessary to activate the viewer trihedron in the current selection mode
+ void onViewPortMapped();
+
private:
NewGeom_OCCSelector* mySelector;
NewGeom_SalomeView* myView;
#include <AIS_Shape.hxx>
#include <AIS_Dimension.hxx>
#include <AIS_Trihedron.hxx>
+#include <AIS_Axis.hxx>
+#include <AIS_Plane.hxx>
+#include <AIS_Point.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <SelectMgr_ListOfFilter.hxx>
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
Handle(AIS_InteractiveObject) aTrihedron;
if (isTrihedronActive()) {
aTrihedron = getTrihedron();
- if (!aTrihedron.IsNull())
+ if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron))
aPrsList.Append(aTrihedron);
}
if (aPrsList.Extent() == 0)
return aErased;
}
-#define DEACTVATE_COMP(TheComp) \
- if (!TheComp.IsNull()) \
- aContext->Deactivate(TheComp);
+void deactivateObject(Handle(AIS_InteractiveContext) theContext,
+ Handle(AIS_InteractiveObject) theObject,
+ const bool theClear = true)
+{
+ if (!theObject.IsNull()) {
+ theContext->Deactivate(theObject);
+ //if (theClear) {
+ //theObject->ClearSelected();
+ // theContext->LocalContext()->ClearOutdatedSelection(theObject, true);
+ //}
+ }
+}
-void XGUI_Displayer::deactivateTrihedron() const
+void XGUI_Displayer::deactivateTrihedron(const bool theUpdateViewer) const
{
Handle(AIS_InteractiveObject) aTrihedron = getTrihedron();
- if (!aTrihedron.IsNull()) {
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron)) {
Handle(AIS_Trihedron) aTrie = Handle(AIS_Trihedron)::DownCast(aTrihedron);
- Handle(AIS_InteractiveContext) aContext = AISContext();
- aContext->Deactivate(aTrie);
- DEACTVATE_COMP(aTrie->XAxis());
- DEACTVATE_COMP(aTrie->YAxis());
- DEACTVATE_COMP(aTrie->Axis());
- DEACTVATE_COMP(aTrie->Position());
- DEACTVATE_COMP(aTrie->XYPlane());
- DEACTVATE_COMP(aTrie->XZPlane());
- DEACTVATE_COMP(aTrie->YZPlane());
+ deactivateObject(aContext, aTrie);
+
+ /// #1136 hidden axis are selected in sketch
+ /// workaround for Cascade: there is a crash in AIS_LocalContext::ClearOutdatedSelection
+ /// for Position AIS object in SelectionModes.
+ deactivateObject(aContext, aTrie->XAxis());
+ deactivateObject(aContext, aTrie->YAxis());
+ deactivateObject(aContext, aTrie->Axis());
+ deactivateObject(aContext, aTrie->Position());
+
+ deactivateObject(aContext, aTrie->XYPlane());
+ deactivateObject(aContext, aTrie->XZPlane());
+ deactivateObject(aContext, aTrie->YZPlane());
+
+ if (theUpdateViewer)
+ updateViewer();
}
}
Handle(AIS_InteractiveObject) XGUI_Displayer::getTrihedron() const
{
- Handle(AIS_InteractiveContext) aContext = AISContext();
- if (!aContext.IsNull()) {
- AIS_ListOfInteractive aList;
- aContext->DisplayedObjects(aList, true);
- AIS_ListIteratorOfListOfInteractive aIt;
- for (aIt.Initialize(aList); aIt.More(); aIt.Next()) {
- Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(aIt.Value());
- if (!aTrihedron.IsNull()) {
- return aTrihedron;
- }
- }
- }
- return Handle(AIS_InteractiveObject)();
+ return myWorkshop->viewer()->trihedron();
}
void XGUI_Displayer::openLocalContext()
if (!aContext.IsNull() && !aContext->HasOpenedContext()) {
aContext->OpenLocalContext();
if (!isTrihedronActive())
- deactivateTrihedron();
+ deactivateTrihedron(true);
aContext->DefaultDrawer()->VIsoAspect()->SetNumber(0);
aContext->DefaultDrawer()->UIsoAspect()->SetNumber(0);
}
{
myIsTrihedronActive = theIsActive;
if (!myIsTrihedronActive) {
- deactivateTrihedron();
+ deactivateTrihedron(true);
}
}
+
+void XGUI_Displayer::displayTrihedron(bool theToDisplay) const
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
+
+ Handle(AIS_Trihedron) aTrihedron = myWorkshop->viewer()->trihedron();
+
+ if (theToDisplay) {
+ if (!aContext->IsDisplayed(aTrihedron))
+ aContext->Display(aTrihedron,
+ 0 /*wireframe*/,
+ -1 /* selection mode */,
+ Standard_True /* update viewer*/,
+ Standard_False /* allow decomposition */,
+ AIS_DS_Displayed /* xdisplay status */);
+
+ if (!isTrihedronActive())
+ deactivateTrihedron(false);
+ else
+ activate(aTrihedron, myActiveSelectionModes, false);
+ } else {
+ deactivateTrihedron(false);
+ //aContext->LocalContext()->ClearOutdatedSelection(aTrihedron, true);
+ // the selection from the previous activation modes should be cleared manually (#26172)
+
+ aContext->Erase(aTrihedron);
+ }
+
+ updateViewer();
+}
/// Returns Trihedron object if it is displayed
Handle(AIS_InteractiveObject) getTrihedron() const;
- // Set trihedron active (used in selection) or non active
+ /// Set trihedron active (used in selection) or non active
void activateTrihedron(bool theIsActive);
+ /// Displays/erases thrihedron in current modes. It will be activated or deactivated
+ /// depending on the trihedron visible state and displayer active trihedron state
+ void displayTrihedron(bool theToDisplay) const;
+
+ /// Returns true if the trihedron should be activated in current selection modes
bool isTrihedronActive() const { return myIsTrihedronActive; }
/// Converts shape type (TopAbs_ShapeEnum) to selection mode
void deactivate(ObjectPtr theObject, const bool theUpdateViewer);
/// Find a trihedron in a list of displayed presentations and deactivate it.
- void deactivateTrihedron() const;
+ /// \param theUpdateViewer an update viewer flag
+ void deactivateTrihedron(const bool theUpdateViewer) const;
/// Opens local context. Does nothing if it is already opened.
void openLocalContext();
{
}
+void XGUI_ViewerProxy::connectViewProxy()
+{
+#ifdef HAVE_SALOME
+ connect(myWorkshop->salomeConnector()->viewer(), SIGNAL(trihedronVisibilityChanged(bool)),
+ SIGNAL(trihedronVisibilityChanged(bool)));
+#else
+ connect(myWorkshop->mainWindow()->viewer(), SIGNAL(trihedronVisibilityChanged(bool)),
+ SLOT(trihedronVisibilityChanged(bool)));
+#endif
+}
+
Handle(AIS_InteractiveContext) XGUI_ViewerProxy::AISContext() const
{
#ifdef HAVE_SALOME
#endif
}
+Handle(AIS_Trihedron) XGUI_ViewerProxy::trihedron() const
+{
+#ifdef HAVE_SALOME
+ return myWorkshop->salomeConnector()->viewer()->trihedron();
+#else
+ return myWorkshop->mainWindow()->viewer()->trihedron();
+#endif
+}
+
Handle(V3d_Viewer) XGUI_ViewerProxy::v3dViewer() const
{
#ifdef HAVE_SALOME
#include "XGUI.h"
#include <ModuleBase_IViewer.h>
+#include <AIS_Trihedron.hxx>
+
#ifndef HAVE_SALOME
#include <AppElements_ViewWindow.h>
#endif
/// \param theParent a parent object
XGUI_ViewerProxy(XGUI_Workshop* theParent);
+ /// Connects some signals to the viewer from the module connector
+ void connectViewProxy();
+
//! Returns AIS_InteractiveContext from current OCCViewer
virtual Handle(AIS_InteractiveContext) AISContext() const;
+ //! Trihedron 3d object shown in the viewer
+ virtual Handle(AIS_Trihedron) trihedron() const;
+
//! Retrurns V3d_Vioewer from current viewer
virtual Handle(V3d_Viewer) v3dViewer() const;
/// Emits by mouse leaving of the view port
void leaveViewPort();
+ /// Signal emited on selection changed
+ void trihedronVisibilityChanged(bool theState);
+
protected:
/// processes the application signals to catch the mouse leaving state of the main window
/// \param theObject
onNew();
+ myViewerProxy->connectViewProxy();
+ connect(myViewerProxy, SIGNAL(trihedronVisibilityChanged(bool)),
+ SLOT(onTrihedronVisibilityChanged(bool)));
+
emit applicationStarted();
}
}
#endif
+//******************************************************
+void XGUI_Workshop::onTrihedronVisibilityChanged(bool theState)
+{
+ XGUI_Displayer* aDisplayer = displayer();
+ if (aDisplayer)
+ aDisplayer->displayTrihedron(theState);
+}
+
//******************************************************
bool XGUI_Workshop::onSave()
{
void onPreferences();
#endif
+ /// Activates/deactivates the trihedron in the viewer AIS context
+ void onTrihedronVisibilityChanged(bool theState);
+
protected:
/// Sets the granted operations for the parameter operation. Firstly, it finds the nested features
/// and set them into the operation. Secondly, it asks the module about ids of granted operations.