From: vsv Date: Tue, 10 Jun 2014 14:24:36 +0000 (+0400) Subject: Provide connection of new features in SALOME module X-Git-Tag: V_0.4.4~292^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2b4f4bf278c841500eb29bb5d204690427b0d56b;p=modules%2Fshaper.git Provide connection of new features in SALOME module --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp index b910d1753..08f39e8c0 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp @@ -29,6 +29,12 @@ #include #include + +#ifndef DBL_MAX +#define DBL_MAX 1.7976931348623158e+308 +#endif + + const double tolerance = Precision::Confusion(); /// \brief Search first vertex - the vertex with lowest x coordinate, which is used in 2 edges at least diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index 0824da5b4..9c02822e8 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -20,6 +20,10 @@ #include #include +#ifndef DBL_MAX +#define DBL_MAX 1.7976931348623158e+308 +#endif + ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData) : ModuleBase_ModelWidget(theParent, theData) diff --git a/src/NewGeom/CMakeLists.txt b/src/NewGeom/CMakeLists.txt index 27b7c58f4..e0d4ba730 100644 --- a/src/NewGeom/CMakeLists.txt +++ b/src/NewGeom/CMakeLists.txt @@ -35,6 +35,7 @@ SET(PROJECT_LIBRARIES ${LightApp} ${CAM} ${OCCViewer} + ${qtx} ) ADD_DEFINITIONS( -DNewGeom_EXPORTS ${CAS_DEFINITIONS} ) diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index 549276279..fc07f5d55 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -16,6 +17,7 @@ #include #include +#include #include #include @@ -72,7 +74,6 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy) if (isDone) { setMenuShown( true ); setToolShown( true ); - myWorkshop->propertyPanel()->hide(); if (!mySelector) { ViewManagerList OCCViewManagers; @@ -81,10 +82,22 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy) mySelector = createSelector(OCCViewManagers.first()); } } + myWorkshop->propertyPanel()->hide(); + QtxPopupMgr* aMgr = popupMgr(); // Create popup manager + action(myEraseAll)->setEnabled(false); } return isDone; } +//****************************************************** +bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy) +{ + setMenuShown( false ); + setToolShown( false ); + //myWorkshop->contextMenuMgr()->disconnectViewer(); + return LightApp_Module::deactivateModule(theStudy); +} + //****************************************************** void NewGeom_Module::onViewManagerAdded( SUIT_ViewManager* theMgr ) { @@ -112,14 +125,6 @@ NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr) return 0; } -//****************************************************** -bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy) -{ - setMenuShown( false ); - setToolShown( false ); - return LightApp_Module::deactivateModule(theStudy); -} - //****************************************************** CAM_DataModel* NewGeom_Module::createDataModel() { @@ -242,3 +247,10 @@ void NewGeom_Module::selectionChanged() LightApp_Module::selectionChanged(); myWorkshop->salomeViewerSelectionChanged(); } + +//****************************************************** +void NewGeom_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle) +{ + myWorkshop->contextMenuMgr()->addViewerItems(theMenu); + LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle); +} \ No newline at end of file diff --git a/src/NewGeom/NewGeom_Module.h b/src/NewGeom/NewGeom_Module.h index ef0b4eb4a..78cc95fba 100644 --- a/src/NewGeom/NewGeom_Module.h +++ b/src/NewGeom/NewGeom_Module.h @@ -74,6 +74,8 @@ public: //! Returns list of Ids of defined actions (just by NewGeom module) virtual QStringList commandIdList() const; + virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle); + public slots: virtual bool activateModule( SUIT_Study* theStudy); virtual bool deactivateModule( SUIT_Study* theStudy); diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index 5fe0be383..99a99d328 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -4,9 +4,14 @@ #include #include +#include #include +#include +#include + + NewGeom_SalomeViewer::NewGeom_SalomeViewer(QObject* theParent) : XGUI_SalomeViewer(theParent), mySelector(0) { @@ -70,6 +75,9 @@ void NewGeom_SalomeViewer::setSelector(NewGeom_OCCSelector* theSel) this, SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*))); connect(aMgr, SIGNAL(keyRelease(SUIT_ViewWindow*, QKeyEvent*)), this, SLOT(onKeyRelease(SUIT_ViewWindow*, QKeyEvent*))); + + connect(aViewer, SIGNAL(selectionChanged()), + this, SIGNAL(selectionChanged())); } //********************************************** @@ -82,6 +90,11 @@ void NewGeom_SalomeViewer::onMousePress(SUIT_ViewWindow*, QMouseEvent* theEvent) void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow*, QMouseEvent* theEvent) { emit mouseRelease(theEvent); + //if ((theEvent->button() == Qt::RightButton) && + // (theEvent->modifiers() == Qt::NoModifier)) { + // QContextMenuEvent aEvent(QContextMenuEvent::Mouse, theEvent->pos(), theEvent->globalPos()); + // emit contextMenuRequested(&aEvent); + //} } //********************************************** @@ -131,3 +144,13 @@ bool NewGeom_SalomeViewer::isMultiSelectionEnabled() const { return mySelector->viewer()->isMultiSelectionEnabled(); } + +//********************************************** +void NewGeom_SalomeViewer::fitAll() +{ + SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager(); + OCCViewer_ViewFrame* aVFrame = dynamic_cast(aMgr->getActiveView()); + if (aVFrame) { + aVFrame->onFitAll(); + } +} \ No newline at end of file diff --git a/src/NewGeom/NewGeom_SalomeViewer.h b/src/NewGeom/NewGeom_SalomeViewer.h index a665af3b7..8217e0146 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.h +++ b/src/NewGeom/NewGeom_SalomeViewer.h @@ -40,6 +40,9 @@ public: //! Returns true if multiselection is enabled virtual bool isMultiSelectionEnabled() const; + //! Perfroms the fit all for the active view + virtual void fitAll(); + void setSelector(NewGeom_OCCSelector* theSel); NewGeom_OCCSelector* selector() const { return mySelector; } diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index a02f1d2dc..efe3c9c12 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -5,7 +5,7 @@ #include "XGUI_SelectionMgr.h" #include "XGUI_Displayer.h" #include "XGUI_MainWindow.h" -#include "XGUI_Viewer.h" +#include "XGUI_ViewerProxy.h" #include "PartSetPlugin_Part.h" @@ -84,7 +84,7 @@ void XGUI_ContextMenuMgr::onContextMenuRequest(QContextMenuEvent* theEvent) QMenu* aMenu = 0; if (sender() == myWorkshop->objectBrowser()) aMenu = objectBrowserMenu(); - else if (sender() == myWorkshop->mainWindow()->viewer()) { + else if (sender() == myWorkshop->viewer()) { aMenu = viewerMenu(); } @@ -141,19 +141,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const QMenu* XGUI_ContextMenuMgr::viewerMenu() const { QMenu* aMenu = new QMenu(); - XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); - QFeatureList aFeatures = aSelMgr->selectedFeatures(); - if (aFeatures.size() > 0) { - if (aFeatures.size() > 0) - aMenu->addAction(action("EDIT_CMD")); - aMenu->addAction(action("HIDE_CMD")); - aMenu->addAction(action("DELETE_CMD")); - } - QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea(); - if (aMDI->actions().size() > 0) { - QMenu* aSubMenu = aMenu->addMenu(tr("Windows")); - aSubMenu->addActions(aMDI->actions()); - } + addViewerItems(aMenu); if (aMenu->actions().size() > 0) { return aMenu; } @@ -161,6 +149,35 @@ QMenu* XGUI_ContextMenuMgr::viewerMenu() const return 0; } +void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const +{ + XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); + QFeatureList aFeatures = aSelMgr->selectedFeatures(); + if (aFeatures.size() > 0) { + if (aFeatures.size() == 1) + theMenu->addAction(action("EDIT_CMD")); + bool isVisible = false; + foreach(FeaturePtr aFeature, aFeatures) { + if (myWorkshop->displayer()->isVisible(aFeature)) { + isVisible = true; + break; + } + } + if (isVisible) + theMenu->addAction(action("HIDE_CMD")); + else + theMenu->addAction(action("SHOW_CMD")); + theMenu->addAction(action("DELETE_CMD")); + } + if (!myWorkshop->isSalomeMode()) { + QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea(); + if (aMDI->actions().size() > 0) { + QMenu* aSubMenu = theMenu->addMenu(tr("Windows")); + aSubMenu->addActions(aMDI->actions()); + } + } +} + void XGUI_ContextMenuMgr::connectObjectBrowser() const { connect(myWorkshop->objectBrowser(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), @@ -169,7 +186,7 @@ void XGUI_ContextMenuMgr::connectObjectBrowser() const void XGUI_ContextMenuMgr::connectViewer() const { - // TODO: Adapt to SALOME mode - connect(myWorkshop->mainWindow()->viewer(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), + connect(myWorkshop->viewer(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, SLOT(onContextMenuRequest(QContextMenuEvent*))); } + diff --git a/src/XGUI/XGUI_ContextMenuMgr.h b/src/XGUI/XGUI_ContextMenuMgr.h index a8255ff0c..a48bd79c7 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.h +++ b/src/XGUI/XGUI_ContextMenuMgr.h @@ -12,6 +12,9 @@ class QAction; class QContextMenuEvent; class QMenu; +/** +* A claas wihich provides manement of context menu +*/ class XGUI_EXPORT XGUI_ContextMenuMgr: public QObject { Q_OBJECT @@ -19,20 +22,27 @@ public: XGUI_ContextMenuMgr(XGUI_Workshop* theParent); virtual ~XGUI_ContextMenuMgr(); + /// Create all actions for context menus. It is called on creation of application void createActions(); - void addAction(const QString& theId, QAction* theAction); - + /// Returns action according to the given ID QAction* action(const QString& theId) const; + /// Returns list of registered actions Ids QStringList actionIds() const; + /// update state of internal commands void updateCommandsStatus(); + /// Connect to object browser from workshop. Has to called at creation of viewer. void connectObjectBrowser() const; + /// Connect to viewer from workshop. Has to called at creation of viewer. void connectViewer() const; + /// Add menu atems for viewer into the given menu (used in SALOME mode) + void addViewerItems(QMenu* theMenu) const; + signals: void actionTriggered(const QString& theId, bool isChecked); @@ -42,6 +52,14 @@ private slots: void onContextMenuRequest(QContextMenuEvent* theEvent); private: + /** + * Add action + * \param theId - string ID of the item + * \param theAction - action to add + */ + void addAction(const QString& theId, QAction* theAction); + + QMenu* objectBrowserMenu() const; QMenu* viewerMenu() const; diff --git a/src/XGUI/XGUI_SalomeViewer.h b/src/XGUI/XGUI_SalomeViewer.h index a07008bfc..d35937900 100644 --- a/src/XGUI/XGUI_SalomeViewer.h +++ b/src/XGUI/XGUI_SalomeViewer.h @@ -9,6 +9,7 @@ class QMouseEvent; class QKeyEvent; +class QContextMenuEvent; /** * A Base object for definition of connector object to @@ -58,6 +59,7 @@ signals: void activated(); void selectionChanged(); + void contextMenuRequested(QContextMenuEvent*); }; #endif \ No newline at end of file diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index b5c3706da..19453efdb 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -97,6 +97,9 @@ void XGUI_ViewerProxy::connectToViewer() this, SIGNAL(keyRelease(QKeyEvent*))); connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); + connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), + this, SIGNAL(contextMenuRequested(QContextMenuEvent*))); + } else { XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); @@ -125,6 +128,8 @@ void XGUI_ViewerProxy::connectToViewer() this, SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*))); connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); + connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), + this, SIGNAL(contextMenuRequested(QContextMenuEvent*))); } } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 3ff0a0046..c4c6ac939 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -450,10 +450,10 @@ void XGUI_Workshop::onNew() if (!isSalomeMode()) { myMainWindow->showPythonConsole(); QMdiSubWindow* aWnd = myMainWindow->viewer()->createView(); - myContextMenuMgr->connectViewer(); aWnd->showMaximized(); updateCommandStatus(); } + myContextMenuMgr->connectViewer(); QApplication::restoreOverrideCursor(); }