]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
This commit was generated by cvs2git to create branch 'BR-D5-38-2003'.
authoradmin <salome-admin@opencascade.com>
Mon, 15 Aug 2005 12:30:16 +0000 (12:30 +0000)
committeradmin <salome-admin@opencascade.com>
Mon, 15 Aug 2005 12:30:16 +0000 (12:30 +0000)
Cherrypick from master 2005-08-15 12:30:15 UTC apo <apo@opencascade.com> 'To introduce a way of new types of Viewer and Presentation usage':
    src/VISUGUI/VisuGUI_Prs3dTools.h

src/VISUGUI/VisuGUI_Prs3dTools.h [new file with mode: 0644]

diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h
new file mode 100644 (file)
index 0000000..3a75c75
--- /dev/null
@@ -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<class TPrs3d_i, class TDlg>
+  void
+  EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
+  {
+    TPrs3d_i* aPrsObject = dynamic_cast<TPrs3d_i*>(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<VISU::CutLines_i*>( aPrsObject ),
+                     aDlg,
+                     false ); // in edition mode
+       QApplication::restoreOverrideCursor();
+      }
+      delete aDlg;
+    }
+  }
+
+
+  //---------------------------------------------------------------
+  template<class TPrs3d_i>
+  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<TPrs3d_i>
+       (aResult,theMeshName,theEntity,theFieldName,theTimeId);
+      QApplication::restoreOverrideCursor();
+      if (!CORBA::is_nil(aPrs3d.in()))
+       return dynamic_cast<TPrs3d_i*>(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<class TPrs3d_i, class TDlg, int IsDlgModal>
+  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<TPrs3d_i>(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<VISU::CutLines_i*>( 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<class TPrs3d_i, class TDlg, int IsDlgModal>
+  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<TPrs3d_i,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
+      return;
+    
+    theModule->application()->putInfo(QObject::tr("INF_DONE"));
+    theModule->updateObjBrowser();
+    UpdateObjBrowser(theModule);
+    
+    if (SVTK_ViewWindow* aView = GetViewWindow(theModule))
+      aView->onFitAll();
+  }
+
+}
+
+#endif