X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FNewGeom%2FNewGeom_SalomeViewer.cpp;h=d9ce85febf901d738fa94427301ce74ddd4c10ca;hb=24f1ad2fd93475684288c899fb4fffcf05f6c21e;hp=5fe0be383819ede7a8b7f2dfe95e8c76778ac3eb;hpb=c52423b158d7e2bae396c62e4fe62e7e8f78c381;p=modules%2Fshaper.git diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index 5fe0be383..d9ce85feb 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -1,21 +1,28 @@ - #include "NewGeom_SalomeViewer.h" #include "NewGeom_OCCSelector.h" #include #include +#include #include +#include +#include + NewGeom_SalomeViewer::NewGeom_SalomeViewer(QObject* theParent) -: XGUI_SalomeViewer(theParent), mySelector(0) + : ModuleBase_IViewer(theParent), + mySelector(0) { } //********************************************** Handle(AIS_InteractiveContext) NewGeom_SalomeViewer::AISContext() const { - return mySelector->viewer()->getAISContext(); + if (mySelector && mySelector->viewer()) + return mySelector->viewer()->getAISContext(); + Handle(AIS_InteractiveContext) aNull; + return aNull; } //********************************************** @@ -44,32 +51,31 @@ void NewGeom_SalomeViewer::setSelector(NewGeom_OCCSelector* theSel) } } mySelector = theSel; + if (!mySelector) + return; OCCViewer_Viewer* aViewer = mySelector->viewer(); SUIT_ViewManager* aMgr = aViewer->getViewManager(); - connect(aMgr, SIGNAL(lastViewClosed(SUIT_ViewManager*)), - this, SIGNAL(lastViewClosed())); - connect(aMgr, SIGNAL(tryCloseView(SUIT_ViewManager*)), - this, SIGNAL(tryCloseView())); - connect(aMgr, SIGNAL(deleteView(SUIT_ViewManager*)), - this, SIGNAL(deleteView())); - connect(aMgr, SIGNAL(viewCreated(SUIT_ViewManager*)), - this, SIGNAL(viewCreated())); - connect(aMgr, SIGNAL(activated(SUIT_ViewManager*)), - this, SIGNAL(activated())); - - connect(aMgr, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); - connect(aMgr, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); - connect(aMgr, SIGNAL(mouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*))); - connect(aMgr, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*))); - connect(aMgr, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)), - this, SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*))); - connect(aMgr, SIGNAL(keyRelease(SUIT_ViewWindow*, QKeyEvent*)), - this, SLOT(onKeyRelease(SUIT_ViewWindow*, QKeyEvent*))); + connect(aMgr, SIGNAL(lastViewClosed(SUIT_ViewManager*)), this, SIGNAL(lastViewClosed())); + connect(aMgr, SIGNAL(tryCloseView(SUIT_ViewManager*)), this, SIGNAL(tryCloseView())); + connect(aMgr, SIGNAL(deleteView(SUIT_ViewManager*)), this, SIGNAL(deleteView())); + connect(aMgr, SIGNAL(viewCreated(SUIT_ViewManager*)), this, SIGNAL(viewCreated())); + connect(aMgr, SIGNAL(activated(SUIT_ViewManager*)), this, SIGNAL(activated())); + + connect(aMgr, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), this, + SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + connect(aMgr, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), this, + SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); + connect(aMgr, SIGNAL(mouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)), this, + SLOT(onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*))); + connect(aMgr, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), this, + SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*))); + connect(aMgr, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)), 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 +88,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 +142,28 @@ 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(); + } +} + +//********************************************** +void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double theZ) +{ + SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager(); + OCCViewer_ViewFrame* aVFrame = dynamic_cast(aMgr->getActiveView()); + if (aVFrame) { + Handle(V3d_View) aView3d = aVFrame->getViewPort()->getView(); + if (!aView3d.IsNull()) { + aView3d->SetProj(theX, theY, theZ); + aView3d->FitAll(0.01, true, true); + aView3d->SetZSize(0.); + } + } +} \ No newline at end of file