X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSHAPERGUI%2FSHAPERGUI_SalomeViewer.cpp;h=785c67f2a6220c2018bdf86a3e33f05754755484;hb=97c06c5cd9fc736f9b5a1dacde369a9d7b5be703;hp=f2bd66cae87a648d5b7a691d2c2fa192584dc252;hpb=423c10234142d14d0d5de89383f2f96a4ec5930f;p=modules%2Fshaper.git diff --git a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp index f2bd66cae..785c67f2a 100644 --- a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp +++ b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp @@ -1,20 +1,40 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include "SHAPERGUI_SalomeViewer.h" #include "SHAPERGUI_OCCSelector.h" #include #include - +#include #include #include +#include #include #include #include +#define SALOME_PATCH_FOR_CTRL_WHEEL + SHAPERGUI_SalomeView::SHAPERGUI_SalomeView(OCCViewer_Viewer* theViewer) : ModuleBase_IViewWindow(), myCurrentView(0) { @@ -99,7 +119,7 @@ Handle(V3d_View) SHAPERGUI_SalomeViewer::activeView() const //********************************************** QWidget* SHAPERGUI_SalomeViewer::activeViewPort() const { - QWidget* aViewPort; + QWidget* aViewPort = 0; if (mySelector) { OCCViewer_Viewer* aViewer = mySelector->viewer(); SUIT_ViewManager* aMgr = aViewer->getViewManager(); @@ -351,6 +371,25 @@ void SHAPERGUI_SalomeViewer::fitAll() } } +//********************************************** +void SHAPERGUI_SalomeViewer::eraseAll() +{ + Handle(AIS_InteractiveContext) aContext = AISContext(); + if (aContext.IsNull()) + return; + AIS_ListOfInteractive aList; + aContext->DisplayedObjects(aList); + AIS_ListIteratorOfListOfInteractive aLIt; + Handle(AIS_InteractiveObject) anAISIO; + for (aLIt.Initialize(aList); aLIt.More(); aLIt.Next()) { + anAISIO = aLIt.Value(); + Handle(Standard_Type) aType = anAISIO->DynamicType(); + if (anAISIO->IsKind(STANDARD_TYPE(SALOME_AISShape))) { + aContext->Erase(anAISIO, false); + } + } +} + //********************************************** void SHAPERGUI_SalomeViewer::setViewProjection(double theX, double theY, double theZ, double theTwist) @@ -400,7 +439,7 @@ bool SHAPERGUI_SalomeViewer::hasSelectionFilter(const Handle(SelectMgr_Filter)& const SelectMgr_ListOfFilter& aFilters = aContext->Filters(); SelectMgr_ListIteratorOfListOfFilter aIt(aFilters); for (; aIt.More() && !aFoundFilter; aIt.Next()) { - aFoundFilter = theFilter.Access() == aIt.Value().Access(); + aFoundFilter = theFilter.get() == aIt.Value().get(); } } return aFoundFilter; @@ -442,6 +481,11 @@ void SHAPERGUI_SalomeViewer::activateViewer(bool toActivate) if (!mySelector || !mySelector->viewer()) return; SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager(); +#ifdef SALOME_PATCH_FOR_CTRL_WHEEL + OCCViewer_Viewer* aViewer = dynamic_cast(aMgr->getViewModel()); + if (aViewer) + aViewer->setUseLocalSelection(toActivate); +#endif QVector aViews = aMgr->getViews(); if (toActivate) { foreach (SUIT_ViewWindow* aView, aViews) { @@ -463,17 +507,92 @@ void SHAPERGUI_SalomeViewer::activateViewer(bool toActivate) } } -void SHAPERGUI_SalomeViewer::Zfitall() +bool SHAPERGUI_SalomeViewer::isColorScaleVisible() const { - 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(); + if (mySelector) { + return mySelector->viewer()->isColorScaleVisible(); + } + return false; +} + +void SHAPERGUI_SalomeViewer::setColorScaleShown(bool on) +{ + if (mySelector) { + mySelector->viewer()->setColorScaleShown(on); + } +} + +void SHAPERGUI_SalomeViewer::setColorScalePosition(double theX, double theY) +{ + if (mySelector) { + QWidget* aWindow = activeViewPort(); + mySelector->viewer()->getColorScale()->SetPosition(aWindow->width() * theX, + aWindow->height() * theY); + } +} + +void SHAPERGUI_SalomeViewer::setColorScaleSize(double theW, double theH) +{ + if (mySelector) { + QWidget* aWindow = activeViewPort(); + mySelector->viewer()->getColorScale()->SetSize(aWindow->width() * theW, + aWindow->height() * theH); + } +} + +void SHAPERGUI_SalomeViewer::setColorScaleRange(double theMin, double theMax) +{ + if (mySelector) { + mySelector->viewer()->getColorScale()->SetRange(theMin, theMax); + } +} + +void SHAPERGUI_SalomeViewer::setColorScaleIntervals(int theNb) +{ + if (mySelector) { + mySelector->viewer()->getColorScale()->SetNumberOfIntervals(theNb); + } +} + +void SHAPERGUI_SalomeViewer::setColorScaleTextHeigth(int theH) +{ + if (mySelector) { + mySelector->viewer()->getColorScale()->SetTextHeight(theH); + } +} + +void SHAPERGUI_SalomeViewer::setColorScaleTextColor(const QColor& theColor) +{ + if (mySelector) { + Quantity_Color aColor(theColor.redF(), theColor.greenF(), theColor.blueF(), Quantity_TOC_RGB); + mySelector->viewer()->getColorScale()->SetColor(aColor); } -} \ No newline at end of file +} + +void SHAPERGUI_SalomeViewer::setColorScaleTitle(const QString& theText) +{ + if (mySelector) { + mySelector->viewer()->getColorScale()->SetTitle(theText.toStdString().c_str()); + } +} + + + +//void SHAPERGUI_SalomeViewer::Zfitall() +//{ +// if (!mySelector || !mySelector->viewer()) +// return; +// SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager(); +// /// WORKAROUND for issue #1798. SUIT_ViewManager::closeAllViews() should nullify myActiveView +// /// As a result, we need to check views count in manager +// if (aMgr->getViews().size() > 0) { +// 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