From 9cf0939dcad468f988923fff4e5f4ac6c0b6513a Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 16 Aug 2005 06:06:46 +0000 Subject: [PATCH] To introduce viewer customization --- src/VISUGUI/VisuGUI_Prs3dTools.h | 29 +++++++---- src/VISUGUI/VisuGUI_ViewTools.h | 89 ++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 10 deletions(-) create mode 100644 src/VISUGUI/VisuGUI_ViewTools.h diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index 3a75c754..cdc0d819 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -29,7 +29,7 @@ #ifndef VisuGUI_Prs3dTools_HeaderFile #define VisuGUI_Prs3dTools_HeaderFile -#include "VisuGUI_Tools.h" +#include "VisuGUI_ViewTools.h" namespace VISU { @@ -97,18 +97,19 @@ namespace VISU //--------------------------------------------------------------- - template + template bool CreatePrs3d(SalomeApp_Module* theModule, _PTR(SObject) theTimeStamp, const Handle(SALOME_InteractiveObject)& theIO) { - using namespace VISU; Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp); + bool isExist; QString aType = Storable::FindValue(aMap,"myType",&isExist); if(!isExist || aType.toInt() != TTIMESTAMP ) return false; + QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); @@ -131,7 +132,7 @@ namespace VISU if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode aDlg->initFromPrsObject(aPrs3d); if(IsDlgModal) - if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) { + if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))){ // Optionally, create table and curves for cut lines QApplication::setOverrideCursor(Qt::waitCursor); CreateCurves( theModule, @@ -151,15 +152,17 @@ namespace VISU } } } - PublishInView(theModule,aPrs3d); + PublishInView(theModule,aPrs3d); + return true; } + return false; } //--------------------------------------------------------------- - template + template void CreatePrs3d(SalomeApp_Module* theModule) { @@ -168,20 +171,26 @@ namespace VISU _PTR(SObject) aTimeStampSObj; Handle(SALOME_InteractiveObject) anIO; - if (!CheckTimeStamp(theModule,aTimeStampSObj,&anIO)) + if(!CheckTimeStamp(theModule,aTimeStampSObj,&anIO)) return; - if (!CreatePrs3d(theModule,aTimeStampSObj,anIO)) + if(!CreatePrs3d(theModule,aTimeStampSObj,anIO)) return; theModule->application()->putInfo(QObject::tr("INF_DONE")); - theModule->updateObjBrowser(); UpdateObjBrowser(theModule); - if (SVTK_ViewWindow* aView = GetViewWindow(theModule)) + typedef typename TViewer::TViewWindow TView; + if(TView* aView = GetViewWindow(theModule)) aView->onFitAll(); } + template + void + CreatePrs3d(SalomeApp_Module* theModule) + { + CreatePrs3d(theModule); + } } #endif diff --git a/src/VISUGUI/VisuGUI_ViewTools.h b/src/VISUGUI/VisuGUI_ViewTools.h new file mode 100644 index 00000000..c4a272c1 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ViewTools.h @@ -0,0 +1,89 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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. +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_Tools.h +// Author : Sergey Anikin +// Module : VISU + +#ifndef VisuGUI_ViewTools_HeaderFile +#define VisuGUI_ViewTools_HeaderFile + +#include "SUIT_MessageBox.h" +#include "SUIT_ViewManager.h" +#include "SUIT_ViewWindow.h" + +#include "SalomeApp_Module.h" +#include "SalomeApp_Application.h" + +#include "VISU_Prs3d_i.hh" + +namespace VISU +{ + //--------------------------------------------------------------- + template + typename TViewer::TViewWindow* + GetViewWindow(const SalomeApp_Module* theModule, + const bool theCreate = false) + { + typedef typename TViewer::TViewWindow TView; + if(SalomeApp_Application* anApp = theModule->getApp()){ + if(SUIT_ViewManager* aViewManager = anApp->getViewManager( TViewer::Type(), theCreate )){ + if(SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()){ + return dynamic_cast(aViewWindow); + } + } + } + return NULL; + } + + + //--------------------------------------------------------------- + template + VISU_Actor* + PublishInView(const SalomeApp_Module* theModule, + Prs3d_i* thePrs) + { + VISU_Actor* aActor = NULL; + + if(!thePrs) + return aActor; + + typedef typename TViewer::TViewWindow TView; + if(TView* aView = GetViewWindow(theModule)){ + QApplication::setOverrideCursor( Qt::waitCursor ); + try{ + if(aActor = thePrs->CreateActor()) + aView->AddActor(aActor); + }catch(std::exception& exc){ + SUIT_MessageBox::warn1(GetDesktop(theModule), + QObject::tr("WRN_VISU"), + QObject::tr("ERR_CANT_CREATE_ACTOR"), + QObject::tr("BUT_OK")); + } + QApplication::restoreOverrideCursor(); + } + return aActor; + } +} + +#endif -- 2.39.2