]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Tune holder presentations creation
authorapo <apo@opencascade.com>
Fri, 24 Nov 2006 13:48:15 +0000 (13:48 +0000)
committerapo <apo@opencascade.com>
Fri, 24 Nov 2006 13:48:15 +0000 (13:48 +0000)
src/VISU_I/VISU_ColoredPrs3dCache_i.cc
src/VISU_I/VISU_ColoredPrs3dCache_i.hh
src/VISU_I/VISU_ColoredPrs3dHolder_i.cc
src/VISU_I/VISU_ColoredPrs3dHolder_i.hh
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_ColoredPrs3d_i.hh
src/VISU_I/VISU_Prs3d_i.cc
src/VISU_I/VISU_Prs3d_i.hh

index dd16a33153660946d00ec0889480001f71c9d1a6..a6ef3c791740488a6e583759046bf4f57ba7b39f 100644 (file)
@@ -85,45 +85,51 @@ VISU::ColoredPrs3dCache_i
 
 
 //----------------------------------------------------------------------------
+template<unsigned int colored_prs3d_type_enum> 
 int
-VISU::ColoredPrs3dCache_i
-::IsPossible(VISU::VISUType theType,
-            const VISU::ColoredPrs3dHolder::BasicInput& theInput)
+CheckIsPossible(const VISU::ColoredPrs3dHolder::BasicInput& theInput)
 {
-  //cout << "VISU::ColoredPrs3dCache_i::IsPossible " << endl;
   VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>( VISU::GetServant(theInput.myResult).in() );
   std::string aMeshName = theInput.myMeshName.in();
   VISU::Entity anEntity = theInput.myEntity;
   std::string aFieldName = theInput.myFieldName.in();
-  long aTimeStampNumber = theInput.myTimeStampNumber;
-
-  bool ok = 0;
-  switch( theType ){
-    case TSCALARMAP: ok = VISU::ScalarMap_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
-      break;
-    case TISOSURFACE: ok = VISU::IsoSurfaces_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber); 
-      break;
-    case TDEFORMEDSHAPE: ok = VISU::DeformedShape_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
-      break;
-    case TSCALARMAPONDEFORMEDSHAPE: ok = VISU::ScalarMapOnDeformedShape_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
-      break;
-    case TGAUSSPOINTS: ok = VISU::GaussPoints_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
-      break;
-    case TPLOT3D: ok = VISU::Plot3D_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
-      break;
-    case TCUTPLANES: ok = VISU::CutPlanes_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
-      break;
-    case TCUTLINES: ok = VISU::CutLines_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
-      break;
-    case TVECTORS: ok = VISU::Vectors_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
-      break;
-    case TSTREAMLINES: ok = VISU::StreamLines_i::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
-      break;
-  default: break;
+  CORBA::Long aTimeStampNumber = theInput.myTimeStampNumber;
+
+  typedef typename VISU::TL::TColoredEnum2Type<colored_prs3d_type_enum>::TResult TColoredPrs3d;
+  return TColoredPrs3d::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
+}
+
+//----------------------------------------------------------------------------
+int
+VISU::ColoredPrs3dCache_i
+::IsPossible(VISU::VISUType theType,
+            const VISU::ColoredPrs3dHolder::BasicInput& theInput)
+{
+  //cout << "VISU::ColoredPrs3dCache_i::IsPossible " << endl;
+  switch(theType){
+  case TSCALARMAP:
+    return CheckIsPossible<TSCALARMAP>(theInput);
+  case TGAUSSPOINTS:
+    return CheckIsPossible<TGAUSSPOINTS>(theInput);
+  case TDEFORMEDSHAPE:
+    return CheckIsPossible<TDEFORMEDSHAPE>(theInput);
+  case TSCALARMAPONDEFORMEDSHAPE:
+    return CheckIsPossible<TSCALARMAPONDEFORMEDSHAPE>(theInput);
+  case TISOSURFACE:
+    return CheckIsPossible<TISOSURFACE>(theInput);
+  case TSTREAMLINES:
+    return CheckIsPossible<TSTREAMLINES>(theInput);
+  case TPLOT3D:
+    return CheckIsPossible<TPLOT3D>(theInput);
+  case TCUTPLANES:
+    return CheckIsPossible<TCUTPLANES>(theInput);
+  case TCUTLINES:
+    return CheckIsPossible<TCUTLINES>(theInput);
+  case TVECTORS:
+    return CheckIsPossible<TVECTORS>(theInput);
   }
 
-  //cout << "returned " << ok << endl;
-  return ok;
+  return 0;
 }
 
 
@@ -164,7 +170,11 @@ VISU::ColoredPrs3dCache_i
   if(IsPossible(theType, theInput))
   {
     VISU::ColoredPrs3dHolder_i* aHolder = new VISU::ColoredPrs3dHolder_i(theType, theInput, *this);
-    CreatePrs(theType, theInput, aHolder);
+    VISU::ColoredPrs3d_i* aColoredPrs3d = CreateColoredPrs3d(theType, theInput);
+    std::string aComment = std::string("myComment=") + aColoredPrs3d->GetComment();
+    std::string aName = aColoredPrs3d->GenerateName().latin1();
+    aHolder->PublishInStudy(aName, aComment);
+    RegisterInHolder(aColoredPrs3d, aHolder);
     return aHolder->_this();
   }
   return VISU::ColoredPrs3dHolder::_nil();
@@ -212,7 +222,7 @@ std::string
 VISU::ColoredPrs3dCache_i
 ::GetFolderName() 
 { 
-  return "Cache"; 
+  return "3D Cache System"; 
 }
 
 void
@@ -260,25 +270,43 @@ CreateHolder2GetDeviceByEnum(VISU::VISUType theType,
 //----------------------------------------------------------------------------
 VISU::ColoredPrs3d_i*
 VISU::ColoredPrs3dCache_i
-::CreatePrs(VISU::VISUType theType,
-           VISU::ColoredPrs3dHolder::BasicInput theInput,
-           VISU::ColoredPrs3dHolder_i* theHolder)
+::CreateColoredPrs3d(VISU::VISUType theType,
+                    VISU::ColoredPrs3dHolder::BasicInput theInput)
 {
   VISU::ColoredPrs3d_i* aPrs3d = VISU::CreatePrs3d_i(theType, GetStudyDocument(), ColoredPrs3d_i::ERegisterInCache);
-  aPrs3d->SetHolderEntry( theHolder->GetEntry() );
   aPrs3d->SetResultObject( theInput.myResult );  
   aPrs3d->SetMeshName( theInput.myMeshName );  
   aPrs3d->SetEntity( theInput.myEntity );  
   aPrs3d->SetFieldName( theInput.myFieldName );  
   aPrs3d->SetTimeStampNumber( theInput.myTimeStampNumber );
   aPrs3d->Apply();
-
-  GetLastVisitedPrsList(theHolder).push_back(aPrs3d);
-  
   return aPrs3d;
 }
 
 
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d_i*
+VISU::ColoredPrs3dCache_i
+::RegisterInHolder(VISU::ColoredPrs3d_i* thePrs3d,
+                  VISU::ColoredPrs3dHolder_i* theHolder)
+{
+  thePrs3d->SetHolderEntry( theHolder->GetEntry() );
+  GetLastVisitedPrsList(theHolder).push_back(thePrs3d);  
+  return thePrs3d;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d_i*
+VISU::ColoredPrs3dCache_i
+::CreatePrs(VISU::VISUType theType,
+           VISU::ColoredPrs3dHolder::BasicInput theInput,
+           VISU::ColoredPrs3dHolder_i* theHolder)
+{
+  return RegisterInHolder(CreateColoredPrs3d(theType, theInput), theHolder);
+}
+
+
 //----------------------------------------------------------------------------
 VISU::TLastVisitedPrsList&
 VISU::ColoredPrs3dCache_i
index b4b970c97a786c375cc1e3d509f6f04a3febee27..4eb1f3cbe044405cece63a19d1e71e14de93e0f2 100644 (file)
@@ -127,6 +127,17 @@ namespace VISU
     VISU::ColoredPrs3dCache_ptr
     GetInstance(SALOMEDS::Study_ptr theStudy);
 
+    //! Creates corresponding ColoredPrs3d instance and apply the BasicInput
+    VISU::ColoredPrs3d_i*
+    CreateColoredPrs3d(VISU::VISUType theType,
+                      VISU::ColoredPrs3dHolder::BasicInput theInput);
+
+    //! Registers the given ColoredPrs3d instance for the ColoredPrs3dHolder
+    VISU::ColoredPrs3d_i*
+    RegisterInHolder(VISU::ColoredPrs3d_i* thePrs3d,
+                    VISU::ColoredPrs3dHolder_i* theHolder);
+
+    //! Creates and registers corresponding ColoredPrs3d instance for the ColoredPrs3dHolder
     VISU::ColoredPrs3d_i*
     CreatePrs(VISU::VISUType theType,
              VISU::ColoredPrs3dHolder::BasicInput theInput,
index e67888aa23ae6ed51d188f7ec70d66d71b2865e6..5825e08bb5899c6fa41ddb8f54f5d0b21936b519 100644 (file)
@@ -69,27 +69,6 @@ VISU::ColoredPrs3dHolder_i
   myCache(theCache)
 {
   if(MYDEBUG) MESSAGE("ColoredPrs3dHolder_i::ColoredPrs3dHolder_i - this = "<<this);
-
-  QString aType;
-  switch( theType ){
-    case TSCALARMAP:                aType = "SCALARMAP"; break;
-    case TISOSURFACE:               aType = "ISOSURFACES"; break;
-    case TDEFORMEDSHAPE:            aType = "DEFORMEDSHAPE"; break;
-    case TSCALARMAPONDEFORMEDSHAPE: aType = "SCALARMAPONDEFORMEDSHAPE"; break;
-    case TGAUSSPOINTS:              aType = "GAUSSPOINTS"; break;
-    case TPLOT3D:                   aType = "PLOT3D"; break;
-    case TCUTPLANES:                aType = "CUTPLANES"; break;
-    case TCUTLINES:                 aType = "CUTLINES"; break;
-    case TVECTORS:                  aType = "VECTORS"; break;
-    case TSTREAMLINES:              aType = "STREAMLINES"; break;
-    default: break;
-  }
-
-  SetName(GenerateName().latin1(), false);
-  CORBA::String_var anIOR = GetID();
-  std::string aFatherEntry = theCache.GetEntry();
-  QString aComment = QString("myComment=") + aType;
-  CreateAttributes(GetStudyDocument(), aFatherEntry, "", anIOR.in(), GetName(), "", aComment, true);
 }
 
 
@@ -101,6 +80,18 @@ VISU::ColoredPrs3dHolder_i
 }
 
 
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3dHolder_i
+::PublishInStudy(const std::string& theName, 
+                const std::string& theComment)
+{
+  SetName(theName, false);
+  CORBA::String_var anIOR = GetID();
+  std::string aFatherEntry = myCache.GetEntry();
+  CreateAttributes(GetStudyDocument(), aFatherEntry, "", anIOR.in(), GetName(), "", theComment, true);
+}
+
 //----------------------------------------------------------------------------
 CORBA::Boolean 
 VISU::ColoredPrs3dHolder_i
index 204924c9e9f62bb95c10d468529532783c8bfa1a..e78aac0d2705534cb5ff7b9370b21ad32443d2db 100644 (file)
@@ -47,6 +47,8 @@ namespace VISU
   {
     ColoredPrs3dHolder_i();
     ColoredPrs3dHolder_i(const ColoredPrs3dHolder_i&);
+
+    friend class ColoredPrs3dCache_i;
   public:
     //----------------------------------------------------------------------------
     //! A constructor to create an instance of the class
@@ -120,6 +122,10 @@ namespace VISU
 
     //----------------------------------------------------------------------------
   private:
+    void
+    PublishInStudy(const std::string& theName, 
+                  const std::string& theComment);
+
     VISU::ColoredPrs3dCache_i& myCache;
     static const std::string myComment;
     static int myNbHolders;
index 3098f582ad63e2cd49b811d204970d14730182f2..9fa199d3d600511017fa3df8d719a7a2e366d265 100644 (file)
@@ -362,21 +362,11 @@ void
 VISU::ColoredPrs3d_i
 ::SetHolderEntry(const std::string& theEntry)
 {
-  myHolderEntry = theEntry; 
+  myHolderEntry = theEntry;
+  SetIO(new SALOME_InteractiveObject(theEntry.c_str(), "VISU", GetName().c_str()));
 }
 
 
-//----------------------------------------------------------------------------
-Handle(SALOME_InteractiveObject)
-VISU::ColoredPrs3d_i
-::GetIO()
-{
-  Handle(SALOME_InteractiveObject) anIO = TSuperClass::GetIO();
-  if(myHolderEntry != "")
-    anIO->setEntry(myHolderEntry.c_str());
-  return anIO;
-}
-
 //----------------------------------------------------------------------------
 CORBA::Boolean 
 VISU::ColoredPrs3d_i
index eb46188e41625f93c041286425164c6774bf29eb..19ad5515f5ddc3bad1304025b4b08366e19f8165 100644 (file)
@@ -227,12 +227,6 @@ namespace VISU
     void
     SetHolderEntry(const std::string& theEntry);
 
-    //----------------------------------------------------------------------------
-    //! Create and return the interactive object
-    virtual
-    Handle(SALOME_InteractiveObject)
-    GetIO();
-
     //----------------------------------------------------------------------------
   public:
     /*!
index 126ad99520b4ab2b4b84c0bd21036a380c71b5d9..1ac89d41b4bd47a75161541bda343f0fe4e1aca8 100644 (file)
@@ -395,6 +395,14 @@ VISU::Prs3d_i
   return myIO;
 }
 
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::SetIO(const Handle(SALOME_InteractiveObject)& theIO)
+{
+  myIO = theIO;
+}
+
 //----------------------------------------------------------------------------
 void
 VISU::Prs3d_i
index ce9415d7a7906971719135603727cc9db18afb35..3afc8c0f0f4f43a3092ddcb0fe441c86c83f3775 100644 (file)
@@ -273,6 +273,9 @@ namespace VISU
     void 
     SetSObject(SALOMEDS::SObject_var theSObject);
 
+    void
+    SetIO(const Handle(SALOME_InteractiveObject)& theIO);
+
   protected:
     vtkTimeStamp myUpdateTime;
     vtkTimeStamp myParamsTime;