From 13e3366c50c3e12fa3788baf24d8e13b2ec9e300 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 17 Dec 2004 08:19:12 +0000 Subject: [PATCH] Update from OCC --- src/VISUGUI/VisuGUI.cxx | 158 +++++++++++++++++++++++++++---------- src/VISUGUI/VisuGUI.h | 1 + src/VISU_I/VISU_Table_i.cc | 19 ++++- src/VISU_I/VISU_Table_i.hh | 11 ++- 4 files changed, 142 insertions(+), 47 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index eb81af8a..12229e66 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -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::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::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::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::GetServant(anObject).in()); + if(aPrsObject) + DeletePresentation(aPrsObject); + // is it Curve object ? + VISU::Curve_i* aCurveObject = dynamic_cast(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::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::GetServant(anObject).in()); + if ( aTable ) { + // table object + PlotTable(aTable, VISU::eDisplay ); + } + VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(anObject).in()); + if ( aContainer ) { + // container object + PlotContainer(aContainer, VISU::eDisplay ); + } + VISU::Curve_i* aCurve = dynamic_cast(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(aVFrame)){ + QList 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 */ diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index aa78fe34..bcefa28a 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -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(); diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index 1607524c..5097767f 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -31,6 +31,7 @@ #include "QAD_Study.h" #include "VISU_CutLines_i.hh" +#include "VISU_Result_i.hh" #include #include @@ -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); } //------------------------------------------------------------- diff --git a/src/VISU_I/VISU_Table_i.hh b/src/VISU_I/VISU_Table_i.hh index 136ce6ac..1d00478b 100644 --- a/src/VISU_I/VISU_Table_i.hh +++ b/src/VISU_I/VISU_Table_i.hh @@ -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); -- 2.39.2