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;
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);
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();
}
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:
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);
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");
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
*/
#include "QAD_Study.h"
#include "VISU_CutLines_i.hh"
+#include "VISU_Result_i.hh"
#include <memory>
#include <fstream>
return "";
}
+void VISU::Table_i::RemoveFromStudy(){
+ VISU::RemoveFromStudy(mySObj,false);
+}
+
//----------------------------------------------------------------
// Curve Object
//----------------------------------------------------------------
return NULL;
}
+void VISU::Curve_i::RemoveFromStudy(){
+ VISU::RemoveFromStudy(mySObj,false);
+}
+
//----------------------------------------------------------------
// Container Object
//----------------------------------------------------------------
"",
aComment.latin1(),
true );
+ mySObj = SALOMEDS::SObject::_duplicate(myStudy->FindObjectID(anEntry.c_str()));
}
return this;
}
/*!
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 );
{
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);
}
//-------------------------------------------------------------