From e914b6884abab44200f8960665ae8c6ab0461f81 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 15 Aug 2005 12:30:15 +0000 Subject: [PATCH] To introduce a way of new types of Viewer and Presentation usage --- src/VISUGUI/VisuGUI.cxx | 142 +---------------------- src/VISUGUI/VisuGUI_Prs3dTools.h | 187 +++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+), 140 deletions(-) create mode 100644 src/VISUGUI/VisuGUI_Prs3dTools.h diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 925841c2..6e66cf12 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -86,7 +86,9 @@ #include "VISU_Actor.h" +#include "VisuGUI_Prs3dTools.h" #include "VisuGUI_Tools.h" + #include "VisuGUI_PopupTools.h" #include "VisuGUI_NameDlg.h" #include "VisuGUI_FileDlg.h" @@ -472,116 +474,6 @@ CreateCurves( SalomeApp_Module* theModule, } } -template -TPrs3d_i* -CreatePrs3d(SalomeApp_Module* theModule, - _PTR(SObject) theTimeStamp, - const char* theMeshName, - VISU::Entity theEntity, - const char* theFieldName, - int theTimeId) -{ - VISU::Result_var aResult; - if (CheckResult(theModule,theTimeStamp,aResult)){ - QApplication::setOverrideCursor(Qt::waitCursor); - typedef typename TPrs3d_i::TInterface TPrs3d; - typename TPrs3d::_var_type aPrs3d = - GetVisuGen(theModule)->template Prs3dOnField - (aResult,theMeshName,theEntity,theFieldName,theTimeId); - QApplication::restoreOverrideCursor(); - if (!CORBA::is_nil(aPrs3d.in())) - return dynamic_cast(VISU::GetServant(aPrs3d.in()).in()); - } - SUIT_MessageBox::warn1(GetDesktop(theModule), - QObject::tr("WRN_VISU"), - QObject::tr("ERR_CANT_BUILD_PRESENTATION"), - QObject::tr("BUT_OK") ); - return NULL; -} - - -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(); - QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); - QApplication::setOverrideCursor(Qt::waitCursor); - TPrs3d_i* aPrs3d = - CreatePrs3d(theModule, - theTimeStamp, - aMeshName.latin1(), - (Entity)anEntity.toInt(), - aFieldName.latin1(), - aTimeStampId.toInt()); - QApplication::restoreOverrideCursor(); - if(aPrs3d){ - SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); - int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0); - if(!aValue){ - if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode - aDlg->initFromPrsObject(aPrs3d); - if(IsDlgModal) - if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) { - // Optionally, create table and curves for cut lines - QApplication::setOverrideCursor(Qt::waitCursor); - CreateCurves( theModule, - dynamic_cast( aPrs3d ), - aDlg, - true ); // in creation mode - QApplication::restoreOverrideCursor(); - delete aDlg; - } else { - DeletePrs3d(theModule,aPrs3d,theIO); - delete aDlg; - return false; - } - else{ - aDlg->show(); - return true; - } - } - } - PublishInView(theModule,aPrs3d); - return true; - } - return false; -} - - -template -void -CreatePrs3d(SalomeApp_Module* theModule) -{ - if (CheckLock(GetCStudy(GetAppStudy(theModule)))) - return; - - _PTR(SObject) aTimeStampSObj; - Handle(SALOME_InteractiveObject) anIO; - if (!CheckTimeStamp(theModule,aTimeStampSObj,&anIO)) - return; - - if (!CreatePrs3d(theModule,aTimeStampSObj,anIO)) - return; - - theModule->application()->putInfo(QObject::tr("INF_DONE")); - theModule->updateObjBrowser(); - UpdateObjBrowser(theModule); - - if (SVTK_ViewWindow* aView = GetViewWindow(theModule)) - aView->onFitAll(); -} - void VisuGUI:: OnCreateMesh() @@ -788,36 +680,6 @@ OnErasePrs() QApplication::restoreOverrideCursor(); } -template -void -EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d) -{ - TPrs3d_i* aPrsObject = dynamic_cast(thePrs3d); - if (aPrsObject) { - TDlg* aDlg = new TDlg (theModule); - aDlg->initFromPrsObject(aPrsObject); - if (aDlg->exec()) { - if (!(aDlg->storeToPrsObject(aPrsObject))) { - delete aDlg; - return; - } - RecreateActor(theModule, aPrsObject); - if (SVTK_ViewWindow* vw = GetViewWindow(theModule)) { - vw->getRenderer()->ResetCameraClippingRange(); - vw->Repaint(); - } - // Optionally, create table and curves for cut lines - QApplication::setOverrideCursor(Qt::waitCursor); - CreateCurves( theModule, - dynamic_cast( aPrsObject ), - aDlg, - false ); // in edition mode - QApplication::restoreOverrideCursor(); - } - delete aDlg; - } -} - void VisuGUI:: OnEditPrs() diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h new file mode 100644 index 00000000..3a75c754 --- /dev/null +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -0,0 +1,187 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 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_Module.h +// Author : +// Module : VISU +// $Header$ + +#ifndef VisuGUI_Prs3dTools_HeaderFile +#define VisuGUI_Prs3dTools_HeaderFile + +#include "VisuGUI_Tools.h" + +namespace VISU +{ + class CutLines_i; + + //--------------------------------------------------------------- + template + void + EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d) + { + TPrs3d_i* aPrsObject = dynamic_cast(thePrs3d); + if (aPrsObject) { + TDlg* aDlg = new TDlg (theModule); + aDlg->initFromPrsObject(aPrsObject); + if (aDlg->exec()) { + if (!(aDlg->storeToPrsObject(aPrsObject))) { + delete aDlg; + return; + } + RecreateActor(theModule, aPrsObject); + if (SVTK_ViewWindow* vw = GetViewWindow(theModule)) { + vw->getRenderer()->ResetCameraClippingRange(); + vw->Repaint(); + } + // Optionally, create table and curves for cut lines + QApplication::setOverrideCursor(Qt::waitCursor); + CreateCurves( theModule, + dynamic_cast( aPrsObject ), + aDlg, + false ); // in edition mode + QApplication::restoreOverrideCursor(); + } + delete aDlg; + } + } + + + //--------------------------------------------------------------- + template + TPrs3d_i* + CreatePrs3d(SalomeApp_Module* theModule, + _PTR(SObject) theTimeStamp, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + int theTimeId) + { + VISU::Result_var aResult; + if (CheckResult(theModule,theTimeStamp,aResult)){ + QApplication::setOverrideCursor(Qt::waitCursor); + typedef typename TPrs3d_i::TInterface TPrs3d; + typename TPrs3d::_var_type aPrs3d = + GetVisuGen(theModule)->template Prs3dOnField + (aResult,theMeshName,theEntity,theFieldName,theTimeId); + QApplication::restoreOverrideCursor(); + if (!CORBA::is_nil(aPrs3d.in())) + return dynamic_cast(VISU::GetServant(aPrs3d.in()).in()); + } + SUIT_MessageBox::warn1(GetDesktop(theModule), + QObject::tr("WRN_VISU"), + QObject::tr("ERR_CANT_BUILD_PRESENTATION"), + QObject::tr("BUT_OK") ); + return NULL; + } + + + //--------------------------------------------------------------- + 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(); + QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); + QApplication::setOverrideCursor(Qt::waitCursor); + + TPrs3d_i* aPrs3d = + CreatePrs3d(theModule, + theTimeStamp, + aMeshName.latin1(), + (Entity)anEntity.toInt(), + aFieldName.latin1(), + aTimeStampId.toInt()); + + QApplication::restoreOverrideCursor(); + if(aPrs3d){ + SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); + int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0); + if(!aValue){ + if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode + aDlg->initFromPrsObject(aPrs3d); + if(IsDlgModal) + if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) { + // Optionally, create table and curves for cut lines + QApplication::setOverrideCursor(Qt::waitCursor); + CreateCurves( theModule, + dynamic_cast( aPrs3d ), + aDlg, + true ); // in creation mode + QApplication::restoreOverrideCursor(); + delete aDlg; + } else { + DeletePrs3d(theModule,aPrs3d,theIO); + delete aDlg; + return false; + } + else{ + aDlg->show(); + return true; + } + } + } + PublishInView(theModule,aPrs3d); + return true; + } + return false; + } + + + //--------------------------------------------------------------- + template + void + CreatePrs3d(SalomeApp_Module* theModule) + { + if (CheckLock(GetCStudy(GetAppStudy(theModule)))) + return; + + _PTR(SObject) aTimeStampSObj; + Handle(SALOME_InteractiveObject) anIO; + if (!CheckTimeStamp(theModule,aTimeStampSObj,&anIO)) + return; + + if (!CreatePrs3d(theModule,aTimeStampSObj,anIO)) + return; + + theModule->application()->putInfo(QObject::tr("INF_DONE")); + theModule->updateObjBrowser(); + UpdateObjBrowser(theModule); + + if (SVTK_ViewWindow* aView = GetViewWindow(theModule)) + aView->onFitAll(); + } + +} + +#endif -- 2.39.2