#include "VISU_PrsObject_i.hh"
#include "VISU_Result_i.hh"
+#include "VISU_Gen_i.hh"
#include "VISU_Prs3d_i.hh"
#include "VISU_Mesh_i.hh"
#include "VISU_ScalarBarActor.hxx"
#include "VISU_Actor.h"
+#include "SALOME_Event.hxx"
+
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Tools.h"
#include "QAD_Study.h"
+#include "QAD_LeftFrame.h"
#include "QAD_RightFrame.h"
#include "QAD_StudyFrame.h"
+#include "QAD_PyEditor.h"
#include "VTKViewer_ViewFrame.h"
+#include "VTKViewer_RenderWindow.h"
#include "SALOMEGUI_TableDlg.h"
#include "Plot2d_CurveContainer.h"
#include "Plot2d_ViewFrame.h"
#include <qstring.h>
#include <qfileinfo.h>
-#include <vtkTransformPolyDataFilter.h>
-#include <vtkDataSetMapper.h>
#include <vtkRenderer.h>
#include <vtkCamera.h>
#endif
static QFileInfo aFileInfo;
-static int MYDELAY = 1;
namespace VISU{
//===========================================================================
+ typedef TVoidMemFunEvent<QAD_StudyFrame> TFrameActionEvent;
+
+ template<class TObject>
+ class TSetBackgroundEvent: public SALOME_Event{
+ TObject* myView;
+ const SALOMEDS::Color& myColor;
+ public:
+ TSetBackgroundEvent(TObject* theView, const SALOMEDS::Color& theColor):
+ myView(theView), myColor(theColor)
+ {}
+ virtual void Execute(){
+ int aColor[3];
+ aColor[0] = int(255.0*myColor.R);
+ aColor[1] = int(255.0*myColor.G);
+ aColor[2] = int(255.0*myColor.B);
+ QColor aNewColor(aColor[0],aColor[1],aColor[2]);
+ myView->setBackgroundColor(aNewColor);
+ }
+ };
+
+ class TSetViewRepresentation: public SALOME_Event{
+ VISU::View::ViewRepresentation myViewRepr;
+ View_i* myView;
+ CORBA::Boolean myState;
+ public:
+ TSetViewRepresentation( View_i* aView,
+ VISU::View::ViewRepresentation ViewRepr,
+ CORBA::Boolean State ):
+ SALOME_Event(), myViewRepr( ViewRepr ), myView( aView ), myState( State )
+ {}
+ virtual void Execute(){
+
+ bool old = myView->IsPartShown( myViewRepr );
+
+ QAD_RightFrame* fr = myView->myStudyFrame->getRightFrame();
+
+ if( myView->myStudyFrame != NULL ){
+ switch( myViewRepr )
+ {
+ case VISU::View::OBJECTBROWSER:
+ if( myState!=old )
+ if( myState )
+ myView->myStudyFrame->unCompressLeft();
+ else
+ myView->myStudyFrame->compressLeft();
+ break;
+ case VISU::View::VIEWER:
+ if( myState!=old )
+ if( myState )
+ fr->unCompressUp();
+ else
+ fr->compressUp();
+ break;
+ case VISU::View::PYTHON:
+ if( myState!=old )
+ if( myState )
+ fr->unCompressLeft();
+ else
+ fr->compressLeft();
+ break;
+ case VISU::View::MESSAGES:
+ if( myState!=old )
+ if( myState )
+ fr->unCompressRight();
+ else
+ fr->compressRight();
+ break;
+ };
+ }
+ }
+};
+
+ class TGetViewRepresentation: public SALOME_Event
+ {
+ public:
+ typedef CORBA::Boolean TResult;
+ TResult myResult;
+ VISU::View::ViewRepresentation myPart;
+ View_i* myView;
+
+ TGetViewRepresentation( View_i* aView, VISU::View::ViewRepresentation Part ):
+ SALOME_Event(), myResult( false ), myPart( Part ), myView( aView )
+ {
+ }
+ virtual void Execute(){
+ switch( myPart )
+ {
+ case VISU::View::OBJECTBROWSER:
+ myResult = !myView->myStudyFrame->isCompressedLeft();
+ break;
+ case VISU::View::VIEWER:
+ myResult = !myView->myStudyFrame->getRightFrame()->isCompressedViewFrame();
+ break;
+ case VISU::View::PYTHON:
+ myResult = !myView->myStudyFrame->getRightFrame()->isCompressedPython();
+ break;
+ case VISU::View::MESSAGES:
+ myResult = !myView->myStudyFrame->getRightFrame()->isCompressedMessage();
+ }
+ }
+ };
+
+ class TSetViewWidthHeight: public SALOME_Event{
+ CORBA::Long mySize;
+ bool myIsWidth;
+ View_i* myView;
+ public:
+ TSetViewWidthHeight( View_i* aView, CORBA::Long Size, bool IsWidth ):
+ SALOME_Event(), mySize( Size ), myView( aView ), myIsWidth( IsWidth )
+ {}
+ virtual void Execute(){
+ if( myView->myStudyFrame != NULL ){
+ QWidget* aStudyParent = myView->myStudyFrame->parentWidget(true);
+ int aleft = aStudyParent->frameGeometry().left();
+ int atop = aStudyParent->frameGeometry().top();
+ int aheight = aStudyParent->frameGeometry().height();
+ int awidth = aStudyParent->frameGeometry().width();
+ QRect aQRect;
+ if( myIsWidth )
+ aQRect = QRect( aleft, atop, mySize, aheight );
+ else
+ aQRect = QRect( aleft, atop, awidth, mySize );
+
+ aStudyParent->setGeometry(aQRect);
+ }
+ }
+ };
+
+ class TGetViewWidthHeight: public SALOME_Event{
+ public:
+ typedef CORBA::Long TResult;
+ TResult myResult;
+ bool myIsWidth;
+ View_i* myView;
+ public:
+ TGetViewWidthHeight( View_i* aView, bool IsWidth ):
+ SALOME_Event(), myView( aView ), myIsWidth( IsWidth )
+ {}
+
+ virtual void Execute()
+ {
+ if( myView ) {
+ QWidget* aStudyParent = myView->myStudyFrame->parentWidget(true);
+ if( myIsWidth )
+ myResult = aStudyParent->frameGeometry().width();
+ else
+ myResult = aStudyParent->frameGeometry().height();
+ }
+ }
+ };
+
+ class TSetViewPositionHorizontal: public SALOME_Event{
+ VISU::View::ViewPosition myViewPos;
+ View_i* myView;
+ public:
+ TSetViewPositionHorizontal ( View_i* aView,
+ VISU::View::ViewPosition ViewPos ):
+ SALOME_Event(), myView( aView ), myViewPos(ViewPos)
+ {}
+ virtual void Execute(){
+ QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
+ QWidget* aStudy = dynamic_cast <QWidget*> (myView->myStudyFrame);
+ QWidget* aStudyParent = aStudy->parentWidget(true);
+ if ( aStudyParent != 0 )
+ if ( aWorkspace!=NULL || aStudy != NULL )
+ switch(myViewPos){
+ case VISU::View::LEFT:
+ QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignLeft);
+ break;
+ case VISU::View::CENTER:
+ QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignHCenter);
+ break;
+ case VISU::View::RIGHT:
+ QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignRight);
+ break;
+ }
+ }
+ };
+
+ class TSetViewPositionVertical: public SALOME_Event{
+ VISU::View::ViewPosition myViewPos;
+ View_i* myView;
+ public:
+ TSetViewPositionVertical ( View_i* aView,
+ VISU::View::ViewPosition ViewPos ):
+ SALOME_Event(), myView( aView ), myViewPos(ViewPos)
+ {}
+ virtual void Execute(){
+ QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
+ QWidget* aStudy = dynamic_cast <QWidget*>(myView->myStudyFrame);
+ QWidget* aStudyParent = aStudy->parentWidget(true);
+ if ( aStudyParent != 0 )
+ if ( aWorkspace!=NULL || aStudy != NULL )
+ switch(myViewPos){
+ case VISU::View::TOP:
+ QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignTop);
+ break;
+ case VISU::View::CENTER:
+ QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignVCenter);
+ break;
+ case VISU::View::BOTTOM:
+ QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignBottom);
+ break;
+ }
+ }
+ };
+
+ class TSetRelativePosition : public SALOME_Event
+ {
+ View_i* myView;
+ CORBA::Double myX, myY;
+ public:
+ TSetRelativePosition ( View_i* aView, CORBA::Double X, CORBA::Double Y ):
+ SALOME_Event(), myView( aView ), myX( X ), myY( Y )
+ {}
+ virtual void Execute(){
+ QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
+ if( aWorkspace )
+ {
+ QAD_StudyFrame* aFrame = myView->myStudyFrame;
+ QWidget* aStudyParent = aFrame->parentWidget(true);
+ aStudyParent->move( int( myX * aWorkspace->width() ), int( myY * aWorkspace->height() ) );
+ }
+ }
+ };
+
+ class TSetRelativeSize : public SALOME_Event
+ {
+ View_i* myView;
+ CORBA::Double myX, myY;
+ public:
+ TSetRelativeSize ( View_i* aView, CORBA::Double X, CORBA::Double Y ):
+ SALOME_Event(), myView( aView ), myX( X ), myY( Y )
+ {}
+ virtual void Execute(){
+ QWidget* aWorkspace = dynamic_cast <QWidget*> (myView->myStudy->getApp()->getDesktop()->getMainFrame());
+ if( aWorkspace )
+ {
+ QAD_StudyFrame* aFrame = myView->myStudyFrame;
+ QWidget* aStudyParent = aFrame->parentWidget(true);
+ aStudyParent->setGeometry( aStudyParent->x(), aStudyParent->y(),
+ int( myX * aWorkspace->width() ), int( myY * aWorkspace->height() ) );
+ }
+ }
+ };
+
+
+
+ class TSavePictureEvent: public SALOME_Event{
+ QWidget* myWidget;
+ const char* myFileName;
+ public:
+ typedef CORBA::Boolean TResult;
+ TResult myResult;
+ TSavePictureEvent(QWidget* theWidget, const char* theFileName):
+ myWidget(theWidget),
+ myFileName(theFileName),
+ myResult(false)
+ {}
+ virtual void Execute(){
+ if(myWidget){
+ QPixmap px = QPixmap::grabWindow(myWidget->winId());
+ if (!QString(myFileName).isNull()) {
+ QString fmt = QAD_Tools::getFileExtensionFromPath(myFileName).upper();
+ if (fmt.isEmpty())
+ fmt = QString("BMP"); // default format
+ if (fmt == "JPG")
+ fmt = "JPEG";
+ myResult = px.save(myFileName, fmt.latin1());
+ }
+ }
+ }
+ };
+
+
+ void RepaintView(QAD_StudyFrame* theStudyFrame);
+ class TRepaintViewEvent: public SALOME_Event{
+ QAD_StudyFrame* myStudyFrame;
+ public:
+ TRepaintViewEvent(QAD_StudyFrame* theStudyFrame):
+ myStudyFrame(theStudyFrame)
+ {}
+ virtual void Execute(){
+ RepaintView(myStudyFrame);
+ }
+ };
+
+
VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame){
return dynamic_cast<VTKViewer_ViewFrame*>(theStudyFrame->getRightFrame()->getViewFrame());
}
vtkCamera* GetCamera(QAD_StudyFrame* theStudyFrame){
return GetRenderer(theStudyFrame)->GetActiveCamera();
}
- void RepaintView(QAD_StudyFrame* theStudyFrame){
- GetRenderer(theStudyFrame)->ResetCameraClippingRange();
- GetViewFrame(theStudyFrame)->getRW()->getRenderWindow()->Render();
+
+
+ void RepaintView(VTKViewer_ViewFrame* theViewFrame){
+ theViewFrame->getRenderer()->ResetCameraClippingRange();
+ theViewFrame->getRW()->getRenderWindow()->Render();
//GetViewFrame(theStudyFrame)->Repaint();
}
+
+ void RepaintView(QAD_StudyFrame* theStudyFrame){
+ RepaintView(GetViewFrame(theStudyFrame));
+ }
+
+
VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){
VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame);
if (!vf) return NULL;
anVISUActor = thePrs->CreateActor();
vf->AddActor(anVISUActor);
}catch(std::runtime_error& exc){
- INFOS("Null actor is created");
+ INFOS(exc.what());
return NULL;
}
}
for ( int i = 0; i < clist.count(); i++ ) {
if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - "<<clist.at( i ) );
- clist.at( i )->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
- clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
- clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
- clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
- /* - DATA NOT UPDATED */
- if ( !clist.at( i )->isAutoAssign() ) {
+ clist.at( i )->setHorTitle( theCurve->GetHorTitle().c_str() );
+ clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() );
+ clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() );
+ clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() );
+ double* xList = 0;
+ double* yList = 0;
+ int nbPoints = theCurve->GetData( xList, yList );
+ if ( nbPoints > 0 && xList && yList ) {
+ clist.at( i )->setData( xList, yList, nbPoints );
+ }
+ if ( !theCurve->IsAuto() ) {
clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
SALOMEDS::Color color = theCurve->GetColor();
clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
- clist.at( i )->setAutoAssign( theCurve->IsAuto() );
}
+ clist.at( i )->setAutoAssign( theCurve->IsAuto() );
theView->displayCurve( clist.at( i ) );
bFound = true;
}
if ( !bFound ) {
Plot2d_Curve* crv = theCurve->CreatePresentation();
if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
- if ( crv )
+ if ( crv ) {
theView->displayCurve( crv );
+ theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
+ theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
+ SALOMEDS::Color newColor;
+ newColor.R = crv->getColor().red()/255.;
+ newColor.G = crv->getColor().green()/255.;
+ newColor.B = crv->getColor().blue()/255.;
+ theCurve->SetColor( newColor );
+ crv->setAutoAssign( theCurve->IsAuto() );
+ }
}
}
else if ( theDisplaying == eDisplayOnly ) {
for ( int i = 0; i < clist.count(); i++ ) {
if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - "<<clist.at( i ) );
- clist.at( i )->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
- clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
- clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
- clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
- /* - DATA NOT UPDATED */
- if ( !clist.at( i )->isAutoAssign() ) {
+ clist.at( i )->setHorTitle( theCurve->GetHorTitle().c_str() );
+ clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() );
+ clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() );
+ clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() );
+ double* xList = 0;
+ double* yList = 0;
+ int nbPoints = theCurve->GetData( xList, yList );
+ if ( nbPoints > 0 && xList && yList ) {
+ clist.at( i )->setData( xList, yList, nbPoints );
+ }
+ if ( !theCurve->IsAuto() ) {
clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
SALOMEDS::Color color = theCurve->GetColor();
clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
- clist.at( i )->setAutoAssign( theCurve->IsAuto() );
}
+ clist.at( i )->setAutoAssign( theCurve->IsAuto() );
theView->displayCurve( clist.at( i ) );
bFound = true;
}
if ( !bFound ) {
Plot2d_Curve* crv = theCurve->CreatePresentation();
if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - "<<crv );
- if ( crv )
+ if ( crv ) {
theView->displayCurve( crv );
+ theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
+ theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
+ SALOMEDS::Color newColor;
+ newColor.R = crv->getColor().red()/255.;
+ newColor.G = crv->getColor().green()/255.;
+ newColor.B = crv->getColor().blue()/255.;
+ theCurve->SetColor( newColor );
+ crv->setAutoAssign( theCurve->IsAuto() );
+ }
}
}
}
- //===========================================================================
- /*
- #include <qthread.h>
- class TViewManager: public QThread{
- public:
- TViewManager(SALOMEDS::Study_ptr theStudy) : myStudyDocument(theStudy) {};
- virtual void run(){
- qApp->lock();
- QAD_Desktop* aDesktop = QAD_Application::getDesktop();
- QAD_Study* aStudy = aDesktop->findStudy(myStudyDocument);
- if(!aStudy){
- CORBA::String_var aName = myStudyDocument->Name();
- aFileInfo.setFile(aName.in());
+
+ QAD_Study* CheckStudy( SALOMEDS::Study_ptr theStudy ) {
+ QAD_Desktop* aDesktop = QAD_Application::getDesktop();
+ QAD_Study* aStudy = aDesktop->findStudy(theStudy);
+ if(!aStudy){
+ CORBA::String_var aName = theStudy->Name();
+ aFileInfo.setFile(aName.in());
+ if (aFileInfo.exists())
aStudy = aDesktop->loadStudy(aFileInfo.baseName());
+ else
+ aStudy = aDesktop->loadStudy(aName.in());
+ if (!aStudy) {
+ MESSAGE("CheckStudy()::ERROR: Can't load study");
}
- qApp->unlock();
}
- SALOMEDS::Study_ptr myStudyDocument;
- };
- */
+ return aStudy;
+ }
+ //===========================================================================
ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy) {
if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i");
- Mutex mt(myMutex,qApp,MYDELAY);
myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
- //TViewManager* aTViewManager = new TViewManager(theStudy);
- //aTViewManager->start();
- QAD_Desktop* aDesktop = QAD_Application::getDesktop();
- QAD_Study* aStudy = aDesktop->findStudy(theStudy);
- if(!aStudy){
- CORBA::String_var aName = theStudy->Name();
- aFileInfo.setFile(aName.in());
- aStudy = aDesktop->loadStudy(aFileInfo.baseName());
- if (!aStudy)
- MESSAGE("ViewManager_i::ERROR: Can't load study");
- }
}
- VISU::View3D_ptr ViewManager_i::Create3DView(){
- Mutex mt(myMutex,qApp,MYDELAY);
- if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
- VISU::View3D_i* pView = new View3D_i(myStudyDocument);
- if(pView->Create(1) != NULL)
- return VISU::View3D::_duplicate(pView->_this());
- return VISU::View3D::_nil();
+ class TGetCurrentViewEvent: public SALOME_Event{
+ SALOMEDS::Study_ptr myStudyDocument;
+ public:
+ TGetCurrentViewEvent( SALOMEDS::Study_ptr theStudy):
+ myStudyDocument(theStudy),
+ myResult(VISU::View::_nil())
+ {}
+ virtual void Execute(){
+ if(QAD_Study* aStudy = QAD_Application::getDesktop()->findStudy( myStudyDocument )){
+ if ( QAD_StudyFrame* aStudyFrame = aStudy->getActiveStudyFrame() ) {
+ if(MYDEBUG)
+ MESSAGE("GetCurrentView::Execute - TypeView = "<<aStudyFrame->getTypeView());
+ if ( aStudyFrame->getTypeView() == VIEW_VTK ) {
+ VISU::View3D_i* pView = new View3D_i(myStudyDocument);
+ if(pView->Create(0))
+ myResult = pView->_this();
+ } else if ( aStudyFrame->getTypeView() == VIEW_PLOT2D ) {
+ VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
+ if(pView->Create(0))
+ myResult = pView->_this();
+ }
+ }
+ }
+ }
+ typedef VISU::View_ptr TResult;
+ TResult myResult;
+ };
+
+ VISU::View_ptr ViewManager_i::GetCurrentView(){
+ return ProcessEvent(new TGetCurrentViewEvent( myStudyDocument ));
}
+
+
+ class TCreateViewEvent: public SALOME_Event{
+ public:
+ TCreateViewEvent( SALOMEDS::Study_ptr theStudy):
+ myStudyDocument(theStudy)
+ {};
+ protected:
+ SALOMEDS::Study_ptr myStudyDocument;
+ };
- VISU::View_ptr ViewManager_i::GetCurrentView(){
- Mutex mt(myMutex,qApp,MYDELAY);
- QAD_Study* Study = QAD_Application::getDesktop()->findStudy( myStudyDocument );
- if(MYDEBUG) MESSAGE("ViewManager_i::GetCurrent3DView - Study = "<<Study);
- QAD_StudyFrame* StudyFrame;
- if ( Study && ( StudyFrame = Study->getActiveStudyFrame() ) ) {
- if(MYDEBUG)
- MESSAGE("ViewManager_i::GetCurrent3DView - TypeView = "<<StudyFrame->getTypeView());
- if ( StudyFrame->getTypeView() == VIEW_VTK ) {
- VISU::View3D_i* pView = new View3D_i(myStudyDocument);
- if(pView->Create(0) != NULL)
- return VISU::View3D::_duplicate(pView->_this());
- }
- else if ( StudyFrame->getTypeView() == VIEW_PLOT2D ) {
- VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
- if(pView->Create(0) != NULL)
- return VISU::XYPlot::_duplicate(pView->_this());
+ template<class TViewFrame>
+ class TCreateViewFrameEvent: public TCreateViewEvent{
+ public:
+ typedef typename TViewFrame::TInterface TInterface;
+ typedef typename TInterface::_ptr_type TResult;
+ TResult myResult;
+ TCreateViewFrameEvent(SALOMEDS::Study_ptr theStudy):
+ TCreateViewEvent(theStudy),
+ myResult(TInterface::_nil())
+ {}
+ virtual void Execute(){
+ if(CheckStudy(myStudyDocument)){
+ TViewFrame* pView = new TViewFrame(myStudyDocument);
+ if(pView->Create(1))
+ myResult = pView->_this();
}
}
- return VISU::View::_nil();
- }
+ };
+
+ VISU::View3D_ptr ViewManager_i::Create3DView(){
+ if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
+ return ProcessEvent(new TCreateViewFrameEvent<VISU::View3D_i>(myStudyDocument));
+ }
+
VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){
if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
- Mutex mt(myMutex,qApp,MYDELAY);
- VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
- if(pView->Create(1) != NULL)
- return VISU::XYPlot::_duplicate(pView->_this());
- return VISU::XYPlot::_nil();
+ return ProcessEvent(new TCreateViewFrameEvent<VISU::XYPlot_i>(myStudyDocument));
}
+ class TCreateTableViewEvent: public TCreateViewEvent{
+ Table_ptr myTable;
+ public:
+ TCreateTableViewEvent(SALOMEDS::Study_ptr theStudy,
+ Table_ptr theTable):
+ TCreateViewEvent(theStudy),
+ myTable(theTable),
+ myResult(VISU::TableView::_nil())
+ {}
+ virtual void Execute(){
+ if ( CheckStudy( myStudyDocument ) ) {
+ VISU::TableView_i* pView = new TableView_i(myStudyDocument);
+ if(pView->Create(myTable) != NULL)
+ myResult = pView->_this();
+ }
+ }
+ typedef VISU::TableView_ptr TResult;
+ TResult myResult;
+ };
+
VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){
if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
- Mutex mt(myMutex,qApp,MYDELAY);
- VISU::TableView_i* pView = new TableView_i(myStudyDocument);
- if(pView->Create(VISU::Table::_duplicate(theTable)) != NULL)
- return VISU::TableView::_duplicate(pView->_this());
- return VISU::TableView::_nil();
+ return ProcessEvent(new TCreateTableViewEvent(myStudyDocument,theTable));
}
void ViewManager_i::Destroy(View_ptr theView){
- if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<<theView->_is_nil());
- if(theView->_is_nil()) return;
- CORBA::Object_var aView = VISU::View::_narrow(theView);
- if(!CORBA::is_nil(aView)){
- if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - VISU::View"<<(!CORBA::is_nil(aView)));
- VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(aView));
- if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - dynamic_cast"<<pView);
- if(pView) {
- pView->Close();
- pView->_remove_ref();
+ class TEvent: public SALOME_Event{
+ View_ptr myView;
+ public:
+ TEvent(View_ptr theView):
+ myView(theView)
+ {}
+ virtual void Execute(){
+ if(!CORBA::is_nil(myView)){
+ if(VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(myView).in())) {
+ pView->Close();
+ pView->_remove_ref();
+ }
+ }
}
- //if(pView) delete pView;
- return;
- }
- }
-
-
- void ViewManager_i::ProcessEvents() {
- while (true) {
- qApp->lock();
- qApp->syncX();
- qApp->flushX();
- qApp->processEvents();
- qApp->unlock();
- //sleep(1);
- }
+ };
+ if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<<theView->_is_nil());
+ ProcessVoidEvent(new TEvent(theView));
}
//===========================================================================
View_i::View_i(SALOMEDS::Study_ptr theStudy) {
+ myStudyFrame = NULL;
if(MYDEBUG) MESSAGE("View_i::View_i");
CORBA::String_var aName = theStudy->Name();
- QAD_Desktop* aDesktop = QAD_Application::getDesktop();
- myStudy = aDesktop->findStudy(theStudy);
- if(!myStudy){
- aFileInfo.setFile(aName.in());
- myStudy = aDesktop->loadStudy(aFileInfo.baseName());
- }
+ myStudy = CheckStudy(theStudy);
if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<<myStudy<<"; aName = "<<aName.in());
}
const char* View_i::GetComment() const { return "";}
void View_i::ToStream(std::ostringstream& theStr) {}
- const char* View_i::GetEntry(){
+ string View_i::GetEntry(){
SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectIOR(GetID());
CORBA::String_var anEntry = aSObject->GetID();
- string aString(anEntry);
- if(MYDEBUG) MESSAGE("Result_i::GetEntry - "<<aString);
- return aString.c_str();
+ return string(anEntry.in());
}
+
+
//===========================================================================
XYPlot_i::XYPlot_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {
if(MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
}
+
Storable* XYPlot_i::Create(int theNew){
- if(MYDEBUG) MESSAGE("XYPlot_i::Create");
- Mutex mt(myMutex,qApp,MYDELAY);
if(theNew)
myStudyFrame = myStudy->newWindow3d("",VIEW_PLOT2D);
else
myStudyFrame = myStudy->getActiveStudyFrame();
myView = dynamic_cast<Plot2d_ViewFrame*>(myStudyFrame->getRightFrame()->getViewFrame());
- Update();
+ myView->Repaint();
return this;
}
+
+
void XYPlot_i::Update() {
- if(MYDEBUG) MESSAGE("XYPlot_i::Update");
- Mutex mt(myMutex,qApp,MYDELAY);
- myName = (const char*)(myStudyFrame->title());
- myView->Repaint();
+ ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
}
+
+
void XYPlot_i::Close(){
- if(MYDEBUG) MESSAGE("XYPlot_i::Close");
- Mutex mt(myMutex,qApp,MYDELAY);
myStudyFrame->close();
}
+
XYPlot_i::~XYPlot_i() {
if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i");
- Mutex mt(myMutex,qApp,MYDELAY);
- myStudyFrame->close();
}
+
+
void XYPlot_i::SetTitle(const char* theTitle){
- if(MYDEBUG) MESSAGE("XYPlot_i::SetTitle");
- Mutex mt(myMutex,qApp,MYDELAY);
- myName = theTitle;
- myStudyFrame->setCaption(myName.c_str());
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<QAD_StudyFrame,const QString&,QString>
+ (myStudyFrame,&QAD_StudyFrame::setCaption,QString(theTitle)));
}
char* XYPlot_i::GetTitle() {
- if(MYDEBUG) MESSAGE("XYPlot_i::GetTitle");
- Mutex mt(myMutex,qApp);
- myName = (const char*)(myStudyFrame->title());
- return CORBA::string_dup(myName.c_str());
+ return CORBA::string_dup(myStudyFrame->title().latin1());
}
+
void XYPlot_i::SetSubTitle(const char* theTitle){
- if(MYDEBUG) MESSAGE("XYPlot_i::SetSubTitle");
- Mutex mt(myMutex,qApp,MYDELAY);
- myView->setTitle(theTitle);
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<Plot2d_ViewFrame,const QString&,QString>
+ (myView,&Plot2d_ViewFrame::setTitle,QString(theTitle)));
}
char* XYPlot_i::GetSubTitle() {
- if(MYDEBUG) MESSAGE("XYPlot_i::GetSubTitle");
- Mutex mt(myMutex,qApp,MYDELAY);
return CORBA::string_dup(myView->getTitle());
}
+
void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){
- if(MYDEBUG) MESSAGE("XYPlot_i::SetCurveType");
- Mutex mt(myMutex,qApp,MYDELAY);
- myView->setCurveType(theType);
+ ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
+ (myView,&Plot2d_ViewFrame::setCurveType,theType,true));
}
VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){
- if(MYDEBUG) MESSAGE("XYPlot_i::GetCurveType");
- Mutex mt(myMutex,qApp);
return (VISU::XYPlot::CurveType)myView->getCurveType();
}
+
void XYPlot_i::SetMarkerSize(CORBA::Long theSize){
- if(MYDEBUG) MESSAGE("XYPlot_i::SetMarkerSize");
- Mutex mt(myMutex,qApp,MYDELAY);
- myView->setMarkerSize(theSize);
+ ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,int,bool>
+ (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true));
}
CORBA::Long XYPlot_i::GetMarkerSize(){
- if(MYDEBUG) MESSAGE("XYPlot_i::GetMarkerSize");
- Mutex mt(myMutex,qApp);
return myView->getMarkerSize();
}
+
+ class TEnbleGridEvent: public SALOME_Event{
+ public:
+ typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool = true);
+ TEnbleGridEvent(Plot2d_ViewFrame* theView, TFun theFun,
+ CORBA::Boolean theMajor, CORBA::Long theNumMajor,
+ CORBA::Boolean theMinor, CORBA::Long theNumMinor):
+ myView(theView), myFun(theFun),
+ myMajor(theMajor), myNumMajor(theNumMajor),
+ myMinor(theMinor), myNumMinor(theNumMinor)
+ {}
+ virtual void Execute(){
+ (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor);
+ }
+ protected:
+ Plot2d_ViewFrame* myView;
+ TFun myFun;
+ CORBA::Boolean myMajor, myNumMajor;
+ CORBA::Boolean myMinor, myNumMinor;
+ };
+
+
void XYPlot_i::EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
- CORBA::Boolean theMinor, CORBA::Long theNumMinor){
- if(MYDEBUG) MESSAGE("XYPlot_i::EnableXGrid");
- Mutex mt(myMutex,qApp,MYDELAY);
- myView->setXGrid(theMajor,theNumMajor,theMinor,theNumMinor);
+ CORBA::Boolean theMinor, CORBA::Long theNumMinor)
+ {
+ ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setXGrid,
+ theMajor,theNumMajor,theMinor,theNumMinor));
}
void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
- CORBA::Boolean theMinor, CORBA::Long theNumMinor){
- if(MYDEBUG) MESSAGE("XYPlot_i::EnableYGrid");
- Mutex mt(myMutex,qApp,MYDELAY);
- myView->setYGrid(theMajor,theNumMajor,theMinor,theNumMinor);
+ CORBA::Boolean theMinor, CORBA::Long theNumMinor)
+ {
+ ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setYGrid,
+ theMajor,theNumMajor,theMinor,theNumMinor));
}
+
+ class TSetScaleModeEvent: public SALOME_Event{
+ public:
+ typedef void (Plot2d_ViewFrame::* TFun)(const int, bool = true);
+ TSetScaleModeEvent(Plot2d_ViewFrame* theView, TFun theFun, int theScaling):
+ myView(theView), myFun(theFun), myScaling(theScaling)
+ {}
+ virtual void Execute(){
+ (myView->*myFun)(myScaling);
+ }
+ protected:
+ Plot2d_ViewFrame* myView;
+ TFun myFun;
+ int myScaling;
+ };
+
+
void XYPlot_i::SetHorScaling(VISU::Scaling theScaling){
- if(MYDEBUG) MESSAGE("XYPlot_i::SetHorScaling");
- Mutex mt(myMutex,qApp,MYDELAY);
- if(theScaling == VISU::LOGARITHMIC)
- myView->setHorScaleMode(1);
- else
- myView->setHorScaleMode(0);
+ ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode,
+ theScaling == VISU::LOGARITHMIC));
}
VISU::Scaling XYPlot_i::GetHorScaling(){
- if(MYDEBUG) MESSAGE("XYPlot_i::GetHorScaling");
- Mutex mt(myMutex,qApp,MYDELAY);
return (VISU::Scaling)myView->getHorScaleMode();
}
+
void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){
- if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling");
- Mutex mt(myMutex,qApp,MYDELAY);
- if(theScaling == VISU::LOGARITHMIC)
- myView->setVerScaleMode(1);
- else
- myView->setVerScaleMode(0);
+ ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
+ theScaling == VISU::LOGARITHMIC));
}
VISU::Scaling XYPlot_i::GetVerScaling(){
- if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling");
- Mutex mt(myMutex,qApp);
return (VISU::Scaling)myView->getVerScaleMode();
}
+
+ class TSetTitleEvent: public SALOME_Event{
+ public:
+ typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, bool = true);
+ TSetTitleEvent(Plot2d_ViewFrame* theView, TFun theFun, const char* theTitle):
+ myView(theView), myFun(theFun), myTitle(theTitle)
+ {}
+ virtual void Execute(){
+ (myView->*myFun)(true,myTitle);
+ }
+ protected:
+ Plot2d_ViewFrame* myView;
+ TFun myFun;
+ const char* myTitle;
+ };
+
+
void XYPlot_i::SetXTitle(const char* theTitle){
- if(MYDEBUG) MESSAGE("XYPlot_i::SetXTitle");
- Mutex mt(myMutex,qApp,MYDELAY);
- myView->setXTitle(true,theTitle);
+ ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setXTitle,theTitle));
}
char* XYPlot_i::GetXTitle() {
- if(MYDEBUG) MESSAGE("XYPlot_i::GetXTitle");
- Mutex mt(myMutex,qApp);
return CORBA::string_dup(myView->getXTitle());
}
+
void XYPlot_i::SetYTitle(const char* theTitle){
- if(MYDEBUG) MESSAGE("XYPlot_i::SetYTitle");
- Mutex mt(myMutex,qApp,MYDELAY);
- myView->setYTitle(true,theTitle);
+ ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setYTitle,theTitle));
}
char* XYPlot_i::GetYTitle() {
- if(MYDEBUG) MESSAGE("XYPlot_i::GetYTitle");
- Mutex mt(myMutex,qApp);
return CORBA::string_dup(myView->getYTitle());
}
+
void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){
- if(MYDEBUG) MESSAGE("XYPlot_i::ShowLegend");
- Mutex mt(myMutex,qApp,MYDELAY);
- myView->showLegend(theShowing);
+ ProcessVoidEvent(new TVoidMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
+ (myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
}
+
void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){
- if(MYDEBUG) MESSAGE("XYPlot_i::SetBackground");
- Mutex mt(myMutex,qApp,MYDELAY);
- int aColor[3];
- aColor[0] = (int)(255.0*theColor.R);
- aColor[1] = (int)(255.0*theColor.G);
- aColor[2] = (int)(255.0*theColor.B);
- QColor aNewColor(aColor[0],aColor[1],aColor[2]);
- myView->setBackgroundColor(aNewColor);
+ ProcessVoidEvent(new TSetBackgroundEvent<Plot2d_ViewFrame>(myView,theColor));
}
SALOMEDS::Color XYPlot_i::GetBackground() {
- if(MYDEBUG) MESSAGE("XYPlot_i::GetBackground");
- Mutex mt(myMutex,qApp);
SALOMEDS::Color aColor;
aColor.R = myView->backgroundColor().red()/255.0;
aColor.G = myView->backgroundColor().green()/255.0;
aColor.B = myView->backgroundColor().blue()/255.0;
return aColor;
}
+
void XYPlot_i::Minimize() {
- if(MYDEBUG) MESSAGE("XYPlot_i::Minimize");
- Mutex mt(myMutex,qApp,MYDELAY);
- myStudyFrame->showMinimized();
+ ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized));
}
+
void XYPlot_i::Restore() {
- if(MYDEBUG) MESSAGE("XYPlot_i::Restore");
- Mutex mt(myMutex,qApp,MYDELAY);
- myStudyFrame->showNormal();
+ ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal));
}
+
void XYPlot_i::Maximize() {
- if(MYDEBUG) MESSAGE("XYPlot_i::Maximize");
- Mutex mt(myMutex,qApp,MYDELAY);
- myStudyFrame->showMaximized();
+ ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized));
}
- void XYPlot_i::Display(PrsObject_ptr thePrsObj) {
- if(MYDEBUG) MESSAGE("XYPlot_i::Display");
- Mutex mt(myMutex,qApp,MYDELAY);
- CORBA::Object_ptr anObj = thePrsObj;
- // is it Curve ?
- if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
- UpdatePlot2d(myView,eDisplay,aCurve);
- }
- // is it Container ?
- if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
- int nbCurves = aContainer->GetNbCurves();
- for ( int i = 1; i <= nbCurves; i++ ) {
- VISU::Curve_i* aCurve = aContainer->GetCurve( i );
- if ( aCurve && aCurve->IsValid() ) {
- UpdatePlot2d(myView,eDisplay,aCurve);
- }
+
+
+ class TXYPlotViewEvent: public SALOME_Event{
+ QAD_Study* myStudy;
+ Plot2d_ViewFrame* myView;
+ PrsObject_ptr myPrsObj;
+ int myDisplaing;
+ public:
+ TXYPlotViewEvent(QAD_Study* theStudy,
+ Plot2d_ViewFrame* theView,
+ PrsObject_ptr thePrsObj,
+ int theDisplaing):
+ myStudy(theStudy),
+ myView(theView),
+ myPrsObj(thePrsObj),
+ myDisplaing(theDisplaing)
+ {}
+ virtual void Execute(){
+ // is it Curve ?
+ if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
+ UpdatePlot2d(myView,myDisplaing,aCurve);
}
- myView->Repaint();
- }
- // is it Table ?
- if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
- SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
- if ( !TableSO->_is_nil() ) {
- SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
- for ( ; Iter->More(); Iter->Next() ) {
- CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
- if( !CORBA::is_nil( childObject ) ) {
- CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
- if( !CORBA::is_nil( aCurve ) )
- UpdatePlot2d(myView,eDisplay,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
+ // is it Container ?
+ if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
+ int nbCurves = aContainer->GetNbCurves();
+ for ( int i = 1; i <= nbCurves; i++ ) {
+ VISU::Curve_i* aCurve = aContainer->GetCurve( i );
+ if ( aCurve && aCurve->IsValid() ) {
+ UpdatePlot2d(myView,myDisplaing,aCurve);
}
}
myView->Repaint();
}
- }
- }
- void XYPlot_i::Erase(PrsObject_ptr thePrsObj) {
- if(MYDEBUG) MESSAGE("XYPlot_i::Erase");
- Mutex mt(myMutex,qApp,MYDELAY);
- CORBA::Object_ptr anObj = thePrsObj;
- // is it Curve ?
- if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
- UpdatePlot2d(myView,eErase,aCurve);
- }
- // is it Container ?
- if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
- int nbCurves = aContainer->GetNbCurves();
- for ( int i = 1; i <= nbCurves; i++ ) {
- VISU::Curve_i* aCurve = aContainer->GetCurve( i );
- if ( aCurve && aCurve->IsValid() ) {
- UpdatePlot2d(myView,eErase,aCurve);
- }
- }
- myView->Repaint();
- }
- // is it Table ?
- if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
- SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
- if ( !TableSO->_is_nil() ) {
- SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
+ // is it Table ?
+ if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
+ SALOMEDS::Study_var aStudy = myStudy->getStudyDocument();
+ SALOMEDS::SObject_var TableSO = aStudy->FindObjectID( aTable->GetEntry() );
+ if ( !TableSO->_is_nil() ) {
+ SALOMEDS::ChildIterator_var Iter = aStudy->NewChildIterator( TableSO );
for ( ; Iter->More(); Iter->Next() ) {
- CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
- if( !CORBA::is_nil( childObject ) ) {
- CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
- if( !CORBA::is_nil( aCurve ) )
- UpdatePlot2d(myView,eErase,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
+ CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
+ if( !CORBA::is_nil( childObject ) ) {
+ CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
+ if( !CORBA::is_nil( aCurve ) )
+ UpdatePlot2d(myView,myDisplaing,dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aCurve).in()));
+ }
}
+ myView->Repaint();
}
- myView->Repaint();
}
}
+ };
+
+
+ void XYPlot_i::Display(PrsObject_ptr thePrsObj) {
+ ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eDisplay));
}
- void XYPlot_i::EraseAll() {
- if(MYDEBUG) MESSAGE("XYPlot_i::EraseAll");
- Mutex mt(myMutex,qApp,MYDELAY);
- myView->EraseAll();
+
+
+ void XYPlot_i::Erase(PrsObject_ptr thePrsObj) {
+ ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eErase));
}
+
+
void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) {
- if(MYDEBUG) MESSAGE("XYPlot_i::DisplayOnly");
- Mutex mt(myMutex,qApp,MYDELAY);
- CORBA::Object_ptr anObj = thePrsObj;
- // is it Curve ?
- if(Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(anObj))) {
- UpdatePlot2d(myView,eDisplayOnly,aCurve);
- }
- // is it Container ?
- if(Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(anObj))) {
- int nbCurves = aContainer->GetNbCurves();
- for ( int i = 1; i <= nbCurves; i++ ) {
- VISU::Curve_i* aCurve = aContainer->GetCurve( i );
- if ( aCurve && aCurve->IsValid() ) {
- UpdatePlot2d(myView,eDisplayOnly,aCurve);
- }
- }
- myView->Repaint();
- }
- // is it Table ?
- if(Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(anObj))) {
- SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() );
- if ( !TableSO->_is_nil() ) {
- SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO );
- for ( ; Iter->More(); Iter->Next() ) {
- CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
- if( !CORBA::is_nil( childObject ) ) {
- CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
- if( !CORBA::is_nil( aCurve ) )
- UpdatePlot2d(myView,eDisplayOnly,dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) ));
- }
- }
- myView->Repaint();
- }
- }
+ ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eDisplayOnly));
+ }
+
+
+ void XYPlot_i::EraseAll() {
+ ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::EraseAll));
}
+
+
void XYPlot_i::FitAll() {
- if(MYDEBUG) MESSAGE("XYPlot_i::FitAll");
- Mutex mt(myMutex,qApp,MYDELAY);
- myView->fitAll();
+ ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::fitAll));
}
+
+
CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) {
- if(MYDEBUG) MESSAGE("XYPlot_i::SavePicture");
- Mutex mt(myMutex,qApp,MYDELAY);
- if (!myView->getViewWidget())
- return false;
-
- QApplication::setOverrideCursor( Qt::waitCursor );
- QPixmap px = QPixmap::grabWindow(myView->getViewWidget()->winId());
- QApplication::restoreOverrideCursor();
-
- if (!QString(theFileName).isNull()) {
- QApplication::setOverrideCursor( Qt::waitCursor );
- QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper();
- if (fmt.isEmpty())
- fmt = QString("BMP"); // default format
- if (fmt == "JPG")
- fmt = "JPEG";
- bool bOk = px.save(theFileName, fmt.latin1());
- QApplication::restoreOverrideCursor();
- return bOk;
- }
- return false;
+ return ProcessEvent(new TSavePictureEvent(myView->getViewWidget(),theFileName));
}
+
//===========================================================================
TableView_i::TableView_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {}
- Storable* TableView_i::Create(VISU::Table_var theTable){
+ Storable* TableView_i::Create(VISU::Table_ptr theTable){
if(MYDEBUG) MESSAGE("TableView_i::Create - "<<(!theTable->_is_nil()));
- Mutex mt(myMutex,qApp,MYDELAY);
if(!theTable->_is_nil()){
- VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable.in()));
+ VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
if(MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = "<<table);
if(table != NULL) {
SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectID(table->GetObjectEntry());
SALOMEGUI_TableDlg::ttAuto,
Qt::Vertical);
myView->show();
- myName = (myView->caption()).latin1();
return this;
}
}
}
return NULL;
}
+
+
+ TableView_i::~TableView_i() {
+ if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
+ delete myView;
+ }
+
+
void TableView_i::SetTitle(const char* theTitle){
- if(MYDEBUG) MESSAGE("TableView_i::SetTitle");
- Mutex mt(myMutex,qApp,MYDELAY);
- myName = theTitle;
- myView->setCaption(myName.c_str());
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<SALOMEGUI_TableDlg,const QString&,QString>
+ (myView,&SALOMEGUI_TableDlg::setCaption,QString(theTitle)));
}
+
+
char* TableView_i::GetTitle() {
- if(MYDEBUG) MESSAGE("TableView_i::GetTitle");
- Mutex mt(myMutex,qApp);
- myName = (myView->caption()).latin1();
- return CORBA::string_dup(myName.c_str());
+ return CORBA::string_dup(myView->caption().latin1());
}
+
+
void TableView_i::Close(){
- if(MYDEBUG) MESSAGE("TableView_i::Close");
- Mutex mt(myMutex,qApp,MYDELAY);
myView->close();
}
- TableView_i::~TableView_i() {
- if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
- Mutex mt(myMutex,qApp,MYDELAY);
- Close();
- delete myView;
- }
+
+
//===========================================================================
int View3D_i::myNbViewParams = 0;
const string View3D_i::myComment = "VIEW3D";
myStudyFrame = myStudy->newWindow3d("",VIEW_VTK);
else
myStudyFrame = myStudy->getActiveStudyFrame();
+ return this;
+ }
- //GetViewFrame(myStudyFrame)->GetScale(myScaleFactor);
-
- return this; //Build(false);
- }
-
-// Storable* View3D_i::Build(int theRestoring){
-// if(MYDEBUG) MESSAGE("View3D_i::Build");
-// if(theRestoring){
-// myStudyFrame->setTitle(myName.c_str());
-// SetBackground(myColor);
-// SetPointOfView(myPosition);
-// SetViewUp(myViewUp);
-// SetFocalPoint(myFocalPnt);
-// SetParallelScale(myParallelScale);
-// ScaleView(VISU::View3D::XAxis,myScaleFactor[0]);
-// ScaleView(VISU::View3D::YAxis,myScaleFactor[1]);
-// ScaleView(VISU::View3D::ZAxis,myScaleFactor[2]);
-// RepaintView(myStudyFrame);
-// }else{
-// Update();
-
-// SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(myStudyDocument);
-// CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID());
-// string anEntry = CreateAttributes(myStudyDocument,aSComponentEntry,"",anIOR,myName.c_str(),"",GetComment());
-
-// }
-// return this;
-// }
void View3D_i::Update(){
- if(MYDEBUG) MESSAGE("View3D_i::Update");
- Mutex mt(myMutex,qApp,MYDELAY);
- myName = (const char*)myStudyFrame->title();
-// myColor = GetBackground();
-// GetCamera(myStudyFrame)->GetPosition(myPosition);
-// GetCamera(myStudyFrame)->GetViewUp(myViewUp);
-// GetCamera(myStudyFrame)->GetFocalPoint(myFocalPnt);
-// myParallelScale = GetCamera(myStudyFrame)->GetParallelScale();
- //RepaintView(myStudyFrame);
-
- //GetViewFrame(myStudyFrame)->GetScale(myScaleFactor);
-
- VTKViewer_ViewFrame* vf = GetViewFrame(myStudyFrame);
- vtkRenderer* Renderer = vf->getRenderer();
- vtkActorCollection* theActors = Renderer->GetActors();
- theActors->InitTraversal();
- vtkActor *actor;
- while(actor = theActors->GetNextActor()){
- if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(actor)){
- VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d();
- if(anActor->GetVisibility() && aPrs3d){
- aPrs3d->Update();
- aPrs3d->UpdateActor(anActor);
+ class TEvent: public SALOME_Event{
+ QAD_StudyFrame* myStudyFrame;
+ public:
+ TEvent(QAD_StudyFrame* theStudyFrame):
+ myStudyFrame(theStudyFrame)
+ {}
+ virtual void Execute(){
+ VTKViewer_ViewFrame* vf = GetViewFrame(myStudyFrame);
+ vtkRenderer* Renderer = vf->getRenderer();
+ vtkActorCollection* theActors = Renderer->GetActors();
+ theActors->InitTraversal();
+ while(vtkActor *anAct = theActors->GetNextActor()){
+ if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)){
+ VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d();
+ if(anActor->GetVisibility() && aPrs3d){
+ aPrs3d->Update();
+ aPrs3d->UpdateActor(anActor);
+ }
+ }
}
+ RepaintView(myStudyFrame);
}
- }
+ };
+ ProcessVoidEvent(new TEvent(myStudyFrame));
}
+
CORBA::Boolean View3D_i::SavePicture(const char* theFileName) {
- if(MYDEBUG) MESSAGE("View3D_i::SavePicture");
- Mutex mt(myMutex,qApp,MYDELAY);
- if (!myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget())
- return false;
-
- QApplication::setOverrideCursor( Qt::waitCursor );
- QPixmap px = QPixmap::grabWindow(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget()->winId());
- QApplication::restoreOverrideCursor();
-
- if (!QString(theFileName).isNull()) {
- QApplication::setOverrideCursor( Qt::waitCursor );
- QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper();
- if (fmt.isEmpty())
- fmt = QString("BMP"); // default format
- if (fmt == "JPG")
- fmt = "JPEG";
- bool bOk = px.save(theFileName, fmt.latin1());
- QApplication::restoreOverrideCursor();
- return bOk;
- }
- return false;
+ return ProcessEvent(new TSavePictureEvent(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget(),theFileName));
}
- CORBA::Boolean View3D_i::SaveViewParams(const char* theName){
- if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint");
- Mutex mt(myMutex,qApp,MYDELAY);
+
+ bool View3D_i::SaveViewParams(QAD_StudyFrame* theStudyFrame, const char* theName){
+ QAD_Study* aStudy = theStudyFrame->getStudy();
+ SALOMEDS::Study_var aStudyDoc = aStudy->getStudyDocument();
if ( theName ) {
SALOMEDS::Study::ListOfSObject_var aList =
- myStudy->getStudyDocument()->FindObjectByName(theName,"VISU");
+ aStudyDoc->FindObjectByName(theName,"VISU");
SALOMEDS::GenericAttribute_var anAttr;
int iEnd = aList->length();
for(int i = 0; i < iEnd; i++){
SALOMEDS::SObject_var anObj = aList[i];
CORBA::String_var aString = anObj->GetID();
string anEntry(aString);
- if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - anEntry = "<<anEntry);
+ if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = "<<anEntry);
if(anObj->FindAttribute(anAttr, "AttributeComment")){
SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
aString = aCmnt->Value();
string aComm(aString);
if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = "<<aComm);
if(aComm.compare(View3D_i::myComment) >= 0){
- aCmnt->SetValue(ToString().c_str());
- return 1;
+ aCmnt->SetValue(ToString(theStudyFrame).c_str());
+ return true;
}
}
}
}
- QString newName;
- if ( theName )
- newName = QString( theName );
- else
- newName = QString( GenerateViewParamsName() );
- SALOMEDS::SComponent_var aSComponent =
- FindOrCreateVisuComponent(myStudy->getStudyDocument());
- CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID());
- string anEntry = CreateAttributes(myStudy->getStudyDocument(),aSComponentEntry,"","",newName.latin1(),"",ToString().c_str());
- return 1;
+ SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(aStudyDoc);
+ CORBA::String_var aSComponentEntry = aSComponent->GetID();
+ string anEntry = CreateAttributes(aStudyDoc,aSComponentEntry.in(),"","",theName,"",ToString(theStudyFrame).c_str());
+ return true;
+ }
+ CORBA::Boolean View3D_i::SaveViewParams(const char* theName){
+ return SaveViewParams(myStudyFrame,theName);
}
- CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){
- if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - "<<theName);
- Mutex mt(myMutex,qApp,MYDELAY);
+
+ bool View3D_i::RestoreViewParams(QAD_StudyFrame* theStudyFrame, const char* theName){
SALOMEDS::Study::ListOfSObject_var aList =
- myStudy->getStudyDocument()->FindObjectByName(theName,"VISU");
+ theStudyFrame->getStudy()->getStudyDocument()->FindObjectByName(theName,"VISU");
SALOMEDS::GenericAttribute_var anAttr;
int iEnd = aList->length();
if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = "<<iEnd);
Storable::StrToMap(strIn,aMap);
if ( Storable::FindValue( aMap,"myComment").compare( View3D_i::myComment.c_str() ) >= 0 ) {
if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = "<<strIn);
- return Restore( aMap ) != NULL;
+ Restore(theStudyFrame,aMap);
+ return true;
}
}
}
- return 0;
+ return false;
}
- Storable* View3D_i::Restore(const Storable::TRestoringMap& theMap) throw(std::logic_error&) {
- // if(MYDEBUG) MESSAGE("View3D_i::Restore");
- //myName = VISU::Storable::FindValue(theMap,"myName").latin1();
-
+
+ class TRestoreViewParamsEvent: public SALOME_Event{
+ QAD_StudyFrame* myStudyFrame;
+ const char* myName;
+ public:
+ TRestoreViewParamsEvent(QAD_StudyFrame* theStudyFrame,
+ const char* theName):
+ myStudyFrame(theStudyFrame),
+ myName(theName)
+ {}
+ virtual void Execute(){
+ myResult = View3D_i::RestoreViewParams(myStudyFrame,myName);
+ }
+ typedef CORBA::Boolean TResult;
+ TResult myResult;
+ };
+
+ CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){
+ return ProcessEvent(new TRestoreViewParamsEvent(myStudyFrame,theName));
+ }
+
+
+ void View3D_i::Restore(QAD_StudyFrame* theStudyFrame, const Storable::TRestoringMap& theMap){
SALOMEDS::Color aColor;
aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble();
aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble();
- myStudyFrame->setTitle(myName.c_str());
- SetBackground(aColor);
- SetPointOfView(aPosition);
- SetViewUp(aViewUp);
- SetFocalPoint(aFocalPnt);
- SetParallelScale(aParallelScale);
- ScaleView(VISU::View3D::XAxis,aScaleFactor[0]);
- ScaleView(VISU::View3D::YAxis,aScaleFactor[1]);
- ScaleView(VISU::View3D::ZAxis,aScaleFactor[2]);
- RepaintView(myStudyFrame);
- return this;
+ SetBackground(theStudyFrame,aColor);
+ SetPointOfView(theStudyFrame,aPosition);
+ SetViewUp(theStudyFrame,aViewUp);
+ SetFocalPoint(theStudyFrame,aFocalPnt);
+ SetParallelScale(theStudyFrame,aParallelScale);
+ ScaleView(theStudyFrame,VISU::View3D::XAxis,aScaleFactor[0]);
+ ScaleView(theStudyFrame,VISU::View3D::YAxis,aScaleFactor[1]);
+ ScaleView(theStudyFrame,VISU::View3D::ZAxis,aScaleFactor[2]);
}
- void View3D_i::ToStream(std::ostringstream& theStr) {
+ string View3D_i::ToString(QAD_StudyFrame* theStudyFrame){
+ ostringstream strOut;
+ Storable::DataToStream( strOut, "myComment", myComment.c_str() );
+ ToStream(theStudyFrame,strOut);
+ strOut<<ends;
+ if(MYDEBUG) MESSAGE("View3D_i::ToString - "<<strOut.str());
+ return strOut.str();
+ }
+ void View3D_i::ToStream(QAD_StudyFrame* theStudyFrame, std::ostringstream& theStr) {
Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
float backint[3];
- GetRenderer(myStudyFrame)->GetBackground(backint);
+ GetRenderer(theStudyFrame)->GetBackground(backint);
Storable::DataToStream(theStr,"myColor.R",backint[0]);
Storable::DataToStream(theStr,"myColor.G",backint[1]);
Storable::DataToStream(theStr,"myColor.B",backint[2]);
double aPosition[3];
- GetPointOfView(myStudyFrame,aPosition);
+ GetPointOfView(theStudyFrame,aPosition);
Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]);
Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]);
Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]);
double aFocalPnt[3];
- GetFocalPoint(myStudyFrame,aFocalPnt);
+ GetFocalPoint(theStudyFrame,aFocalPnt);
Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]);
Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]);
Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]);
double aViewUp[3];
- GetCamera(myStudyFrame)->GetViewUp(aViewUp);
+ GetCamera(theStudyFrame)->GetViewUp(aViewUp);
Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]);
Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]);
Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]);
- Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(myStudyFrame));
+ Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theStudyFrame));
double aScaleFactor[3];
- GetViewFrame(myStudyFrame)->GetScale(aScaleFactor);
+ GetViewFrame(theStudyFrame)->GetScale(aScaleFactor);
Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]);
Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]);
Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]);
}
+ void View3D_i::ToStream(std::ostringstream& theStr) {
+ ToStream(myStudyFrame,theStr);
+ }
-// Storable* VISU::View3DRestore(SALOMEDS::SComponent_var& theSComponent, SALOMEDS::Study_var& theStudy,
-// const char* thePrefix, const Storable::TRestoringMap& theMap)
-// {
-// try{
-// View3D_i* pView3D = new View3D_i(theStudy);
-// return pView3D->Restore(theMap);
-// }catch(std::logic_error& exc){
-// MESSAGE("Follow exception was accured :\n"<<exc.what());
-// }catch(...){
-// MESSAGE("Unknown exception was accured!");
-// }
-// return NULL;
-// }
-
void View3D_i::Close(){
- if(MYDEBUG) MESSAGE("View3D_i::Close");
- Mutex mt(myMutex,qApp,MYDELAY);
myStudyFrame->close();
}
View3D_i::~View3D_i() {
if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
- Mutex mt(myMutex,qApp,MYDELAY);
- myStudyFrame->close();
}
//-------------------- View interface --------------------
+
+ void View_i::ShowPart( VISU::View::ViewRepresentation ViewRepr, CORBA::Boolean state ) {
+ ProcessVoidEvent( new TSetViewRepresentation( this, ViewRepr, state ) );
+ Update();
+ }
+
+ CORBA::Boolean View_i::IsPartShown( VISU::View::ViewRepresentation Part )
+ {
+ return ProcessEvent( new TGetViewRepresentation( this, Part ) );
+ }
+
+ void View_i::SetViewWidth(CORBA::Long Width){
+ ProcessVoidEvent( new TSetViewWidthHeight( this, Width, true ) );
+ }
+
+ void View_i::SetViewHeight(CORBA::Long Height){
+ ProcessVoidEvent( new TSetViewWidthHeight( this, Height, false ) );
+ }
+
+ CORBA::Long View_i::GetViewWidth()
+ {
+ return ProcessEvent( new TGetViewWidthHeight( this, true ) );
+ }
+
+ CORBA::Long View_i::GetViewHeight()
+ {
+ return ProcessEvent( new TGetViewWidthHeight( this, false ) );
+ }
+
+ void View_i::SetViewPositionHorizontal( VISU::View::ViewPosition ViewPosHor ){
+ ProcessVoidEvent( new TSetViewPositionHorizontal( this, ViewPosHor ) );
+ }
+
+ void View_i::SetViewPositionVertical( VISU::View::ViewPosition ViewPosVer ){
+ ProcessVoidEvent( new TSetViewPositionVertical( this, ViewPosVer ) );
+ }
+
+ void View_i::SetRelativePosition( CORBA::Double x, CORBA::Double y )
+ {
+ ProcessVoidEvent( new TSetRelativePosition( this, x, y ) );
+ }
+
+ void View_i::SetRelativeSize( CORBA::Double x, CORBA::Double y )
+ {
+ ProcessVoidEvent( new TSetRelativeSize( this, x, y ) );
+ }
+
+
+
+
void View3D_i::SetTitle(const char* theTitle){
- if(MYDEBUG) MESSAGE("View3D_i::SetTitle");
- Mutex mt(myMutex,qApp,MYDELAY);
- myName = theTitle;
- myStudyFrame->setTitle(myName.c_str());
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<QAD_StudyFrame,const QString&,QString>
+ (myStudyFrame,&QAD_StudyFrame::setTitle,QString(theTitle)));
}
char* View3D_i::GetTitle() {
- if(MYDEBUG) MESSAGE("View3D_i::GetTitle");
- Mutex mt(myMutex,qApp,MYDELAY);
- myName = (const char*)myStudyFrame->title();
- return CORBA::string_dup(myName.c_str());
+ return CORBA::string_dup(myStudyFrame->title().latin1());
}
+
void View3D_i::SetBackground(QAD_StudyFrame* theStudyFrame, const SALOMEDS::Color& theColor) {
int aColor[3];
- aColor[0] = (int)(255.0*theColor.R);
- aColor[1] = (int)(255.0*theColor.G);
- aColor[2] = (int)(255.0*theColor.B);
+ aColor[0] = int(255.0*theColor.R);
+ aColor[1] = int(255.0*theColor.G);
+ aColor[2] = int(255.0*theColor.B);
QColor aNewColor(aColor[0],aColor[1],aColor[2]);
GetViewFrame(theStudyFrame)->setBackgroundColor(aNewColor);
}
void View3D_i::SetBackground(const SALOMEDS::Color& theColor) {
- if(MYDEBUG) MESSAGE("View3D_i::SetBackground");
- Mutex mt(myMutex,qApp,MYDELAY);
- //myColor.R = theColor.R; myColor.G = theColor.G; myColor.B = theColor.B;
- SetBackground(myStudyFrame,theColor);
+ ProcessVoidEvent(new TSetBackgroundEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),theColor));
}
+
SALOMEDS::Color View3D_i::GetBackground(QAD_StudyFrame* theStudyFrame) {
SALOMEDS::Color aColor;
float backint[3];
return aColor;
}
SALOMEDS::Color View3D_i::GetBackground() {
- if(MYDEBUG) MESSAGE("View3D_i::GetBackground");
- Mutex mt(myMutex,qApp,MYDELAY);
- //myColor = GetBackground(myStudyFrame);
- return GetBackground(myStudyFrame); //myColor;
+ return GetBackground(myStudyFrame);
}
+
void View3D_i::Minimize() {
- if(MYDEBUG) MESSAGE("View3D_i::Minimize");
- Mutex mt(myMutex,qApp,MYDELAY);
- myStudyFrame->showMinimized();
+ ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized));
}
void View3D_i::Restore() {
- if(MYDEBUG) MESSAGE("View3D_i::Restore");
- Mutex mt(myMutex,qApp,MYDELAY);
- myStudyFrame->showNormal();
+ ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal));
}
void View3D_i::Maximize() {
- if(MYDEBUG) MESSAGE("View3D_i::Maximize");
- Mutex mt(myMutex,qApp,MYDELAY);
- myStudyFrame->showMaximized();
+ ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized));
}
+
+
//===========================================================================
+ class TUpdateViewerEvent: public SALOME_Event{
+ QAD_StudyFrame* myStudyFrame;
+ Prs3d_i* myPrs3d;
+ int myDisplaing;
+ public:
+ TUpdateViewerEvent(QAD_StudyFrame* theStudyFrame,
+ Prs3d_i* thePrs3d,
+ int theDisplaing):
+ myStudyFrame(theStudyFrame),
+ myPrs3d(thePrs3d),
+ myDisplaing(theDisplaing)
+ {}
+ virtual void Execute(){
+ UpdateViewer(myStudyFrame,myDisplaing,myPrs3d);
+ }
+ };
+
void View3D_i::EraseAll() {
if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
- Mutex mt(myMutex,qApp,MYDELAY);
- UpdateViewer(myStudyFrame,eEraseAll);
+ ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,NULL,eEraseAll));
}
+
void View3D_i::DisplayAll() {
if(MYDEBUG) MESSAGE("View3D_i::DisplayAll");
- Mutex mt(myMutex,qApp,MYDELAY);
- UpdateViewer(myStudyFrame,eDisplayAll);
+ ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,NULL,eDisplayAll));
}
+
void View3D_i::Erase(PrsObject_ptr thePrsObj) {
if(MYDEBUG) MESSAGE("View3D_i::Erase");
- Mutex mt(myMutex,qApp,MYDELAY);
CORBA::Object_ptr anObj = thePrsObj;
- if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
- UpdateViewer(myStudyFrame,eErase,aPrs);
+ if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
+ ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eErase));
+ }
}
+
void View3D_i::Display(PrsObject_ptr thePrsObj) {
if(MYDEBUG) MESSAGE("View3D_i::Display");
- Mutex mt(myMutex,qApp,MYDELAY);
CORBA::Object_ptr anObj = thePrsObj;
- if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
- UpdateViewer(myStudyFrame,eDisplay,aPrs);
+ if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
+ ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eDisplay));
+ }
}
+
void View3D_i::DisplayOnly(PrsObject_ptr thePrsObj) {
if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly");
- Mutex mt(myMutex,qApp,MYDELAY);
CORBA::Object_ptr anObj = thePrsObj;
- if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj)))
- UpdateViewer(myStudyFrame,eDisplayOnly,aPrs);
+ if(Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in())){
+ ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eDisplayOnly));
+ }
}
//-------------------- View3D interface --------------------
void View3D_i::FitAll() {
- if(MYDEBUG) MESSAGE("View3D_i::FitAll");
- Mutex mt(myMutex,qApp,MYDELAY);
- GetViewFrame(myStudyFrame)->onViewFitAll();
+ ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFitAll));
Update();
}
+
+
void View3D_i::SetView(VISU::View3D::ViewType theType) {
- if(MYDEBUG) MESSAGE("View3D_i::SetView");
- Mutex mt(myMutex,qApp,MYDELAY);
switch(theType){
- case VISU::View3D::FRONT : GetViewFrame(myStudyFrame)->onViewFront(); break;
- case VISU::View3D::BACK : GetViewFrame(myStudyFrame)->onViewBack(); break;
- case VISU::View3D::LEFT : GetViewFrame(myStudyFrame)->onViewLeft(); break;
- case VISU::View3D::RIGHT : GetViewFrame(myStudyFrame)->onViewRight(); break;
- case VISU::View3D::TOP : GetViewFrame(myStudyFrame)->onViewTop(); break;
- case VISU::View3D::BOTTOM : GetViewFrame(myStudyFrame)->onViewBottom(); break;
+ case VISU::View3D::FRONT :
+ ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFront));
+ break;
+ case VISU::View3D::BACK :
+ ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBack));
+ break;
+ case VISU::View3D::LEFT :
+ ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewLeft));
+ break;
+ case VISU::View3D::RIGHT :
+ ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewRight));
+ break;
+ case VISU::View3D::TOP :
+ ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewTop));
+ break;
+ case VISU::View3D::BOTTOM :
+ ProcessVoidEvent(new TVoidMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBottom));
+ break;
}
Update();
}
+
+ class TSet3DViewParamEvent: public SALOME_Event{
+ public:
+ typedef void (*TFun)(QAD_StudyFrame* theStudyFrame, const CORBA::Double theParam[3]);
+ TSet3DViewParamEvent(TFun theFun,
+ QAD_StudyFrame* theStudyFrame,
+ const CORBA::Double theParam[3]):
+ myFun(theFun),
+ myStudyFrame(theStudyFrame),
+ myParam(theParam)
+ {}
+ virtual void Execute(){
+ myFun(myStudyFrame,myParam);
+ }
+ private:
+ TFun myFun;
+ QAD_StudyFrame* myStudyFrame;
+ const CORBA::Double* myParam;
+ };
+
+
void View3D_i::SetPointOfView(QAD_StudyFrame* theStudyFrame, const CORBA::Double thePosition[3]) {
GetCamera(theStudyFrame)->SetPosition(thePosition);
}
- void View3D_i::SetPointOfView(const VISU::View3D::XYZ theCoord) {
+ void View3D_i::SetPointOfView(const VISU::View3D::XYZ thePosition) {
if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
- Mutex mt(myMutex,qApp,MYDELAY);
- //VISU::View3D::XYZ_copy(myPosition,theCoord);
- SetPointOfView(myStudyFrame, theCoord);
+ ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,myStudyFrame,thePosition));
}
+
void View3D_i::GetPointOfView(QAD_StudyFrame* theStudyFrame, CORBA::Double thePosition[3]) {
GetCamera(theStudyFrame)->GetPosition(thePosition);
}
VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() {
if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
- Mutex mt(myMutex,qApp,MYDELAY);
CORBA::Double aPosition[3];
GetPointOfView(myStudyFrame,aPosition);
return VISU::View3D::XYZ_dup(aPosition);
}
+
void View3D_i::SetViewUp(QAD_StudyFrame* theStudyFrame, const CORBA::Double theViewUp[3]) {
GetCamera(theStudyFrame)->SetViewUp(theViewUp);
}
- void View3D_i::SetViewUp(const VISU::View3D::XYZ theDir) {
+ void View3D_i::SetViewUp(const VISU::View3D::XYZ theViewUp) {
if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
- Mutex mt(myMutex,qApp,MYDELAY);
- //VISU::View3D::XYZ_copy(myViewUp,theDir);
- SetViewUp(myStudyFrame, theDir);
+ ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,myStudyFrame,theViewUp));
}
+
void View3D_i::GetViewUp(QAD_StudyFrame* theStudyFrame, CORBA::Double theViewUp[3]) {
GetCamera(theStudyFrame)->GetViewUp(theViewUp);
}
VISU::View3D::XYZ_slice* View3D_i::GetViewUp() {
if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
- Mutex mt(myMutex,qApp,MYDELAY);
CORBA::Double aViewUp[3];
GetCamera(myStudyFrame)->GetViewUp(aViewUp);
return VISU::View3D::XYZ_dup(aViewUp);
}
+
void View3D_i::SetFocalPoint(QAD_StudyFrame* theStudyFrame, const CORBA::Double theFocalPnt[3]) {
GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt);
}
void View3D_i::SetFocalPoint(const VISU::View3D::XYZ theCoord) {
if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
- Mutex mt(myMutex,qApp,MYDELAY);
- //VISU::View3D::XYZ_copy(myFocalPnt,theCoord);
- SetFocalPoint(myStudyFrame,theCoord);
+ ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,myStudyFrame,theCoord));
}
+
void View3D_i::GetFocalPoint(QAD_StudyFrame* theStudyFrame, CORBA::Double theFocalPnt[3]) {
GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt);
}
VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() {
if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
- Mutex mt(myMutex,qApp,MYDELAY);
CORBA::Double aFocalPnt[3];
GetFocalPoint(myStudyFrame,aFocalPnt);
return VISU::View3D::XYZ_dup(aFocalPnt);
}
+
+ class TSetViewParamEvent: public SALOME_Event{
+ public:
+ typedef void (*TFun)(QAD_StudyFrame* theStudyFrame, CORBA::Double theParam);
+ TSetViewParamEvent(TFun theFun,
+ QAD_StudyFrame* theStudyFrame,
+ CORBA::Double theParam):
+ myFun(theFun),
+ myStudyFrame(theStudyFrame),
+ myParam(theParam)
+ {}
+ virtual void Execute(){
+ myFun(myStudyFrame,myParam);
+ }
+ private:
+ TFun myFun;
+ QAD_StudyFrame* myStudyFrame;
+ CORBA::Double myParam;
+ };
+
+
void View3D_i::SetParallelScale(QAD_StudyFrame* theStudyFrame, CORBA::Double theScale) {
GetCamera(theStudyFrame)->SetParallelScale(theScale);
}
void View3D_i::SetParallelScale(CORBA::Double theScale) {
if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
- Mutex mt(myMutex,qApp,MYDELAY);
- //myParallelScale = theScale;
- SetParallelScale(myStudyFrame, theScale);
+ ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,myStudyFrame,theScale));
}
+
CORBA::Double View3D_i::GetParallelScale(QAD_StudyFrame* theStudyFrame) {
return GetCamera(theStudyFrame)->GetParallelScale();
}
CORBA::Double View3D_i::GetParallelScale() {
if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
- Mutex mt(myMutex,qApp);
return GetParallelScale(myStudyFrame);
}
aScaleFactor[theAxis] = theParam;
aViewFrame->SetScale(aScaleFactor);
}
+
+ void SetScaleView(QAD_StudyFrame* theStudyFrame, const CORBA::Double theScale[3]){
+ double aScale[3] = {theScale[0], theScale[1], theScale[2]};
+ GetViewFrame(theStudyFrame)->SetScale(aScale);
+ }
void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) {
if(MYDEBUG) MESSAGE("View3D_i::ScaleView");
- Mutex mt(myMutex,qApp);
- //myScaleFactor[theAxis] = theParam;
- ScaleView(myStudyFrame,theAxis,theParam);
+ double aScale[3];
+ GetViewFrame(myStudyFrame)->GetScale(aScale);
+ aScale[theAxis] = theParam;
+ ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale));
}
void View3D_i::RemoveScale() {
if(MYDEBUG) MESSAGE("View3D_i::RemoveScale");
- Mutex mt(myMutex,qApp);
- double aScaleFactor[]={1,1,1};
- //myScaleFactor[0] = myScaleFactor[0] = myScaleFactor[0] = 1.0;
- GetViewFrame(myStudyFrame)->SetScale(aScaleFactor);
+ double aScale[3] = {1.0, 1.0, 1.0};
+ ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale));
}
//===========================================================================
+
+
+ VISU_Actor* GetActor(VISU::Prs3d_i* thePrs3d, VTKViewer_ViewFrame* theVTKFrame){
+ vtkActorCollection *anActColl = theVTKFrame->getRenderer()->GetActors();
+ anActColl->InitTraversal();
+ while(vtkActor *anActor = anActColl->GetNextActor())
+ if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
+ if(thePrs3d == anVISUActor->GetPrs3d())
+ return anVISUActor->GetParent();
+ return NULL;
+ }
+
+
+ void DeletePrs3d(Prs3d_ptr thePrs3d){
+ if(Prs3d_i* aPrs3d = dynamic_cast<Prs3d_i*>(GetServant(thePrs3d).in())){
+ SALOMEDS::SObject_var aSObject = aPrs3d->GetSObject();
+ SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
+ if(QAD_Desktop* aDesktop = QAD_Application::getDesktop()){
+ if(QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument)){
+ aStudy->unHighlightAll();
+ int aNbStudyFrames = aStudy->getStudyFramesCount();
+ for(int aFrameId = 0; aFrameId < aNbStudyFrames; aFrameId++){
+ if(QAD_StudyFrame* aFrame = aStudy->getStudyFrame(aFrameId)){
+ QAD_ViewFrame* aViewFrame = aFrame->getRightFrame()->getViewFrame();
+ if(VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame)){
+ if(VISU_Actor* anActor = VISU::GetActor(aPrs3d,aVTKFrame)){
+ aVTKFrame->RemoveActor(anActor);
+ anActor->Delete();
+ }
+ aVTKFrame->unHighlightAll();
+ }
+ }
+ }
+
+ aPrs3d->RemoveFromStudy();
+ aPrs3d->Destroy();
+
+ aStudy->updateObjBrowser(); //update Object browser
+ }
+ }
+ }
+ }
+
+
+ void VISU_Gen_i::DeleteResult(Result_ptr theResult)
+ {
+ class TEvent: public SALOME_Event{
+ Result_ptr myResult;
+ public:
+ TEvent(Result_ptr theResult): myResult(theResult) {}
+ virtual void Execute(){
+ if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(myResult).in())){
+ SALOMEDS::SObject_var aSObject = aResult->GetSObject();
+ SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
+ SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->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::DeletePrs3d(aPrs3d);
+ }
+
+ aResult->RemoveFromStudy();
+ aResult->Destroy();
+
+ if(QAD_Desktop* aDesktop = QAD_Application::getDesktop())
+ if(QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument))
+ aStudy->updateObjBrowser(); //update Object browser
+ }
+ }
+ };
+
+ ProcessVoidEvent(new TEvent(theResult));
+ }
+
+
+ void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d)
+ {
+ class TEvent: public SALOME_Event{
+ Prs3d_ptr myPrs3d;
+ public:
+ TEvent(Prs3d_ptr thePrs3d): myPrs3d(thePrs3d) {}
+ virtual void Execute(){
+ VISU::DeletePrs3d(myPrs3d);
+ }
+ };
+
+ ProcessVoidEvent(new TEvent(thePrs3d));
+ }
+
}