]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Update from OCC OCC-V2_1_0_deb
authoradmin <salome-admin@opencascade.com>
Fri, 17 Dec 2004 08:19:12 +0000 (08:19 +0000)
committeradmin <salome-admin@opencascade.com>
Fri, 17 Dec 2004 08:19:12 +0000 (08:19 +0000)
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h
src/VISU_I/VISU_Table_i.cc
src/VISU_I/VISU_Table_i.hh

index eb81af8ac08ee601a6babe536dcaf8384cad09bc..12229e66b38cfedba19bb4a8bc3eda2c252b0645 100644 (file)
@@ -149,28 +149,37 @@ static int MYDEBUG = 0;
 static int MYDEBUGWITHFILES = 0;
 #endif
 
-class CustomItem : public QCustomMenuItem{
+class CustomItem : public QCustomMenuItem
+{
 public:
-  CustomItem( const QString& s, const QFont& f )
-    : string( s ), font( f ){};
-  ~CustomItem(){}
-  
-  void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
+  CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
+  ~CustomItem() {}
+
+  void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
   {
-    p->setFont ( font );
-    p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
+    p->save();
+    p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
+    p->setPen( act ? cg.highlightedText() : cg.buttonText() );
+    p->setFont( myFont );
+    p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
+    p->restore();
   }
-  
+
   QSize sizeHint()
   {
-    return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip,  string );
+    return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
   }
+
+  bool fullSpan() const
+  {
+    return true;
+  }
+
 private:
-  QString string;
-  QFont font;
+  QString myString;
+  QFont   myFont;
 };
 
-
 inline bool IsSObjectTable(SALOMEDS::SObject_ptr theSObject){
   if(!theSObject->_is_nil()) {
     SALOMEDS::GenericAttribute_var anAttr;
@@ -1923,19 +1932,35 @@ void VisuGUI::DeleteObject() {
        if(!CORBA::is_nil(aBase)){
          VISU::VISUType aType = aBase->GetType();
          switch (aType){
-         case VISU::TRESULT:{
-           SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
-           for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
-             SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
-             CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
-             if(CORBA::is_nil(aChildObj)) continue;
-             VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
-             if(CORBA::is_nil(aPrs3d)) continue;
-             VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
-             DeletePresentation(pPrs3d);
+         case VISU::TRESULT:
+           {
+             SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
+             for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
+               SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
+               CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
+                 if(CORBA::is_nil(aChildObj)) continue;
+                 VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
+                 if(CORBA::is_nil(aPrs3d)) continue;
+                 VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
+                 DeletePresentation(pPrs3d);
+             }
+             break;
            }
-           break;
-         }}
+         case VISU::TTABLE:
+           {
+             SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
+             for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
+               SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
+               CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
+                 if(CORBA::is_nil(aChildObj)) continue;
+                 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( aChildObj );
+                 if(CORBA::is_nil(aCurve)) continue;
+                 VISU::Curve_i* pCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
+                 DeletePresentation(pCurve);
+             }
+             break;
+           }
+         }
        }
       }
       aStudyBuilder->RemoveObjectWithChildren(aSObject);
@@ -2254,8 +2279,17 @@ void VisuGUI::DeletePrs() {
   SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
   aStudyBuilder->NewCommand();
 
-  DeletePresentation(GetSelectedPrs3d());
-
+  CORBA::Object_var anObject = GetSelectedObj();
+  if ( !CORBA::is_nil( anObject ) ) {
+    // is it Prs3d object ?
+    VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
+    if(aPrsObject)
+      DeletePresentation(aPrsObject);
+    // is it Curve object ?
+    VISU::Curve_i* aCurveObject = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
+    if(aCurveObject)
+      DeletePresentation(aCurveObject);
+  }
   aStudyBuilder->CommitCommand();
 }
 
@@ -2855,6 +2889,7 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri
            thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
          thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
        }
+       if ( !aIsLocked ) thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
        break;
 
       case VISU::TCONTAINER:
@@ -3153,9 +3188,8 @@ void VisuGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO,
   SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
   SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
 
-  if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return;
-
-  vtkRenderer *Renderer = GetRenderer();
+  if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK &&
+       GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_PLOT2D) return;
 
   SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
   SCRUTE(aSObj);
@@ -3167,20 +3201,34 @@ void VisuGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO,
   CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
   if(!CORBA::is_nil(anObject)) {
     VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
-    if ( !aPrsObject ) {
-      if(MYDEBUG) MESSAGE("The object is not VISU::Prs3d_i");
-      return;
-    }
-    VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
-    if(!SelectedActor)
-      try{
-       SelectedActor = aPrsObject -> CreateActor();
-       if(VTKViewer_ViewFrame* vf = GetVtkViewFrame())
-         vf->AddActor(SelectedActor);
-      }catch(std::runtime_error& exc){
-       INFOS(exc.what());
-       throw exc; 
+    if ( aPrsObject ) {
+      VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
+      if(!SelectedActor) {
+       try{
+         SelectedActor = aPrsObject -> CreateActor();
+         if(VTKViewer_ViewFrame* vf = GetVtkViewFrame())
+           vf->AddActor(SelectedActor);
+       }catch(std::runtime_error& exc){
+         INFOS(exc.what());
+         throw exc; 
+       }
       }
+    }
+    VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
+    if ( aTable ) {
+      // table object 
+      PlotTable(aTable, VISU::eDisplay );
+    }
+    VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
+    if ( aContainer ) {
+      // container object
+      PlotContainer(aContainer, VISU::eDisplay );
+    }
+    VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
+    if ( aCurve ) {
+      // curve object 
+      PlotCurve(aCurve, VISU::eDisplay );
+    }
   }else
     if(MYDEBUG) MESSAGE("CORBA::is_nil(anObject) = true");
   END_OF("VisuGUI::BuildPresentation");
@@ -3999,6 +4047,30 @@ void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) {
   GetActiveStudy()->updateObjBrowser(); //update Object browser
 }
 
+/**
+ * Deletes given curve presentation from Data structure
+ */
+void VisuGUI::DeletePresentation(VISU::Curve_i* theCurve) {
+  if(checkLock(GetStudyDocument()) || !theCurve) return;
+  GetActiveStudy()->unHighlightAll();
+  for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
+    if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
+      QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
+      if(Plot2d_ViewFrame* aViewFrame = dynamic_cast<Plot2d_ViewFrame*>(aVFrame)){
+       QList<Plot2d_Curve> clist;
+       aViewFrame->getCurves( clist );
+       for ( int i = 0; i < clist.count(); i++ ) {
+         if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) )
+           aViewFrame->eraseCurve( clist.at( i ) );
+       }
+       aViewFrame->Repaint();
+       aViewFrame->unHighlightAll();
+      }
+    }
+  theCurve->RemoveFromStudy(); 
+  GetActiveStudy()->updateObjBrowser(); //update Object browser
+}
+
 /**
  * Creates new actor of presentation
  */
index aa78fe3455279282c285bdc74dea3cadad28acda..bcefa28a22cb996ca8fc96d1c692f729ca3e4554 100644 (file)
@@ -166,6 +166,7 @@ class VisuGUI : public SALOMEGUI{
   
   void VisuGUI::ChangeRepresentation(VISU::PresentationType theType);
   void DeletePresentation(VISU::Prs3d_i* thePrs);
+  void DeletePresentation(VISU::Curve_i* theCurve);
   
   void         SetState(int aState );
   void         ResetState();
index 1607524ce31c374d90be9189c629b34f436e4fc8..5097767f5eb24dfd6d7318239913790981f9e181 100644 (file)
@@ -31,6 +31,7 @@
 #include "QAD_Study.h"
 
 #include "VISU_CutLines_i.hh"
+#include "VISU_Result_i.hh"
 
 #include <memory>      
 #include <fstream>     
@@ -249,6 +250,10 @@ const char* VISU::Table_i::GetTableTitle()
   return ""; 
 }
 
+void VISU::Table_i::RemoveFromStudy(){
+  VISU::RemoveFromStudy(mySObj,false);
+}
+
 //----------------------------------------------------------------
 //                      Curve Object
 //----------------------------------------------------------------
@@ -641,6 +646,10 @@ VISU::Storable* VISU::Curve_i::Restore(SALOMEDS::SObject_ptr theSObject,
   return NULL;
 }
 
+void VISU::Curve_i::RemoveFromStudy(){
+  VISU::RemoveFromStudy(mySObj,false);
+}
+
 //----------------------------------------------------------------
 //                      Container Object
 //----------------------------------------------------------------
@@ -786,6 +795,7 @@ VISU::Storable* VISU::Container_i::Build( int theRestoring )
                                       "",
                                       aComment.latin1(),
                                       true );
+    mySObj = SALOMEDS::SObject::_duplicate(myStudy->FindObjectID(anEntry.c_str()));
   }
   return this;
 }
@@ -873,9 +883,10 @@ VISU::Curve_i* VISU::Container_i::GetCurve( CORBA::Long theIndex )
 /*!
   Restores container data from the stream
 */
-VISU::Storable* VISU::Container_i::Restore( const Storable::TRestoringMap& theMap )
+VISU::Storable* VISU::Container_i::Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO )
 {
   if(MYDEBUG) MESSAGE(GetComment());
+  mySObj = SALOMEDS::SObject::_duplicate(SO);
   myName = VISU::Storable::FindValue( theMap, "myName" ).latin1(); 
   QString val = VISU::Storable::FindValue( theMap, "myCurves" );
   myCurves = QStringList::split( QString( "*" ), val, false );
@@ -899,7 +910,11 @@ VISU::Storable* VISU::Container_i::Restore(SALOMEDS::SObject_ptr theSObject,
 {
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
   VISU::Container_i* pResent = new VISU::Container_i( aStudy );
-  return pResent->Restore( theMap );
+  return pResent->Restore( theMap, theSObject );
+}
+
+void VISU::Container_i::RemoveFromStudy(){
+  VISU::RemoveFromStudy(mySObj,false);
 }
 
 //-------------------------------------------------------------
index 136ce6ac8a5063541614275e618556eff67bfd1f..1d00478b70c746a097fe0ec7d422b5aed68bb6b8 100644 (file)
@@ -54,6 +54,8 @@ namespace VISU{
     virtual CORBA::Long GetNbRows();
     virtual CORBA::Long GetNbColumns();
 
+    virtual void RemoveFromStudy();
+
   protected:
     Storable* Build(int theRestoring);
 
@@ -103,6 +105,8 @@ namespace VISU{
     virtual VISU::Curve::LineType GetLine() { return myLine; }
     virtual CORBA::Long GetLineWidth() { return myLineWidth; }
 
+    virtual void RemoveFromStudy();
+
   protected:
     Storable* Build(int theRestoring);
 
@@ -160,15 +164,18 @@ namespace VISU{
     virtual CORBA::Long GetNbCurves();
     virtual void Clear();
 
+    virtual void RemoveFromStudy();
+
   protected:
     Storable* Build(int theRestoring);
     
   protected:
     QStringList myCurves;
-    
+    SALOMEDS::SObject_var mySObj;
+        
   public:
     virtual Storable* Create();
-    virtual Storable* Restore( const Storable::TRestoringMap& theMap );
+    virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO );
 
     static Storable* Restore(SALOMEDS::SObject_ptr theSObject, 
                             const string& thePrefix, const Storable::TRestoringMap& theMap);