-// VISU OBJECT : interactive object for VISU entities implementation
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
+// VISU OBJECT : interactive object for VISU entities implementation
// File : VISU_View_i.cc
// Author : Alexey PETROV
// Module : VISU
-
+//
#include "VISU_View_i.hh"
+#include "VISU_Tools.h"
#include "VISU_Gen_i.hh"
#include "VISU_Prs3d_i.hh"
#include "VISU_Table_i.hh"
+#include "VISU_PointMap3d_i.hh"
#include "VISU_ScalarMap_i.hh"
#include "VISU_ViewManager_i.hh"
-
-#include "VisuGUI_TableDlg.h"
+#include "VISU_TableDlg.h"
#include "VISU_Actor.h"
#include "VISU_ScalarMapAct.h"
+#include "VISU_PointMap3dActor.h"
+#include "VISU_DeformedGridPL.hxx"
-#include "SALOME_Event.hxx"
+#include "SALOME_Event.h"
#include "SUIT_ViewWindow.h"
#include "SUIT_ViewManager.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_ViewModel.h"
+#include "VTKViewer_Algorithm.h"
#include "SPlot2d_ViewModel.h"
#include "Plot2d_ViewFrame.h"
#include "SalomeApp_Study.h"
#include <QtxWorkstack.h>
+#include <QtxWorkspace.h>
-#include <qworkspace.h>
-#include <qimage.h>
+#include <QWorkspace>
+#include <QImage>
#include <vtkCamera.h>
#include <vtkRenderer.h>
+#include <vtkActor.h>
using namespace std;
{
switch(myViewRepresentation){
case VISU::View::OBJECTBROWSER:
- myApplication->setWindowShown(SalomeApp_Application::WT_ObjectBrowser,myState);
+ myApplication->getWindow( SalomeApp_Application::WT_ObjectBrowser )->setVisible( myState );
break;
case VISU::View::PYTHON:
- myApplication->setWindowShown(SalomeApp_Application::WT_PyConsole,myState);
+ myApplication->getWindow( SalomeApp_Application::WT_PyConsole )->setVisible( myState );
break;
case VISU::View::MESSAGES:
- myApplication->setWindowShown(SalomeApp_Application::WT_LogWindow,myState);
+ myApplication->getWindow( SalomeApp_Application::WT_LogWindow )->setVisible( myState );
break;
- case VISU::View::VIEWER:{
- ViewManagerList aViewManagerList = myApplication->viewManagers();
- // to do something
- // ...
+ case VISU::View::VIEWER:
+ {
+ ViewManagerList mgrs = myApplication->viewManagers();
+ ViewManagerList::const_iterator anIt = mgrs.begin(), aLast = mgrs.end();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ const QVector<SUIT_ViewWindow*>& views = (*anIt)->getViews();
+ for( int i=0; i<views.count(); i++ )
+ views[i]->setShown( myState );
+ }
break;
}}
}
{
switch(myViewRepresentation){
case VISU::View::OBJECTBROWSER:
- myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_ObjectBrowser);
+ myResult = myApplication->dockWindow( SalomeApp_Application::WT_ObjectBrowser )->isVisible();
break;
case VISU::View::PYTHON:
- myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_PyConsole);
+ myResult = myApplication->dockWindow( SalomeApp_Application::WT_PyConsole )->isVisible();
break;
case VISU::View::MESSAGES:
- myResult = myApplication->isWindowVisible(SalomeApp_Application::WT_LogWindow);
+ myResult = myApplication->dockWindow( SalomeApp_Application::WT_LogWindow )->isVisible();
break;
case VISU::View::VIEWER:{
ViewManagerList aViewManagerList = myApplication->viewManagers();
- // to do something
- // ...
+ ViewManagerList::const_iterator anIt = aViewManagerList.begin();
+ for( ; anIt != aViewManagerList.end(); anIt++ )
+ {
+ const QVector<SUIT_ViewWindow*>& views = (*anIt)->getViews();
+ for( int i=0; i<views.count(); i++ ) {
+ myResult = views[i]->isVisible();
+ return;
+ }
+ }
+ myResult = false;
break;
}}
}
SUIT_ViewWindow* aVW = GetViewWindow();
if (aVW)
ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
- Qt::Horizontal, QtxWorkstack::SPLIT_MOVE));
+ Qt::Horizontal, QtxWorkstack::SplitMove));
}
void
SUIT_ViewWindow* aVW = GetViewWindow();
if (aVW)
ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
- Qt::Horizontal, QtxWorkstack::SPLIT_STAY));
+ Qt::Horizontal, QtxWorkstack::SplitStay));
}
void
SUIT_ViewWindow* aVW = GetViewWindow();
if (aVW)
ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
- Qt::Vertical, QtxWorkstack::SPLIT_MOVE));
+ Qt::Vertical, QtxWorkstack::SplitMove));
}
void
SUIT_ViewWindow* aVW = GetViewWindow();
if (aVW)
ProcessVoidEvent(new TSplitEvent(myApplication, aVW,
- Qt::Vertical, QtxWorkstack::SPLIT_STAY));
+ Qt::Vertical, QtxWorkstack::SplitStay));
}
void
void
Execute()
{
- if (QWidget* aParent = myVW->parentWidget(true)) {
+ if (QWidget* aParent = myVW->parentWidget()) {
QRect aQRect = aParent->frameGeometry();
(aQRect.*myAction)(mySize);
aParent->setGeometry(aQRect);
void
Execute()
{
- if(QWidget* aParent = myVW->parentWidget(true)){
+ if(QWidget* aParent = myVW->parentWidget()){
QRect aQRect = aParent->frameGeometry();
myResult = (aQRect.*myAction)();
}
class TAlignEvent: public TWorkspaceEvent
{
protected:
- Qt::AlignmentFlags myAligment;
+ Qt::AlignmentFlag myAligment;
public:
TAlignEvent(QWidget* theViewWindow,
QWidget* theWorkspace,
- Qt::AlignmentFlags theAligment):
+ Qt::AlignmentFlag theAligment):
TWorkspaceEvent(theViewWindow,theWorkspace),
myAligment(theAligment)
{}
void
Execute()
{
- if(QWidget* aParent = myVW->parentWidget(true))
+ if(QWidget* aParent = myVW->parentWidget())
SUIT_Tools::alignWidget(aParent,myWorkspace,myAligment);
}
};
void
Execute()
{
- if(QWidget* aParent = myVW->parentWidget(true))
+ if(QWidget* aParent = myVW->parentWidget())
aParent->move(int(myX*myWorkspace->width()),int(myY*myWorkspace->height()));
}
};
void
Execute()
{
- if(QWidget* aParent = myVW->parentWidget(true))
+ if(QWidget* aParent = myVW->parentWidget())
aParent->setGeometry(aParent->x(),
aParent->y(),
int(myX*myWorkspace->width()),
{
struct TEvent: public SALOME_Event
{
- QWidget* myWidget;
+ SVTK_ViewWindow* myVW;
SALOMEDS::Color myColor;
public:
- TEvent(QWidget* theWidget,
+ TEvent(SVTK_ViewWindow* theViewWindow,
const SALOMEDS::Color& theColor):
- myWidget(theWidget),
+ myVW(theViewWindow),
myColor(theColor)
{}
virtual void Execute(){
aColor[0] = int(255.0*myColor.R);
aColor[1] = int(255.0*myColor.G);
aColor[2] = int(255.0*myColor.B);
- myWidget->setBackgroundColor(QColor(aColor[0],aColor[1],aColor[2]));
+ QColor aNewColor (aColor[0],aColor[1],aColor[2]);
+ myVW->setBackgroundColor(aNewColor);
}
};
-
- SUIT_ViewWindow* aVW = GetViewWindow();
+
+ SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(GetViewWindow());
if (aVW)
ProcessVoidEvent(new TEvent(aVW, theColor));
}
struct TBackgroundEvent: public SALOME_Event
{
- QWidget* myWidget;
+ SVTK_ViewWindow* myVW;
typedef SALOMEDS::Color TResult;
TResult myResult;
- TBackgroundEvent(QWidget* theWidget):
- myWidget(theWidget)
+ TBackgroundEvent(SVTK_ViewWindow* theViewWindow):
+ myVW(theViewWindow)
{}
virtual
void
Execute()
{
- const QColor& aColor = myWidget->backgroundColor();
- myResult.R = aColor.red()/255.0;
- myResult.G = aColor.green()/255.0;
- myResult.B = aColor.blue()/255.0;
+ vtkFloatingPointType backint[3];
+ GetRenderer(myVW)->GetBackground(backint);
+ myResult.R = backint[0];
+ myResult.G = backint[1];
+ myResult.B = backint[2];
}
};
View_i::
GetBackground()
{
- SUIT_ViewWindow* aVW = GetViewWindow();
+ SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(GetViewWindow());
if (aVW)
return ProcessEvent(new TBackgroundEvent(aVW));
if (!img.isNull()) {
QString fileName (myFileName);
if (!fileName.isEmpty()) {
- QString fmt = SUIT_Tools::extension(fileName).upper();
+ QString fmt = SUIT_Tools::extension(fileName).toUpper();
if (fmt.isEmpty()) fmt = QString("BMP"); // default format
if (fmt == "JPG" ) fmt = "JPEG";
//QApplication::setOverrideCursor(Qt::waitCursor);
- img.save(fileName, fmt.latin1());
+ img.save(fileName, fmt.toLatin1().data());
myResult = true;
//QApplication::restoreOverrideCursor();
}
SUIT_ViewWindow* View_i::GetViewWindow()
{
if (myViewWindow) {
- QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
- int aPos = aViews.find(myViewWindow);
+ QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
+ int aPos = aViews.indexOf(myViewWindow);
if (aPos < 0)
myViewWindow = NULL;
}
ProcessVoidEvent(new TVoidMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::Repaint));
}
+ struct TCloseViewEvent: public SALOME_Event
+ {
+ SUIT_ViewWindow* myView;
+ TCloseViewEvent (SUIT_ViewWindow* theView):
+ myView(theView)
+ {}
+
+ virtual void Execute()
+ {
+ if ( myView ) myView->close();
+ }
+ };
+
void XYPlot_i::Close()
{
- //jfa: may be need to be enclosed in SALOME_Event?
- SUIT_ViewWindow* aVW = GetViewWindow();
- if (aVW)
- aVW->close();
- //QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
- //int aPos = aViews.find(myViewWindow);
- //if (aPos >= 0)
- // myViewWindow->close();
+ ProcessVoidEvent(new TCloseViewEvent(GetViewWindow()));
+ QApplication::sendPostedEvents();
}
XYPlot_i::~XYPlot_i() {
SUIT_ViewWindow* aVW = GetViewWindow();
if (aVW)
ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
- (aVW, &SUIT_ViewWindow::setCaption, QString(theTitle)));
+ (aVW, &SUIT_ViewWindow::setWindowTitle, QString(theTitle)));
}
char* XYPlot_i::GetTitle()
{
SUIT_ViewWindow* aVW = GetViewWindow();
if (aVW)
- return CORBA::string_dup(aVW->caption().latin1());
+ return CORBA::string_dup( aVW->windowTitle().toLatin1().data());
return CORBA::string_dup("");
}
char* XYPlot_i::GetSubTitle()
{
if (GetViewWindow())
- return CORBA::string_dup(myView->getTitle());
+ return CORBA::string_dup(myView->getTitle().toLatin1().data());
return CORBA::string_dup("");
}
return -1;
}
- class TEnableGridEvent: public SALOME_Event
- {
- public:
- typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool);
- TEnableGridEvent (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,true);
- }
- protected:
- Plot2d_ViewFrame* myView;
- TFun myFun;
- CORBA::Boolean myMajor, myMinor;
- CORBA::Long myNumMajor, myNumMinor;
- };
-
void XYPlot_i::EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
CORBA::Boolean theMinor, CORBA::Long theNumMinor)
{
- if (GetViewWindow())
- ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setXGrid,
- theMajor,theNumMajor,theMinor,theNumMinor));
+ class TEvent: public SALOME_Event
+ {
+ public:
+ TEvent (Plot2d_ViewFrame* theView,
+ CORBA::Boolean theMajor,
+ CORBA::Long theNumMajor,
+ CORBA::Boolean theMinor,
+ CORBA::Long theNumMinor):
+ myView(theView),
+ myMajor(theMajor),
+ myNumMajor(theNumMajor),
+ myMinor(theMinor),
+ myNumMinor(theNumMinor)
+ {}
+
+ virtual void Execute()
+ {
+ myView->setXGrid( myMajor, myNumMajor, myMinor, myNumMinor );
+ }
+ protected:
+ Plot2d_ViewFrame* myView;
+ CORBA::Boolean myMajor, myMinor;
+ CORBA::Long myNumMajor, myNumMinor;
+ };
+
+ if ( GetViewWindow() )
+ ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor ) );
}
- void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor,
- CORBA::Boolean theMinor, CORBA::Long theNumMinor)
+ void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor,
+ CORBA::Long theNumMajor,
+ CORBA::Boolean theMinor,
+ CORBA::Long theNumMinor)
{
- //asl: Plot2d_ViewFrame::setYGrid has more parameters
- //if (GetViewWindow())
- // ProcessVoidEvent(new TEnableGridEvent(myView,&Plot2d_ViewFrame::setYGrid,
- // theMajor,theNumMajor,theMinor,theNumMinor));
+ this->EnableYGrid( theMajor, theNumMajor, theMinor, theNumMinor, false, 0, false, 0 );
}
+ void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor,
+ CORBA::Long theNumMajor,
+ CORBA::Boolean theMinor,
+ CORBA::Long theNumMinor,
+ CORBA::Boolean the2Major,
+ CORBA::Long the2NumMajor,
+ CORBA::Boolean the2Minor,
+ CORBA::Long the2NumMinor)
+ {
+ class TEvent: public SALOME_Event
+ {
+ public:
+ TEvent (Plot2d_ViewFrame* theView,
+ CORBA::Boolean theMajor,
+ CORBA::Long theNumMajor,
+ CORBA::Boolean theMinor,
+ CORBA::Long theNumMinor,
+ CORBA::Boolean the2Major,
+ CORBA::Long the2NumMajor,
+ CORBA::Boolean the2Minor,
+ CORBA::Long the2NumMinor):
+ myView(theView),
+ myMajor(theMajor),
+ myNumMajor(theNumMajor),
+ myMinor(theMinor),
+ myNumMinor(theNumMinor),
+ my2Major(the2Major),
+ my2NumMajor(the2NumMajor),
+ my2Minor(the2Minor),
+ my2NumMinor(the2NumMinor)
+ {}
+
+ virtual void Execute()
+ {
+ myView->setYGrid( myMajor, myNumMajor, myMinor, myNumMinor,
+ my2Major, my2NumMajor, my2Minor, my2NumMinor);
+ }
+ protected:
+ Plot2d_ViewFrame* myView;
+ CORBA::Boolean myMajor, myMinor, my2Major, my2Minor;
+ CORBA::Long myNumMajor, myNumMinor, my2NumMajor, my2NumMinor;
+ };
+
+ if (GetViewWindow())
+ ProcessVoidEvent( new TEvent( myView, theMajor, theNumMajor, theMinor, theNumMinor,
+ the2Major, the2NumMajor, the2Minor, the2NumMinor ) );
+ }
+
class TSetScaleModeEvent: public SALOME_Event
{
public:
char* XYPlot_i::GetXTitle()
{
if (GetViewWindow())
- return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle));
+ return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::XTitle).toLatin1().data());
return CORBA::string_dup("");
}
char* XYPlot_i::GetYTitle()
{
if (GetViewWindow())
- return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle));
+ return CORBA::string_dup(myView->getTitle(Plot2d_ViewFrame::YTitle).toLatin1().data());
return CORBA::string_dup("");
}
virtual void Execute()
{
+ Qtx::VisibilityState state = (myDisplaing == eDisplay ||myDisplaing == eDisplayOnly) ?
+ Qtx::ShownState : Qtx::HiddenState;
// is it Curve ?
if (Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
- UpdatePlot2d(myView,myDisplaing,aCurve);
+ UpdatePlot2d(aCurve,myDisplaing,myView);
+ VISU::SetVisibilityState(aCurve->GetEntry(),state);
+ VISU::CurveVisibilityChanged(aCurve, myDisplaing , false, true, true);
}
// is it Container ?
if (Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
+ VISU::SetVisibilityState(aContainer->GetEntry(),state);
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);
+ UpdatePlot2d(aCurve,myDisplaing,myView);
+ VISU::CurveVisibilityChanged(aCurve, myDisplaing , true, true, true);
}
}
myView->Repaint();
}
}
if (!aCStudy) return;
- _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry().latin1());
+ _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry());
if (TableSO) {
_PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO);
for (; Iter->More(); Iter->Next()) {
CORBA::Object_var childObject = VISU::ClientSObjectToObject(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()));
+ if (!CORBA::is_nil(aCurve)) {
+ Curve_i* crv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
+ UpdatePlot2d(crv, myDisplaing, myView);
+ VISU::CurveVisibilityChanged(crv, myDisplaing , true, false, true);
+ }
}
}
myView->Repaint();
+ VISU::SetVisibilityState(aTable->GetEntry(),state);
}
}
}
SalomeApp_Application* myApplication;
VISU::Table_i* myTable;
- typedef VisuGUI_TableDlg* TResult;
+ typedef VISU_TableDlg* TResult;
TResult myResult;
TCreateTableViewEvent (SalomeApp_Application* theApplication,
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(myTable->GetObjectEntry());
- if (aSObject) {
- myResult = new VisuGUI_TableDlg (myApplication->desktop(),
- aSObject,
- false,
- VisuGUI_TableDlg::ttAuto,
- Qt::Vertical);
- myResult->show();
- }
+ myResult = new VISU_TableDlg (myApplication->desktop(),
+ aCStudy,
+ myTable,
+ false,
+ VISU_TableDlg::ttAuto,
+ Qt::Vertical);
+ myResult->show();
}
}
}
void TableView_i::SetTitle (const char* theTitle)
{
- ProcessVoidEvent(new TVoidMemFun1ArgEvent<VisuGUI_TableDlg,const QString&,QString>
- (myView, &VisuGUI_TableDlg::setCaption, QString(theTitle)));
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TableDlg,const QString&,QString>
+ (myView, &VISU_TableDlg::setWindowTitle, QString(theTitle)));
}
char* TableView_i::GetTitle()
{
//jfa: may be need to be enclosed in SALOME_Event?
- return CORBA::string_dup(myView->caption().latin1());
+ return CORBA::string_dup(myView->windowTitle().toLatin1().data());
}
void TableView_i::Close()
{
class TEvent: public SALOME_Event
{
- SUIT_ViewWindow* myVW;
+ SUIT_ViewWindow* myViewWindow;
public:
TEvent(SUIT_ViewWindow* theViewWindow):
- myVW(theViewWindow)
+ myViewWindow(theViewWindow)
{}
virtual void Execute()
{
- SVTK_ViewWindow* vf = dynamic_cast<SVTK_ViewWindow*>(myVW);
- 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);
- }
+ SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(myViewWindow);
+ vtkRenderer* aRenderer = aViewWindow->getRenderer();
+ VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+ vtkActorCollection* anActors = aCopy.GetActors();
+ anActors->InitTraversal();
+ while (vtkActor *anAct = anActors->GetNextActor()) {
+ if (VISU_ActorBase* anActor = dynamic_cast<VISU_ActorBase*>(anAct)) {
+ if (anActor->GetVisibility())
+ anActor->UpdateFromFactory();
}
}
- RepaintView(myVW);
+ RepaintView(myViewWindow);
}
};
- SUIT_ViewWindow* aVW = GetViewWindow();
- if (aVW)
- ProcessVoidEvent(new TEvent(aVW));
+ if (SUIT_ViewWindow* aViewWindow = GetViewWindow())
+ ProcessVoidEvent(new TEvent(aViewWindow));
}
- bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName)
+ bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
{
MESSAGE("View3D_i::SaveViewParams()");
- if (!theViewManager || !theName)
+ if (!theViewManager || theName == "")
return false;
_PTR(Study) aCStudy;
if (!aCStudy)
return false;
- if (strcmp(theName, "") != 0) {
- std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
+ if (theName != "") {
+ std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName.c_str(), "VISU");
_PTR(GenericAttribute) anAttr;
int iEnd = aList.size();
for (int i = 0; i < iEnd; i++) {
_PTR(SObject) anObj = aList[i];
string anEntry = anObj->GetID();
if(MYDEBUG) MESSAGE("View3D_i::SaveViewParams - anEntry = " << anEntry);
- if (anObj->FindAttribute(anAttr, "AttributeComment")) {
- _PTR(AttributeComment) aCmnt (anAttr);
+ if (anObj->FindAttribute(anAttr, "AttributeString")) {
+ _PTR(AttributeString) aCmnt (anAttr);
string aComm (aCmnt->Value());
if (MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = " << aComm);
if (aComm.compare(View3D_i::myComment) >= 0) {
}
_PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
string aSComponentEntry = aSComponent->GetID();
- string anEntry = CreateAttributes(aCStudy, aSComponentEntry.c_str(), "", "", theName, "",
+ string anEntry = CreateAttributes(aCStudy,
+ aSComponentEntry.c_str(),
+ "",
+ "",
+ theName,
+ "",
ToString(theViewManager->getActiveView()).c_str());
return true;
}
class TSaveViewParamsEvent: public SALOME_Event
{
SUIT_ViewManager* myViewMgr;
- const char* myName;
+ std::string myName;
public:
TSaveViewParamsEvent (SUIT_ViewManager* theViewManager,
- const char* theName):
+ const std::string& theName):
myViewMgr(theViewManager),
myName(theName)
{}
TResult myResult;
};
- CORBA::Boolean View3D_i::SaveViewParams (const char* theName)
+ CORBA::Boolean View3D_i::SaveViewParams (const char* theViewParamsName)
{
- return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theName));
+ return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theViewParamsName));
}
- bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const char* theName)
+ bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
{
_PTR(Study) aCStudy;
if (SUIT_Study* aSStudy = theViewManager->study()) {
_PTR(SObject) anObj = aList[i];
string anEntry = anObj->GetID();
if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - anEntry = " << anEntry);
- if (anObj->FindAttribute(anAttr, "AttributeComment")) {
- _PTR(AttributeComment) aCmnt (anAttr);
- QString strIn(aCmnt->Value().c_str());
- Storable::TRestoringMap aMap;
- Storable::StrToMap(strIn, aMap);
- if (Storable::FindValue(aMap, "myComment").compare
- (View3D_i::myComment.c_str()) >= 0) {
- if (MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = " << strIn);
- Restore(theViewManager->getActiveView(), aMap);
- return true;
- }
+ Storable::TRestoringMap aMap = Storable::GetStorableMap(anObj);
+ if (Storable::FindValue(aMap, "myComment") == View3D_i::myComment.c_str()) {
+ Restore(theViewManager->getActiveView(), aMap);
+ return true;
}
}
return false;
class TRestoreViewParamsEvent: public SALOME_Event
{
SUIT_ViewManager* myViewMgr;
- const char* myName;
+ std::string myName;
public:
TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager,
- const char* theName):
+ const std::string& theName):
myViewMgr(theViewManager),
myName(theName)
{}
TResult myResult;
};
- CORBA::Boolean View3D_i::RestoreViewParams (const char* theName)
+ CORBA::Boolean View3D_i::RestoreViewParams (const char* theViewParamsName)
{
- return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theName));
+ return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theViewParamsName));
}
void View3D_i::Restore (SUIT_ViewWindow* theViewWindow,
void View3D_i::ToStream (SUIT_ViewWindow* theViewWindow, std::ostringstream& theStr)
{
- Storable::DataToStream(theStr,"myType",VISU::TVIEW3D);
-
vtkFloatingPointType backint[3];
GetRenderer(theViewWindow)->GetBackground(backint);
Storable::DataToStream(theStr,"myColor.R",backint[0]);
void View3D_i::Close()
{
- //jfa: may be need to be enclosed in SALOME_Event?
- SUIT_ViewWindow* aVW = GetViewWindow();
- if (aVW)
- aVW->close();
- //QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
- //int aPos = aViews.find(myViewWindow);
- //if (aPos >= 0)
- // myViewWindow->close();
+ ProcessVoidEvent(new TCloseViewEvent(GetViewWindow()));
+ QApplication::sendPostedEvents();
}
-
+
View3D_i::~View3D_i()
{
if(MYDEBUG) MESSAGE("View3D_i::~View3D_i");
SUIT_ViewWindow* aVW = GetViewWindow();
if (aVW)
ProcessVoidEvent(new TVoidMemFun1ArgEvent<SUIT_ViewWindow,const QString&,QString>
- (aVW,&SUIT_ViewWindow::setCaption,QString(theTitle)));
+ (aVW,&SUIT_ViewWindow::setWindowTitle,QString(theTitle)));
}
char* View3D_i::GetTitle()
{
SUIT_ViewWindow* aVW = GetViewWindow();
if (aVW)
- return CORBA::string_dup(aVW->caption().latin1());
+ return CORBA::string_dup(aVW->windowTitle().toLatin1().data());
return CORBA::string_dup("");
}
}
};
+ class TDisplayTableEvent: public SALOME_Event
+ {
+ SUIT_ViewWindow* myVW;
+ PointMap3d_i* myTable;
+ int myDisplaying;
+ public:
+ TDisplayTableEvent( SUIT_ViewWindow* theView,
+ PointMap3d_i* theTable,
+ int theDisplaying ) :
+ myVW (theView),
+ myTable (theTable),
+ myDisplaying (theDisplaying)
+ {}
+ virtual void Execute() {
+ SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(myVW);
+ VISU_PointMap3dActor* anActor = myTable->CreateActor();
+ myTable->UpdateActor( anActor );
+ aViewWindow->AddActor( anActor );
+ }
+ };
+
void View3D_i::EraseAll()
{
if(MYDEBUG) MESSAGE("View3D_i::EraseAll");
if(MYDEBUG) MESSAGE("View3D_i::Display");
SUIT_ViewWindow* aVW = GetViewWindow();
CORBA::Object_ptr anObj = thePrsObj;
- Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
+ Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
if (aVW && aPrs)
ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplay));
+ else if (aVW && !aPrs) {
+ PointMap3d_i* aTable = dynamic_cast<PointMap3d_i*>(VISU::GetServant(anObj).in());
+ if (aTable)
+ ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplay));
+ }
}
void View3D_i::DisplayOnly (PrsObject_ptr thePrsObj)
Prs3d_i* aPrs = dynamic_cast<Prs3d_i*>(VISU::GetServant(anObj).in());
if (aVW && aPrs)
ProcessVoidEvent(new TUpdateViewerEvent(aVW,aPrs,eDisplayOnly));
+ else if (aVW && !aPrs) {
+ PointMap3d_i* aTable = dynamic_cast<PointMap3d_i*>(VISU::GetServant(anObj).in());
+ if (aTable)
+ ProcessVoidEvent(new TDisplayTableEvent(aVW, aTable, eDisplayOnly));
+ }
}
void View3D_i::FitAll()
if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView");
SUIT_ViewWindow* aVW = GetViewWindow();
if (aVW)
- ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,aVW,thePosition));
+ ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetPointOfView,aVW,thePosition));
}
void View3D_i::GetPointOfView (SUIT_ViewWindow* theViewWindow,
if(MYDEBUG) MESSAGE("View3D_i::SetViewUp");
SUIT_ViewWindow* aVW = GetViewWindow();
if (aVW)
- ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,aVW,theViewUp));
+ ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetViewUp,aVW,theViewUp));
}
void View3D_i::GetViewUp (SUIT_ViewWindow* theViewWindow,
if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint");
SUIT_ViewWindow* aVW = GetViewWindow();
if (aVW)
- ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,aVW,theCoord));
+ ProcessVoidEvent(new TSet3DViewParamEvent(&View3D_i::SetFocalPoint,aVW,theCoord));
}
if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale");
SUIT_ViewWindow* aVW = GetViewWindow();
if (aVW)
- ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,aVW,theScale));
+ ProcessVoidEvent(new TSetViewParamEvent(&View3D_i::SetParallelScale,aVW,theScale));
}
CORBA::Double View3D_i::GetParallelScale (SUIT_ViewWindow* theViewWindow)
if (!aPrs) {
myError = "Corrupted presentation";
} else {
- VISU_Actor* anActor = VISU::GetActor(aPrs, vw);
+ VISU_Actor* anActor = VISU::FindActor(vw, aPrs);
if (!anActor) {
myError = "No actor found. Display the presentation at first.";
} else {
myResult("Unknown error occured")
{}
virtual void Execute() {
+ VISU::VISUType aType = myPrs->GetType();
switch (myPrsType) {
case VISU::INSIDEFRAME:
{
- VISU::VISUType aType = myPrs->GetType();
if (aType != VISU::TSCALARMAP &&
aType != VISU::TDEFORMEDSHAPE &&
- aType != VISU::TSCALARMAPONDEFORMEDSHAPE) {
+ aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
+ aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) {
myResult = "Insideframe representation is not available for this type of presentations.";
return;
}
}
break;
case VISU::SURFACEFRAME:
- myResult = "Surfaceframe representation is available only for mesh presentation.";
- return;
+ {
+ if (aType != VISU::TSCALARMAP &&
+ aType != VISU::TDEFORMEDSHAPE &&
+ aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
+ aType != VISU::TDEFORMEDSHAPEANDSCALARMAP &&
+ aType != VISU::TCUTPLANES &&
+ aType != VISU::TISOSURFACES &&
+ aType != VISU::TPLOT3D) {
+ myResult = "Surfaceframe representation is not available for this type of presentations.";
+ return;
+ }
+ }
+ break;
case VISU::SHRINK:
myResult = "Use SetShrinked() method to shrink/unshrink presentation.";
return;
}
};
+ class TSetQuadratic2DPresentationTypeEvent: public TPrsManageEvent {
+ private:
+ Quadratic2DPresentationType myPrsType;
+ public:
+ typedef string TResult;
+ TResult myResult;
+ TSetQuadratic2DPresentationTypeEvent(View3D_i* theView3D,
+ ScalarMap_ptr thePrs,
+ Quadratic2DPresentationType theType):
+ TPrsManageEvent(theView3D, thePrs), myPrsType(theType),
+ myResult("Unknown error occured")
+ {}
+ virtual void Execute()
+ {
+ VISU::VISUType aType = myPrs->GetType();
+ if (aType != VISU::TSCALARMAP &&
+ aType != VISU::TDEFORMEDSHAPE &&
+ aType != VISU::TSCALARMAPONDEFORMEDSHAPE &&
+ aType != VISU::TDEFORMEDSHAPEANDSCALARMAP) {
+ myResult = "2D Quadratic element representation is not available for this type of presentations.";
+ return;
+ }
+ if (VISU_Actor* anActor = GetMyActor()) {
+ if(myPrsType == VISU::LINES)
+ anActor->SetQuadratic2DRepresentation(VISU_Actor::eLines);
+ else if(myPrsType == VISU::ARCS)
+ anActor->SetQuadratic2DRepresentation(VISU_Actor::eArcs);
+
+ SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(myView3D->GetViewWindow());
+ vw->Repaint();
+ myResult = "";
+ } else {
+ myResult = myError;
+ }
+ }
+ };
+
+ class TGetQuadratic2DPresentationTypeEvent: public TPrsManageEvent {
+ public:
+ typedef VISU::Quadratic2DPresentationType TResult;
+ TResult myResult;
+ TGetQuadratic2DPresentationTypeEvent(View3D_i* theView3D, ScalarMap_ptr thePrs):
+ TPrsManageEvent(theView3D, thePrs), myResult(VISU::LINES) {}
+ virtual void Execute() {
+ if (VISU_Actor* anActor = GetMyActor()) {
+ if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eLines)
+ myResult = VISU::LINES;
+ else if(anActor->GetQuadratic2DRepresentation() == VISU_Actor::eArcs)
+ myResult = VISU::ARCS;
+ }
+ }
+ };
+
PresentationType View3D_i::GetPresentationType(ScalarMap_ptr thePrs)
{
return ProcessEvent(new TGetPrsTypeEvent(this,thePrs));
return ProcessEvent(new TGetLineWidthEvent(this,thePrs));
}
+ Quadratic2DPresentationType View3D_i::GetQuadratic2DPresentationType(ScalarMap_ptr thePrs)
+ {
+ return ProcessEvent(new TGetQuadratic2DPresentationTypeEvent(this,thePrs));
+ }
+
char* View3D_i::SetPresentationType(ScalarMap_ptr thePrs, PresentationType thePrsType)
{
string aRet = ProcessEvent(new TSetPrsTypeEvent(this,thePrs,thePrsType));
string aRet = ProcessEvent(new TSetLineWidthEvent(this,thePrs,theLineWidth));
return CORBA::string_dup(aRet.c_str());
}
+
+ char* View3D_i::SetQuadratic2DPresentationType(ScalarMap_ptr thePrs, Quadratic2DPresentationType theType)
+ {
+ string aRet = ProcessEvent(new TSetQuadratic2DPresentationTypeEvent(this,thePrs,theType));
+ return CORBA::string_dup(aRet.c_str());
+ }
}
+
+