X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FNewGeom%2FNewGeom_SalomeViewer.cpp;h=636abd69f2a5638603e1932edcad61801aa6da24;hb=5b679606e1f5aa81b438efe5f00cead3bfa85859;hp=0613d66243959e0efcc1ed29da32efc6039d2639;hpb=d499ef7358a4dc4ce020054fc94ef04c22e9e444;p=modules%2Fshaper.git diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index 0613d6624..636abd69f 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -3,24 +3,43 @@ #include "NewGeom_SalomeViewer.h" #include "NewGeom_OCCSelector.h" -#include #include #include #include +#include + #include #include +NewGeom_SalomeView::NewGeom_SalomeView(OCCViewer_Viewer* theViewer) +: ModuleBase_IViewWindow(), myCurrentView(0) +{ + myViewer = theViewer; +} + Handle(V3d_View) NewGeom_SalomeView::v3dView() const { - SUIT_ViewManager* aMgr = myViewer->getViewManager(); - OCCViewer_ViewWindow* aWnd = static_cast(aMgr->getActiveView()); - Handle(V3d_View) aView = aWnd->getViewPort()->getView(); + Handle(V3d_View) aView; + if (myCurrentView) { + OCCViewer_ViewWindow* aWnd = static_cast(myCurrentView); + aView = aWnd->getViewPort()->getView(); + } return aView; } +QWidget* NewGeom_SalomeView::viewPort() const +{ + QWidget* aViewPort = 0; + if (myCurrentView) { + OCCViewer_ViewWindow* aWnd = static_cast(myCurrentView); + aViewPort = aWnd->getViewPort(); + } + return aViewPort; +} + //********************************************** //********************************************** //********************************************** @@ -99,8 +118,8 @@ void NewGeom_SalomeViewer::setSelector(NewGeom_OCCSelector* theSel) this, SLOT(onDeleteView(SUIT_ViewWindow*))); connect(aMgr, SIGNAL(viewCreated(SUIT_ViewWindow*)), this, SLOT(onViewCreated(SUIT_ViewWindow*))); - connect(aMgr, SIGNAL(activated(SUIT_ViewWindow*)), - this, SLOT(onActivated(SUIT_ViewWindow*))); + connect(aMgr, SIGNAL(activated(SUIT_ViewManager*)), + this, SLOT(onActivated(SUIT_ViewManager*))); connect(aMgr, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); @@ -127,14 +146,16 @@ void NewGeom_SalomeViewer::onSelectionChanged() } //********************************************** -void NewGeom_SalomeViewer::onMousePress(SUIT_ViewWindow*, QMouseEvent* theEvent) +void NewGeom_SalomeViewer::onMousePress(SUIT_ViewWindow* theView, QMouseEvent* theEvent) { + myView->setCurrentView(theView); emit mousePress(myView, theEvent); } //********************************************** -void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow*, QMouseEvent* theEvent) +void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow* theView, QMouseEvent* theEvent) { + myView->setCurrentView(theView); emit mouseRelease(myView, theEvent); if (myIsSelectionChanged) { emit selectionChanged(); @@ -143,34 +164,35 @@ void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow*, QMouseEvent* theEven } //********************************************** -void NewGeom_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent* theEvent) +void NewGeom_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow* theView, QMouseEvent* theEvent) { + myView->setCurrentView(theView); emit mouseDoubleClick(myView, theEvent); } //********************************************** void NewGeom_SalomeViewer::onMouseMove(SUIT_ViewWindow* theView, QMouseEvent* theEvent) { - OCCViewer_ViewWindow* aViewWnd = dynamic_cast(theView); - Handle(AIS_InteractiveContext) aContext = AISContext(); - if (aContext->HasDetected()) - aViewWnd->getViewPort()->setFocus(Qt::MouseFocusReason); + myView->setCurrentView(theView); emit mouseMove(myView, theEvent); } //********************************************** -void NewGeom_SalomeViewer::onKeyPress(SUIT_ViewWindow* theView, QKeyEvent* theEvent) +bool NewGeom_SalomeViewer::canDragByMouse() const { - OCCViewer_ViewWindow* aViewWnd = dynamic_cast(theView); - Handle(AIS_InteractiveContext) aContext = AISContext(); - Handle(V3d_View) aView = aViewWnd->getViewPort()->getView(); - - bool noModifiers = (theEvent->modifiers() == Qt::NoModifier); - if ((theEvent->key() == Qt::Key_N) && noModifiers) { - aContext->HilightNextDetected(aView); - } else if ((theEvent->key() == Qt::Key_P) && noModifiers) { - aContext->HilightPreviousDetected(aView); + OCCViewer_Viewer* aViewer = mySelector->viewer(); + SUIT_ViewWindow* aWnd = aViewer->getViewManager()->getActiveView(); + OCCViewer_ViewWindow* aViewWnd = dynamic_cast(aWnd); + if (aViewWnd) { + return (aViewWnd->interactionStyle() == 0); } + return true; +} + + +//********************************************** +void NewGeom_SalomeViewer::onKeyPress(SUIT_ViewWindow* theView, QKeyEvent* theEvent) +{ emit keyPress(myView, theEvent); } @@ -189,18 +211,32 @@ void NewGeom_SalomeViewer::onTryCloseView(SUIT_ViewWindow*) //********************************************** void NewGeom_SalomeViewer::onDeleteView(SUIT_ViewWindow*) { + if(myWindowScale.contains(myView->v3dView())) + myWindowScale.remove(myView->v3dView()); emit deleteView(myView); } //********************************************** -void NewGeom_SalomeViewer::onViewCreated(SUIT_ViewWindow*) +void NewGeom_SalomeViewer::onViewCreated(SUIT_ViewWindow* theView) { + myView->setCurrentView(theView); + + OCCViewer_ViewFrame* aView = dynamic_cast(theView); + + OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW); + if (aWnd) + connect(aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)), + this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType))); + + myWindowScale.insert (aView->getViewPort()->getView(), aView->getViewPort()->getView()->Camera()->Scale()); + emit viewCreated(myView); } //********************************************** -void NewGeom_SalomeViewer::onActivated(SUIT_ViewWindow*) +void NewGeom_SalomeViewer::onActivated(SUIT_ViewManager* theMgr) { + myView->setCurrentView(theMgr->getActiveView()); emit activated(myView); } @@ -208,7 +244,8 @@ void NewGeom_SalomeViewer::onActivated(SUIT_ViewWindow*) void NewGeom_SalomeViewer::enableSelection(bool isEnabled) { if (mySelector) - mySelector->viewer()->enableSelection(isEnabled); + if (mySelector->viewer()->isSelectionEnabled() != isEnabled) + mySelector->viewer()->enableSelection(isEnabled); // The enableSelection() in SALOME 7.5 cause of forced Viewer update(we have blinking) // After this is corrected, the first row should be recommented, the last - removed //mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD @@ -250,7 +287,7 @@ void NewGeom_SalomeViewer::fitAll() } //********************************************** -void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double theZ) +void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double theZ, double theTwist) { if (!mySelector) return; @@ -261,8 +298,11 @@ void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double th Handle(V3d_View) aView3d = aVFrame->getViewPort()->getView(); if (!aView3d.IsNull()) { aView3d->SetProj(theX, theY, theZ); + aView3d->SetTwist( theTwist ); aView3d->FitAll(0.01, true); aView3d->SetZSize(0.); + if (aView3d->Depth() < 0.1) + aView3d->DepthFitAll(); } } } @@ -285,6 +325,21 @@ void NewGeom_SalomeViewer::removeSelectionFilter(const Handle(SelectMgr_Filter)& } } +//*************************************** +bool NewGeom_SalomeViewer::hasSelectionFilter(const Handle(SelectMgr_Filter)& theFilter) +{ + bool aFoundFilter = false; + Handle(AIS_InteractiveContext) aContext = AISContext(); + if (!aContext.IsNull()) { + const SelectMgr_ListOfFilter& aFilters = aContext->Filters(); + SelectMgr_ListIteratorOfListOfFilter aIt(aFilters); + for (; aIt.More() && !aFoundFilter; aIt.Next()) { + aFoundFilter = theFilter.Access() == aIt.Value().Access(); + } + } + return aFoundFilter; +} + //*************************************** void NewGeom_SalomeViewer::clearSelectionFilters() { @@ -302,3 +357,48 @@ void NewGeom_SalomeViewer::update() aContext->UpdateCurrentViewer(); } } + +//*************************************** +void NewGeom_SalomeViewer::onViewTransformed(OCCViewer_ViewWindow::OperationType theType) +{ + emit viewTransformed((int) theType); +} + +//*************************************** +void NewGeom_SalomeViewer::activateViewer(bool toActivate) +{ + if (!mySelector || !mySelector->viewer()) + return; + SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager(); + QVector aViews = aMgr->getViews(); + if (toActivate) { + foreach (SUIT_ViewWindow* aView, aViews) { + OCCViewer_ViewFrame* aOCCView = dynamic_cast(aView); + OCCViewer_ViewWindow* aWnd = aOCCView->getView(OCCViewer_ViewFrame::MAIN_VIEW); + connect(aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)), + this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType))); + } + } else { + foreach (SUIT_ViewWindow* aView, aViews) { + OCCViewer_ViewFrame* aOCCView = dynamic_cast(aView); + OCCViewer_ViewWindow* aWnd = aOCCView->getView(OCCViewer_ViewFrame::MAIN_VIEW); + disconnect((OCCViewer_ViewWindow*)aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)), + this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType))); + } + } +} + +void NewGeom_SalomeViewer::Zfitall() +{ + if (!mySelector || !mySelector->viewer()) + return; + SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager(); + OCCViewer_ViewFrame* aView = dynamic_cast(aMgr->getActiveView()); + if (aView) { + OCCViewer_ViewWindow* aWnd = aView->getView(OCCViewer_ViewFrame::MAIN_VIEW); + Handle(V3d_View) aView3d = aWnd->getViewPort()->getView(); + aView3d->ZFitAll(); + if (aView3d->Depth() < 0.1) + aView3d->DepthFitAll(); + } +} \ No newline at end of file