#include "SUIT_Tools.h"
#include "STD_MDIDesktop.h"
+#include "STD_TabDesktop.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_ViewModel.h"
#include "SalomeApp_Application.h"
#include "SalomeApp_Study.h"
+#include <QtxWorkstack.h>
+
#include <qworkspace.h>
#include <vtkCamera.h>
static int MYDEBUG = 0;
#endif
-namespace VISU{
+namespace VISU {
typedef TVoidMemFunEvent<SUIT_ViewWindow> TFrameActionEvent;
+ struct TNewViewEvent: public SALOME_Event
+ {
+ SalomeApp_Application* myApplication;
+ typedef QWidget* TResult;
+ TResult myResult;
+
+ TNewViewEvent (SalomeApp_Application* theApplication):
+ myApplication(theApplication),
+ myResult(NULL)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ if (STD_MDIDesktop* aDesktop = dynamic_cast<STD_MDIDesktop*>(myApplication->desktop())) {
+ myResult = aDesktop->workspace();
+ }
+ }
+ };
+
View_i::
- View_i(SalomeApp_Application *theApplication,
- SUIT_ViewManager* theViewManager):
+ View_i (SalomeApp_Application *theApplication,
+ SUIT_ViewManager* theViewManager):
myApplication(theApplication),
myWorkspace(NULL),
myViewManager(theViewManager)
{
if(MYDEBUG) MESSAGE("View_i::View_i - "<<this);
- if(STD_MDIDesktop* aDesktop = dynamic_cast<STD_MDIDesktop*>(myApplication->desktop())){
- myWorkspace = aDesktop->workspace();
- }
+ myWorkspace = ProcessEvent(new TNewViewEvent(theApplication));
}
View_i::
{}
};
-
void
View_i::
- ShowPart(VISU::View::ViewRepresentation theViewRepresentation,
- CORBA::Boolean theState)
+ ShowPart (VISU::View::ViewRepresentation theViewRepresentation,
+ CORBA::Boolean theState)
{
struct TEvent: public TApplicationEvent
{
ProcessVoidEvent(new TEvent(myApplication,theViewRepresentation,theState));
}
-
struct TPartShownEvent: public TApplicationEvent
{
VISU::View::ViewRepresentation myViewRepresentation;
}
};
-
CORBA::Boolean
View_i::
- IsPartShown(VISU::View::ViewRepresentation theViewRepresentation)
+ IsPartShown (VISU::View::ViewRepresentation theViewRepresentation)
{
return ProcessEvent(new TPartShownEvent(myApplication,theViewRepresentation));
}
+ enum SplitSide {SPLIT_LEFT, SPLIT_RIGHT, SPLIT_TOP, SPLIT_BOTTOM};
+
+ struct TSplitEvent: public SALOME_Event
+ {
+ SalomeApp_Application * myApplication;
+ SUIT_ViewWindow * myViewWindow;
+ SplitSide mySplitSide;
+
+ public:
+ TSplitEvent (SalomeApp_Application * theApplication,
+ SUIT_ViewWindow * theViewWindow,
+ SplitSide theSplitSide):
+ myApplication(theApplication),
+ myViewWindow(theViewWindow),
+ mySplitSide(theSplitSide)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ MESSAGE("TSplitEvent::Execute()");
+ SUIT_Desktop* desk = myApplication->desktop();
+ STD_TabDesktop* tabDesk = dynamic_cast<STD_TabDesktop*>(desk);
+ if (tabDesk) {
+ MESSAGE("TSplitEvent::Execute() - tabDesk");
+ QtxWorkstack* workstack = tabDesk->workstack();
+ if (workstack) {
+ MESSAGE("TSplitEvent::Execute() - workstack");
+ QWidgetList vws = workstack->splitWindowList();
+ if (vws.count() > 1) {
+ MESSAGE("TSplitEvent::Execute() - vws.count() > 1");
+ //jfa tmp:workstack->windowActivated(myViewWindow);
+ //??? to do: set workarea of this vw as active area
+ switch (mySplitSide) {
+ case SPLIT_LEFT:
+ case SPLIT_RIGHT:
+ workstack->split(Qt::Horizontal);
+ break;
+ case SPLIT_TOP:
+ case SPLIT_BOTTOM:
+ workstack->split(Qt::Vertical);
+ break;
+ }
+ }
+ }
+ }
+ }
+ };
+
+ void
+ View_i::
+ SplitRight()
+ {
+ ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,SPLIT_RIGHT));
+ }
+
+ void
+ View_i::
+ SplitBottom()
+ {
+ ProcessVoidEvent(new TSplitEvent(myApplication,myViewWindow,SPLIT_BOTTOM));
+ }
struct TSetViewSize: public SALOME_Event
{
}
};
-
void
View_i::
SetViewWidth(CORBA::Long theWidth)
ProcessVoidEvent(new TSetViewSize(myViewWindow,&QRect::setWidth,theWidth));
}
-
void
View_i::
SetViewHeight(CORBA::Long theHeight)
void
View_i::
- SetViewPositionHorizontal(VISU::View::ViewPosition theViewPosition)
+ SetViewPositionHorizontal (VISU::View::ViewPosition theViewPosition)
{
- if(myWorkspace){
- switch(theViewPosition){
+ if (myWorkspace) {
+ switch (theViewPosition) {
case VISU::View::LEFT:
ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignLeft));
break;
void
View_i::
- SetViewPositionVertical(VISU::View::ViewPosition theViewPosition)
+ SetViewPositionVertical (VISU::View::ViewPosition theViewPosition)
{
- if(myWorkspace){
- switch(theViewPosition){
+ if (myWorkspace) {
+ switch (theViewPosition) {
case VISU::View::TOP:
ProcessVoidEvent(new TAlignEvent(myViewWindow,myWorkspace,Qt::AlignTop));
break;
void
View_i::
- SetRelativePosition(CORBA::Double theX, CORBA::Double theY)
+ SetRelativePosition (CORBA::Double theX, CORBA::Double theY)
{
struct TEvent: public TXYEvent
{
}
};
- if(myWorkspace)
+ if (myWorkspace)
ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
}
void
View_i::
- SetRelativeSize(CORBA::Double theX, CORBA::Double theY)
+ SetRelativeSize (CORBA::Double theX, CORBA::Double theY)
{
struct TEvent: public TXYEvent
{
}
};
- if(myWorkspace)
+ if (myWorkspace)
ProcessVoidEvent(new TEvent(myViewWindow,myWorkspace,theX,theY));
}
void
View_i::
- SetBackground(const SALOMEDS::Color& theColor)
+ SetBackground (const SALOMEDS::Color& theColor)
{
struct TEvent: public SALOME_Event
{
void
View_i::
- Erase(PrsObject_ptr thePrsObj)
+ Erase (PrsObject_ptr thePrsObj)
{}
void
View_i::
- Display(PrsObject_ptr thePrsObj)
+ Display (PrsObject_ptr thePrsObj)
{}
void
View_i::
- DisplayOnly(PrsObject_ptr thePrsObj)
+ DisplayOnly (PrsObject_ptr thePrsObj)
{}
void
{
return "";
}
+
void
View_i::
- ToStream(std::ostringstream& theStr)
- {}
+ ToStream (std::ostringstream& theStr)
+ {
+ }
//================= OLD CODE ===================
// return aStudy;
//}
+ template<class TViewer>
+ struct TNewSpecViewEvent: public SALOME_Event
+ {
+ SalomeApp_Application* myApplication;
+
+ typedef SUIT_ViewManager* TResult;
+ TResult myResult;
+
+ TNewSpecViewEvent (SalomeApp_Application* theApplication):
+ myApplication(theApplication),
+ myResult(NULL)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ myResult = myApplication->getViewManager(TViewer::Type(), true);
+ }
+ };
+
//===========================================================================
XYPlot_i::XYPlot_i (SalomeApp_Application* theApplication)
: View_i(theApplication, NULL)
{
if (MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i");
if (theApplication) {
- myViewManager = theApplication->getViewManager(Plot2d_Viewer::Type(), true);
+ myViewManager = ProcessEvent(new TNewSpecViewEvent<Plot2d_Viewer>(theApplication));
}
}
- Storable* XYPlot_i::Create (int theNew)
+
+ struct TCreatePlot2dViewEvent: public SALOME_Event
{
- if (theNew) {
- myViewWindow = myViewManager->createViewWindow();
- } else {
- myViewWindow = myViewManager->getActiveView();
- }
- ////myView = dynamic_cast<Plot2d_ViewFrame*>(myViewWindow->getRightFrame()->getViewFrame());
- //SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(myViewManager->getViewModel());
- //myView = aView->getActiveViewFrame();
- if (myViewWindow) {
- Plot2d_ViewWindow* aPlot2dVW = dynamic_cast<Plot2d_ViewWindow*>(myViewWindow);
- if (aPlot2dVW) {
- myView = aPlot2dVW->getViewFrame();
- if (myView) {
- myView->Repaint();
+ SUIT_ViewManager* myViewManager;
+ XYPlot_i * myPlot2dView;
+ int myNew;
+
+ typedef Plot2d_ViewFrame* TResult;
+ TResult myResult;
+
+ TCreatePlot2dViewEvent (SUIT_ViewManager* theViewManager,
+ XYPlot_i * thePlot2dView,
+ const int theNew):
+ myViewManager(theViewManager),
+ myPlot2dView(thePlot2dView),
+ myNew(theNew),
+ myResult(NULL)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ if (myNew) {
+ myPlot2dView->myViewWindow = myViewManager->createViewWindow();
+ } else {
+ myPlot2dView->myViewWindow = myViewManager->getActiveView();
+ }
+ if (myPlot2dView->myViewWindow) {
+ Plot2d_ViewWindow* aPlot2dVW = dynamic_cast<Plot2d_ViewWindow*>(myPlot2dView->myViewWindow);
+ if (aPlot2dVW) {
+ myResult = aPlot2dVW->getViewFrame();
+ if (myResult) {
+ myResult->Repaint();
+ }
}
}
}
+ };
+
+ Storable* XYPlot_i::Create (int theNew)
+ {
+ myView = ProcessEvent(new TCreatePlot2dViewEvent(myViewManager, this, theNew));
return this;
}
void XYPlot_i::Close()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
myViewWindow->close();
}
}
char* XYPlot_i::GetTitle()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
return CORBA::string_dup(myViewWindow->caption().latin1());
}
char* XYPlot_i::GetSubTitle()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
return CORBA::string_dup(myView->getTitle());
}
VISU::XYPlot::CurveType XYPlot_i::GetCurveType()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
return (VISU::XYPlot::CurveType)myView->getCurveType();
}
CORBA::Long XYPlot_i::GetMarkerSize()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
return myView->getMarkerSize();
}
VISU::Scaling XYPlot_i::GetHorScaling()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
return (VISU::Scaling)myView->getHorScaleMode();
}
VISU::Scaling XYPlot_i::GetVerScaling()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
return (VISU::Scaling)myView->getVerScaleMode();
}
class TSetTitleEvent: public SALOME_Event
{
public:
- //typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, bool = true);
- typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, Plot2d_ViewFrame::ObjectType, bool = true);
- //TSetTitleEvent (Plot2d_ViewFrame* theView, TFun theFun, const char* theTitle):
TSetTitleEvent (Plot2d_ViewFrame* theView, Plot2d_ViewFrame::ObjectType theType, const char* theTitle):
- //myView(theView), myFun(theFun), myTitle(theTitle)
myView(theView), myType(theType), myTitle(theTitle)
{}
virtual void Execute()
{
- //(myView->*myFun)(true,myTitle,myType);
myView->setTitle(true,myTitle,myType);
}
protected:
Plot2d_ViewFrame* myView;
- //TFun myFun;
Plot2d_ViewFrame::ObjectType myType;
const char* myTitle;
};
void XYPlot_i::SetXTitle (const char* theTitle)
{
- //ProcessVoidEvent(new TSetTitleEvent(myView, &Plot2d_ViewFrame::setXTitle, theTitle));
ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::XTitle, theTitle));
}
char* XYPlot_i::GetXTitle()
{
- //return CORBA::string_dup(myView->getXTitle());
+ //jfa: may be need to be enclosed in SALOME_Event?
return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle));
}
void XYPlot_i::SetYTitle (const char* theTitle)
{
- //ProcessVoidEvent(new TSetTitleEvent(myView, &Plot2d_ViewFrame::setYTitle, theTitle));
ProcessVoidEvent(new TSetTitleEvent(myView, Plot2d_ViewFrame::YTitle, theTitle));
}
char* XYPlot_i::GetYTitle()
{
- //return CORBA::string_dup(myView->getYTitle());
+ //jfa: may be need to be enclosed in SALOME_Event?
return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle));
}
ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame> (myView,&Plot2d_ViewFrame::fitAll));
}
- //CORBA::Boolean XYPlot_i::SavePicture (const char* theFileName)
- //{
- // return ProcessEvent(new TSavePictureEvent (myView->getViewWidget(),theFileName));
- //}
-
//===========================================================================
TableView_i::TableView_i (SalomeApp_Application* theApplication)
{
}
- Storable* TableView_i::Create (VISU::Table_ptr theTable)
+ struct TCreateTableViewEvent: public SALOME_Event
{
- if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil()));
- if (!theTable->_is_nil()) {
- 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) {
+ SalomeApp_Application* myApplication;
+ VISU::Table_i* myTable;
+
+ typedef VisuGUI_TableDlg* TResult;
+ TResult myResult;
+
+ TCreateTableViewEvent (SalomeApp_Application* theApplication,
+ VISU::Table_i* theTable):
+ myApplication(theApplication),
+ myTable(theTable),
+ myResult(NULL)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ if (myTable != NULL) {
if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
if (_PTR(Study) aCStudy = aStudy->studyDS()) {
- _PTR(SObject) aSObject = aCStudy->FindObjectID(table->GetObjectEntry());
+ _PTR(SObject) aSObject = aCStudy->FindObjectID(myTable->GetObjectEntry());
if (aSObject) {
- myView = new VisuGUI_TableDlg (myApplication->desktop(),
- aSObject,
- false,
- VisuGUI_TableDlg::ttAuto,
- Qt::Vertical);
- myView->show();
- return this;
+ myResult = new VisuGUI_TableDlg (myApplication->desktop(),
+ aSObject,
+ false,
+ VisuGUI_TableDlg::ttAuto,
+ Qt::Vertical);
+ myResult->show();
}
}
}
}
}
}
+ };
+
+ Storable* TableView_i::Create (VISU::Table_ptr theTable)
+ {
+ if (MYDEBUG) MESSAGE("TableView_i::Create - " << (!theTable->_is_nil()));
+ if (!theTable->_is_nil()) {
+ VISU::Table_i* table =
+ dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
+ if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table);
+
+ myView = ProcessEvent(new TCreateTableViewEvent(myApplication, table));
+ if (myView)
+ return this;
+ }
return NULL;
}
char* TableView_i::GetTitle()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
return CORBA::string_dup(myView->caption().latin1());
- return "";
}
void TableView_i::Close()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
myView->close();
}
{
if (MYDEBUG) MESSAGE("View3D_i::View3D_i");
if (theApplication) {
- myViewManager = theApplication->getViewManager(SVTK_Viewer::Type(), true);
+ myViewManager = ProcessEvent(new TNewSpecViewEvent<SVTK_Viewer>(theApplication));
}
}
+ struct TCreateView3dEvent: public SALOME_Event
+ {
+ SUIT_ViewManager* myViewManager;
+ int myNew;
+
+ typedef SUIT_ViewWindow* TResult;
+ TResult myResult;
+
+ TCreateView3dEvent (SUIT_ViewManager* theViewManager,
+ const int theNew):
+ myViewManager(theViewManager),
+ myNew(theNew),
+ myResult(NULL)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ if (myNew) {
+ myResult = myViewManager->createViewWindow();
+ } else {
+ myResult = myViewManager->getActiveView();
+ }
+ }
+ };
+
Storable* View3D_i::Create (int theNew)
{
if (MYDEBUG) MESSAGE("View3D_i::Create");
- if (theNew) {
- myViewWindow = myViewManager->createViewWindow();
- } else {
- myViewWindow = myViewManager->getActiveView();
- }
+ myViewWindow = ProcessEvent(new TCreateView3dEvent(myViewManager, theNew));
return this;
}
ProcessVoidEvent(new TEvent(myViewWindow));
}
- //CORBA::Boolean View3D_i::SavePicture (const char* theFileName)
- //{
- // return ProcessEvent(new TSavePictureEvent(myViewWindow, theFileName));
- //}
-
bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName)
{
+ MESSAGE("View3D_i::SaveViewParams()");
_PTR(Study) aCStudy;
if (SUIT_Study* aSStudy = theViewManager->study()) {
if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
return true;
}
+ class TSaveViewParamsEvent: public SALOME_Event
+ {
+ SUIT_ViewManager* myViewManager;
+ const char* myName;
+ public:
+ TSaveViewParamsEvent (SUIT_ViewManager* theViewManager,
+ const char* theName):
+ myViewManager(theViewManager),
+ myName(theName)
+ {}
+
+ virtual void Execute()
+ {
+ myResult = View3D_i::SaveViewParams(myViewManager, myName);
+ }
+ typedef CORBA::Boolean TResult;
+ TResult myResult;
+ };
+
CORBA::Boolean View3D_i::SaveViewParams (const char* theName)
{
- return SaveViewParams(myViewManager, theName);
+ return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theName));
}
bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const char* theName)
void View3D_i::Close()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
myViewWindow->close();
}
char* View3D_i::GetTitle()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
return CORBA::string_dup(myViewWindow->caption().latin1());
}
void View3D_i::SetBackground (SUIT_ViewWindow* theStudyFrame,
const SALOMEDS::Color& theColor)
{
+ //jfa: may be need to be enclosed in SALOME_Event?
int aColor[3];
aColor[0] = int(255.0*theColor.R);
aColor[1] = int(255.0*theColor.G);
SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theStudyFrame)
{
+ //jfa: may be need to be enclosed in SALOME_Event?
SALOMEDS::Color aColor;
float backint[3];
GetRenderer(theStudyFrame)->GetBackground(backint);
void View3D_i::SetPointOfView (SUIT_ViewWindow* theStudyFrame,
const CORBA::Double thePosition[3])
{
+ //jfa: may be need to be enclosed in SALOME_Event?
GetCamera(theStudyFrame)->SetPosition(thePosition);
}
void View3D_i::GetPointOfView (SUIT_ViewWindow* theStudyFrame,
CORBA::Double thePosition[3])
{
+ //jfa: may be need to be enclosed in SALOME_Event?
GetCamera(theStudyFrame)->GetPosition(thePosition);
}
VISU::View3D::XYZ_slice* View3D_i::GetPointOfView()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView");
CORBA::Double aPosition[3];
GetPointOfView(myViewWindow,aPosition);
VISU::View3D::XYZ_slice* View3D_i::GetViewUp()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
if(MYDEBUG) MESSAGE("View3D_i::GetViewUp");
CORBA::Double aViewUp[3];
GetCamera(myViewWindow)->GetViewUp(aViewUp);
VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint");
CORBA::Double aFocalPnt[3];
GetFocalPoint(myViewWindow,aFocalPnt);
CORBA::Double View3D_i::GetParallelScale()
{
+ //jfa: may be need to be enclosed in SALOME_Event?
if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale");
return GetParallelScale(myViewWindow);
}