#include <TopoDS_Wire.hxx>
#include <Precision.hxx>
+
+#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
#include <QEvent>
#include <QKeyEvent>
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623158e+308
+#endif
+
ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData)
: ModuleBase_ModelWidget(theParent, theData)
${LightApp}
${CAM}
${OCCViewer}
+ ${qtx}
)
ADD_DEFINITIONS( -DNewGeom_EXPORTS ${CAS_DEFINITIONS} )
#include <XGUI_Workshop.h>
#include <XGUI_PropertyPanel.h>
+#include <XGUI_ContextMenuMgr.h>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SUIT_Desktop.h>
#include <SUIT_ViewManager.h>
+#include <QtxPopupMgr.h>
#include <QtxActionMenuMgr.h>
#include <QDockWidget>
if (isDone) {
setMenuShown( true );
setToolShown( true );
- myWorkshop->propertyPanel()->hide();
if (!mySelector) {
ViewManagerList OCCViewManagers;
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 )
{
return 0;
}
-//******************************************************
-bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
-{
- setMenuShown( false );
- setToolShown( false );
- return LightApp_Module::deactivateModule(theStudy);
-}
-
//******************************************************
CAM_DataModel* NewGeom_Module::createDataModel()
{
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
//! 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);
#include <OCCViewer_ViewWindow.h>
#include <OCCViewer_ViewPort3d.h>
+#include <OCCViewer_ViewFrame.h>
#include <SUIT_ViewManager.h>
+#include <QMouseEvent>
+#include <QContextMenuEvent>
+
+
NewGeom_SalomeViewer::NewGeom_SalomeViewer(QObject* theParent)
: XGUI_SalomeViewer(theParent), mySelector(0)
{
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()));
}
//**********************************************
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);
+ //}
}
//**********************************************
{
return mySelector->viewer()->isMultiSelectionEnabled();
}
+
+//**********************************************
+void NewGeom_SalomeViewer::fitAll()
+{
+ SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
+ OCCViewer_ViewFrame* aVFrame = dynamic_cast<OCCViewer_ViewFrame*>(aMgr->getActiveView());
+ if (aVFrame) {
+ aVFrame->onFitAll();
+ }
+}
\ No newline at end of file
//! 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; }
#include "XGUI_SelectionMgr.h"
#include "XGUI_Displayer.h"
#include "XGUI_MainWindow.h"
-#include "XGUI_Viewer.h"
+#include "XGUI_ViewerProxy.h"
#include "PartSetPlugin_Part.h"
QMenu* aMenu = 0;
if (sender() == myWorkshop->objectBrowser())
aMenu = objectBrowserMenu();
- else if (sender() == myWorkshop->mainWindow()->viewer()) {
+ else if (sender() == myWorkshop->viewer()) {
aMenu = viewerMenu();
}
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;
}
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*)),
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*)));
}
+
class QContextMenuEvent;
class QMenu;
+/**
+* A claas wihich provides manement of context menu
+*/
class XGUI_EXPORT XGUI_ContextMenuMgr: public QObject
{
Q_OBJECT
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);
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;
class QMouseEvent;
class QKeyEvent;
+class QContextMenuEvent;
/**
* A Base object for definition of connector object to
void activated();
void selectionChanged();
+ void contextMenuRequested(QContextMenuEvent*);
};
#endif
\ No newline at end of file
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();
this, SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*)));
connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
+ connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)),
+ this, SIGNAL(contextMenuRequested(QContextMenuEvent*)));
}
}
if (!isSalomeMode()) {
myMainWindow->showPythonConsole();
QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
- myContextMenuMgr->connectViewer();
aWnd->showMaximized();
updateCommandStatus();
}
+ myContextMenuMgr->connectViewer();
QApplication::restoreOverrideCursor();
}