X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVISUGUI%2FVisuGUI_Selection.cxx;h=3828a0ca0dceb862bf6b56ac4f53d7b457c2f3b1;hb=498e8f4fec90f3e034affd2e7350682558ad4b4e;hp=46549cc52a6e8f37bd71a5dae876261c0de6918f;hpb=3f4152dedc1ae968267cfb8a079f261ec0088ed0;p=modules%2Fvisu.git diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 46549cc5..3828a0ca 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -1,6 +1,6 @@ -// VISU VISUGUI : GUI of VISU component +// Copyright (C) 2007-2008 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 @@ -17,622 +17,773 @@ // 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 VISUGUI : GUI of VISU component // File : VisuGUI_Selection.cxx -// Author : Laurent CORNABE & Hubert ROLLAND +// Author : Sergey Anikin // Module : VISU -// $Header$ - +// #include "VisuGUI_Selection.h" -#include "VisuGUI.h" -#include "VisuGUI_Tools.h" #include "VisuGUI_ViewTools.h" +#include "VisuGUI_Tools.h" + +#include "VISU_Result_i.hh" +#include "VISU_Gen_i.hh" #include "VISU_Actor.h" -#include "VISU_PrsObject_i.hh" -#include "VISU_Prs3d_i.hh" -#include "VISU_PipeLine.hxx" +#include "VISU_ScalarMapAct.h" +#include "VISU_GaussPtsAct.h" #include "SalomeApp_Study.h" -#include "SalomeApp_Application.h" -#include "LightApp_Application.h" -#include "LightApp_SelectionMgr.h" -#include "LightApp_VTKSelector.h" - -#include "SUIT_MessageBox.h" -#include "SUIT_ViewWindow.h" -#include "SUIT_Session.h" -#include "SUIT_ResourceMgr.h" - -#include "SALOME_ListIO.hxx" -#include "SALOME_ListIteratorOfListIO.hxx" - -#include "SVTK_ViewWindow.h" -#include "SVTK_Selector.h" - -#include "utilities.h" - -// OCCT Includes -#include -#include - -// QT Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// VTK Includes -#include -#include -#include -#include -#include - -// STL Includes -#include - -using namespace std; - -static VisuGUI_SelectionDlg* mySelectionDlg = NULL; - -VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (const SalomeApp_Module* theModule): - QDialog(VISU::GetDesktop(theModule), - 0, - false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), - mySelectionMgr(NULL), - myModule(theModule) -{ - if (mySelectionDlg) - mySelectionDlg->close(true); - - setCaption( "Data on elements" ); - setSizeGripEnabled(TRUE); - - QGridLayout* TopLayout = new QGridLayout (this); - TopLayout->setSpacing(6); - TopLayout->setMargin(11); - TopLayout->setRowStretch(0, 0); - TopLayout->setRowStretch(1, 0); - TopLayout->setRowStretch(2, 1); - TopLayout->setRowStretch(3, 0); - - QHButtonGroup* aTypeBox = new QHButtonGroup ("Selection", this); - - QRadioButton* aPointBtn = - new QRadioButton ("Point", aTypeBox); - new QRadioButton ("Cell" , aTypeBox); - new QRadioButton ("Actor", aTypeBox); - aPointBtn->setChecked(true); - - connect(aTypeBox, SIGNAL(clicked(int)), this, SLOT(onSelectionChange(int))); - - TopLayout->addWidget(aTypeBox, 0, 0); - - QWidget* aNamePane = new QWidget (this); - QGridLayout* aNameLay = new QGridLayout (aNamePane); - - QLabel* aMeshLbl = new QLabel ("Mesh name: ", aNamePane); - myMeshName = new QLabel (aNamePane); - - QLabel* aFieldLbl = new QLabel ("Field name: ", aNamePane); - myFieldName = new QLabel (aNamePane); - - aNameLay->addWidget(aMeshLbl, 0, 0); - aNameLay->addWidget(myMeshName, 0, 1); - aNameLay->addWidget(aFieldLbl, 1, 0); - aNameLay->addWidget(myFieldName, 1, 1); - - TopLayout->addWidget(aNamePane, 1, 0); - - myWidgetStack = new QWidgetStack (this); - - // Create Points pane - myPointsPane = new QVBox (myWidgetStack); - myPointsPane->layout()->setSpacing(6); - - QGroupBox* aDataGrp = new QGroupBox (2, Qt::Horizontal, "Data of Point", myPointsPane); - aDataGrp->layout()->setSpacing(6); - - new QLabel ("ID:", aDataGrp); - myIDValLbl = new QLineEdit ("", aDataGrp); - QIntValidator* aIntValidator = new QIntValidator (myIDValLbl); - aIntValidator->setBottom(0); - myIDValLbl->setValidator(aIntValidator); - connect(myIDValLbl, SIGNAL(textChanged(const QString&)), this, SLOT(onPointIdEdit(const QString&))); - - new QLabel ("Scalar Value:", aDataGrp); - myScalarValLbl = new QLabel ("", aDataGrp); - new QLabel ("Vector Value:", aDataGrp); - myVectorValLbl = new QLabel ("", aDataGrp); - myVectorValLbl->setMinimumWidth(150); - - QGroupBox* aCoordGrp = new QGroupBox (2, Qt::Horizontal, "Coordinates", myPointsPane); - aCoordGrp->layout()->setSpacing(6); - new QLabel ("X:", aCoordGrp); - myXValLbl = new QLabel ("", aCoordGrp); - new QLabel ("Y:", aCoordGrp); - myYValLbl = new QLabel ("", aCoordGrp); - new QLabel ("Z:",aCoordGrp ); - myZValLbl = new QLabel ("", aCoordGrp); - - - myWidgetStack->addWidget(myPointsPane, 0); - - // Create Cells pane - myCellsPane = new QWidget (myWidgetStack); - QGridLayout* aCellLayout = new QGridLayout (myCellsPane); - aCellLayout->setSpacing(6); - aCellLayout->setRowStretch(0, 0); - aCellLayout->setRowStretch(1, 1); - - QGroupBox* aCellGrp = new QGroupBox(2, Qt::Horizontal, "Data of Cell", myCellsPane); +#include "LightApp_Study.h" +#include "LightApp_Displayer.h" - new QLabel ("ID:", aCellGrp); - myCellIDValLbl = new QLineEdit ("", aCellGrp); - myCellIDValLbl->setValidator(aIntValidator); - connect(myCellIDValLbl, SIGNAL(textChanged(const QString&)), this, SLOT(onCellIdEdit(const QString&))); - - new QLabel ("Scalar Value:", aCellGrp); - myCellScalarValLbl = new QLabel ("", aCellGrp); - new QLabel ("Vector Value:", aCellGrp); - myCellVectorValLbl = new QLabel ("", aCellGrp); - - aCellLayout->addWidget(aCellGrp, 0, 0); - - myListPoints = new QTable (myCellsPane); - myListPoints->setReadOnly(true); - myListPoints->setNumCols(6); - myListPoints->setNumRows(0); - myListPoints->setColumnWidth(0, 40); - myListPoints->setColumnWidth(1, 40); - myListPoints->setColumnWidth(2, 40); - myListPoints->setColumnWidth(3, 40); - myListPoints->setSelectionMode(QTable::NoSelection); - QHeader* aHeader = myListPoints->horizontalHeader(); - aHeader->setLabel( 0, "ID" ); - aHeader->setLabel( 1, "X" ); - aHeader->setLabel( 2, "Y" ); - aHeader->setLabel( 3, "Z" ); - aHeader->setLabel( 4, "Scalar" ); - aHeader->setLabel( 5, "Vector" ); +using namespace VISU; - aCellLayout->addWidget(myListPoints, 1, 0); +////////////////////////////////////////////////// +// Class: VisuGUI_Selection +////////////////////////////////////////////////// - myWidgetStack->addWidget(myCellsPane, 1); - - // Actor Pane - myActorsPane = new QVBox (myWidgetStack); - myActorsPane->layout()->setSpacing(6); - QGroupBox* aPosGrp = new QGroupBox (2, Qt::Horizontal, "Position", myActorsPane); - aPosGrp->layout()->setSpacing(6); - new QLabel ("X:", aPosGrp); - myXPosLbl = new QLabel ("0", aPosGrp); - new QLabel ("Y:", aPosGrp); - myYPosLbl = new QLabel ("0", aPosGrp); - new QLabel ("Z:", aPosGrp); - myZPosLbl = new QLabel ("0", aPosGrp); - - QGroupBox* aSizeGrp = new QGroupBox (2, Qt::Horizontal, "Size", myActorsPane); - aSizeGrp->layout()->setSpacing(6); - new QLabel ("dX:", aSizeGrp); - myDXLbl = new QLabel ("0", aSizeGrp); - new QLabel ("dY:", aSizeGrp); - myDYLbl = new QLabel ("0", aSizeGrp); - new QLabel ("dZ:",aSizeGrp ); - myDZLbl = new QLabel ("0", aSizeGrp); - - myWidgetStack->addWidget(myActorsPane, 2); - - - TopLayout->addWidget(myWidgetStack, 2, 0); - - // Create buttons group - QHBox* aBtnBox = new QHBox (this); - QHBoxLayout* aBtnLayout = (QHBoxLayout*)aBtnBox->layout(); - aBtnLayout->addStretch(); - - QPushButton* aCloseBtn = new QPushButton (tr("BUT_CLOSE"), aBtnBox); - connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close())); - - QPushButton* aHelpBtn = new QPushButton (tr("BUT_HELP"), aBtnBox); - connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp())); - - TopLayout->addWidget(aBtnBox, 3, 0); - - SalomeApp_Application* anApp = dynamic_cast - (SUIT_Session::session()->activeApplication()); - mySelectionMgr = anApp->selectionMgr(); - connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionEvent())); - - //connect(visuGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(close())); - - myFl = false; - - // Activate Points pane - myWidgetStack->raiseWidget(myPointsPane); - if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myModule)) - aViewWindow->SetSelectionMode(NodeSelection); - onSelectionEvent(); +//--------------------------------------------------------------- +QVariant VisuGUI_Selection::parameter( const int ind, const QString& p ) const +{ + QVariant val( LightApp_Selection::parameter( ind, p ) ); + if ( !val.isValid() ) { + if ( p == "type" ) val = QVariant( type( ind ) ); + else if ( p == "nbComponents" ) val = QVariant( nbComponents( ind ) ); + else if ( p == "medEntity" ) val = QVariant( medEntity( ind ) ); + else if ( p == "medSource" ) val = QVariant( medSource( ind ) ); + else if ( p == "representation" ) val = QVariant( representation( ind ) ); + else if ( p == "nbTimeStamps" ) val = QVariant( nbTimeStamps( ind ) ); + else if ( p == "nbChildren" ) val = QVariant( nbChildren( ind ) ); + else if ( p == "nbNamedChildren") val = QVariant( nbNamedChildren( ind ) ); + else if ( p == "isVisible" ) val = QVariant( isVisible( ind ) ); + else if ( p == "isShrunk" ) val = QVariant( isShrunk( ind ) ); + else if ( p == "hasActor" ) val = QVariant( hasActor( ind ) ); + else if ( p == "isShading" ) val = QVariant( isShading( ind ) ); + else if ( p == "isScalarMapAct" ) val = QVariant( isScalarMapAct( ind ) ); + else if ( p == "isGaussPtsAct" ) val = QVariant( isGaussPtsAct( ind ) ); + else if ( p == "isVisuComponent") val = QVariant( isVisuComponent( ind ) ); + else if ( p == "fullResolution" ) val = QVariant( fullResolution( ind ) ); + else if ( p == "mediumResolution" ) val = QVariant( mediumResolution( ind ) ); + else if ( p == "lowResolution" ) val = QVariant( lowResolution( ind ) ); + else if ( p == "resolutionState" ) val = QVariant( resolutionState( ind ) ); + else if ( p == "isThereAreVisibleCurves" ) val = QVariant( findDisplayedCurves( ind, false ) ); + else if ( p == "isThereAreHiddenCurves" ) val = QVariant( findDisplayedCurves( ind, true ) ); + else if ( p == "hasCurves" ) val = QVariant( hasCurves( ind ) ); + else if ( p == "isPlot2dViewer" ) val = QVariant( Plot2dViewerType( ind ) ); + else if ( p == "isValuesLabeled" ) val = QVariant( isValuesLabeled( ind ) ); + else if ( p == "isScalarBarVisible" ) val = QVariant( isScalarBarVisible( ind ) ); + else if ( p == "quadratic2DMode" ) val = QVariant( quadratic2DMode(ind) ); + } - mySelectionDlg = this; + return val; } -VisuGUI_SelectionDlg::~VisuGUI_SelectionDlg() + +//--------------------------------------------------------------- +// Macro for converting VISU enumeration items into corresponding strings +#define ENUM2STRING( x, y ) \ + case y: \ + x = QString( #y ); \ + break + +QString VisuGUI_Selection::type( const int ind ) const { -} + QString aResStr; + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return aResStr; + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, (const char*)entry( ind ).toLatin1()); + VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject); + + VISU::Base_i* aBase = anObjectInfo.myBase; + if(aBase){ + VISU::VISUType aType = aBase->GetType(); + if(aType == VISU::TCOLOREDPRS3DHOLDER){ + CORBA::Object_var anObject = ClientSObjectToObject(anObjectInfo.mySObject); + VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject); + aType = aHolder->GetPrsType(); + } + switch (aType) { + ENUM2STRING( aResStr, VISU::TVISUGEN ); + ENUM2STRING( aResStr, VISU::TRESULT ); + ENUM2STRING( aResStr, VISU::TTABLE ); + ENUM2STRING( aResStr, VISU::TCURVE ); + ENUM2STRING( aResStr, VISU::TCONTAINER ); + ENUM2STRING( aResStr, VISU::TMESH ); + ENUM2STRING( aResStr, VISU::TSCALARMAP ); + ENUM2STRING( aResStr, VISU::TISOSURFACES ); + ENUM2STRING( aResStr, VISU::TDEFORMEDSHAPE ); + ENUM2STRING( aResStr, VISU::TSCALARMAPONDEFORMEDSHAPE ); + ENUM2STRING( aResStr, VISU::TCUTPLANES ); + ENUM2STRING( aResStr, VISU::TCUTLINES ); + ENUM2STRING( aResStr, VISU::TVECTORS ); + ENUM2STRING( aResStr, VISU::TSTREAMLINES ); + ENUM2STRING( aResStr, VISU::TPLOT3D ); + ENUM2STRING( aResStr, VISU::TANIMATION ); + ENUM2STRING( aResStr, VISU::TPOINTMAP3D ); + } + } + + if(aResStr.isNull()){ + VISU::VISUType aType = VISU::Storable::RestoringMap2Type(aMap); + switch (aType) { + ENUM2STRING( aResStr, VISU::TENTITY ); + ENUM2STRING( aResStr, VISU::TFAMILY ); + ENUM2STRING( aResStr, VISU::TGROUP ); + ENUM2STRING( aResStr, VISU::TVIEW3D ); + ENUM2STRING( aResStr, VISU::TFIELD ); + ENUM2STRING( aResStr, VISU::TTIMESTAMP ); + } + } -void VisuGUI_SelectionDlg::onSelectionChange (int theId) -{ - SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myModule); - if (!aViewWindow) return; - - switch (theId) { - case 0: // Points - myWidgetStack->raiseWidget(myPointsPane); - aViewWindow->SetSelectionMode(NodeSelection); - onPointIdEdit(myIDValLbl->text()); - break; - case 1: // Cells - myWidgetStack->raiseWidget(myCellsPane); - aViewWindow->SetSelectionMode(CellSelection); - onCellIdEdit(myCellIDValLbl->text()); - break; - case 2: // Actor - myWidgetStack->raiseWidget(myActorsPane); - aViewWindow->SetSelectionMode(ActorSelection); - onSelectionEvent(); + if(aResStr.isNull()){ + bool anIsExist; + QString aVal = VISU::Storable::FindValue(aMap, "myComment", &anIsExist); + if ( anIsExist && aVal != "MESH" ) + aResStr = "VISU::T" + aVal; } + + return aResStr; } -void VisuGUI_SelectionDlg::closeEvent (QCloseEvent* theEvent) +//--------------------------------------------------------------- +QString VisuGUI_Selection::nbComponents( const int ind ) const { - if (mySelectionDlg) { - mySelectionDlg = NULL; - disconnect(mySelectionMgr,0,0,0); - if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myModule)) { - switch(aViewWindow->SelectionMode()){ - case NodeSelection: - case CellSelection: - aViewWindow->SetSelectionMode(ActorSelection); - break; - } - } - } - QDialog::closeEvent(theEvent); + QString aResStr; + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return aResStr; + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, (const char*)entry( ind ).toLatin1()); + VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject); + + bool isExist; + QString aVal = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist); + if ( isExist ) + aResStr = aVal; + return aResStr; } -template QString getValue(TData* theData, int theId){ - if (vtkDataArray *aScalar = theData->GetScalars()){ - vtkFloatingPointType aVal = aScalar->GetTuple1(theId); - return QString::number(aVal); - } else { - return QString("No data"); - } + +//--------------------------------------------------------------- +QString VisuGUI_Selection::resolutions( const int ind ) const +{ + QString aResStr; + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return aResStr; + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind ).toLatin1().data()); + VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject); + + bool isExist; + QString aVal = VISU::Storable::FindValue(aMap,"myResolutions",&isExist); + if ( isExist ) + aResStr = aVal; + + return aResStr; } -template QString getVector(TData* theData, int theId){ - if (vtkDataArray *aVector = theData->GetVectors()) { - vtkFloatingPointType *aVal = aVector->GetTuple3(theId); - return QString("%1; %2; %3").arg(aVal[0]).arg(aVal[1]).arg(aVal[2]); - } else { - return QString("No data"); - } + +//--------------------------------------------------------------- +QString VisuGUI_Selection::resolution( const int ind, char theResoltuion ) const +{ + QString aResStr; + + QString aResolutions = resolutions( ind ); + if(aResolutions.isEmpty()) + return aResStr; + + if(aResolutions.indexOf(theResoltuion) != -1) + aResStr = "1"; + else + aResStr = "0"; + + return aResStr; } -#define ABS(a) (a>=0)?a:-a -void VisuGUI_SelectionDlg::onSelectionEvent() { - SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myModule); - if (!aViewWindow) return; +//--------------------------------------------------------------- +QString VisuGUI_Selection::fullResolution( const int ind ) const +{ + return resolution( ind, 'F'); +} + + +//--------------------------------------------------------------- +QString VisuGUI_Selection::mediumResolution( const int ind ) const +{ + return resolution( ind, 'M'); +} + + +//--------------------------------------------------------------- +QString VisuGUI_Selection::lowResolution( const int ind ) const +{ + return resolution( ind, 'L'); +} - switch (aViewWindow->SelectionMode()) { - case NodeSelection: - case CellSelection: - case ActorSelection: - break; - default: - close( TRUE ); - return; + +//--------------------------------------------------------------- +QString VisuGUI_Selection::resolutionState( const int ind ) const +{ + QString aResStr; + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return aResStr; + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind ).toLatin1().data()); + VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject); + + bool isExist; + QString aVal = VISU::Storable::FindValue(aMap,"myState",&isExist); + if ( isExist ) { + if ( aVal.toInt() == VISU::Result::FULL ) + aResStr = "F"; + if ( aVal.toInt() == VISU::Result::MEDIUM ) + aResStr = "M"; + if ( aVal.toInt() == VISU::Result::LOW ) + aResStr = "L"; + if ( aVal.toInt() == VISU::Result::HIDDEN ) + aResStr = "H"; } - if (myFl) return; - myFl = true; + return aResStr; +} - int aType = myWidgetStack->id(myWidgetStack->visibleWidget()); - SalomeApp_Application* anApp = dynamic_cast - (SUIT_Session::session()->activeApplication()); +//--------------------------------------------------------------- +QString VisuGUI_Selection::medEntity( const int ind ) const +{ + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return QString(); + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, (const char*)entry( ind ).toLatin1()); + VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject); + + bool isExist; + QString aVal = VISU::Storable::FindValue(aMap,"myEntityId",&isExist); + if ( isExist ) { + using namespace VISU; + TEntity anEntityId = TEntity(aVal.toInt()); + switch(anEntityId){ + case NODE_ENTITY : + return "NODE_ENTITY"; + case EDGE_ENTITY : + return "EDGE_ENTITY"; + case FACE_ENTITY : + return "FACE_ENTITY"; + case CELL_ENTITY : + return "CELL_ENTITY"; + default: + return QString(); + } + } + return QString(); +} - SVTK_Selector* aSelector = aViewWindow->GetSelector(); +QString VisuGUI_Selection::medSource( const int ind ) const +{ + _PTR(Study) aStudyDS = GetStudy()->studyDS(); + if(_PTR(SObject) aSObject = aStudyDS->FindObjectID((const char*)entry(ind).toLatin1())){ + VISU::Result_var aRes; + if(VISU::Result_i* aResult = CheckResult(myModule,aSObject,aRes)){ + using namespace VISU; + Result_i::ECreationId aCreationId = aResult->GetCreationId(); + switch(aCreationId){ + case Result_i::eImportFile : + return "eImportFile"; + case Result_i::eCopyAndImportFile : + return "eCopyAndImportFile"; + case Result_i::eImportMed : + return "eImportMed"; + case Result_i::eImportMedField : + return "eImportMedField"; + default: + return QString(); + } + } + } + return QString(); +} - VISU::Prs3d_i* aPrs3d = NULL; - _PTR(SObject) aSObject; - Handle(SALOME_InteractiveObject) anIO; +QString VisuGUI_Selection::nbTimeStamps( const int ind ) const +{ + QString aResStr; + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return aResStr; + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, (const char*)entry( ind ).toLatin1()); + VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject); + + bool isExist; + const QString& aVal = VISU::Storable::FindValue(aMap,"myNbTimeStamps",&isExist); + if ( isExist ) + aResStr = aVal; + return aResStr; +} - SALOME_ListIO aListIO; - mySelectionMgr->selectedObjects(aListIO); - if (aListIO.Extent() == 1) { - anIO = aListIO.First(); +//---------------------------------------------------------------------------- +template +struct TPopupDispatcher +{ + QString + operator()(const SalomeApp_Module* theModule, + const QString& theEntry) + { + if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){ + QString aType = aViewManager->getType(); + TPopupFunctor aFunctor; + if(aType == SVTK_Viewer::Type()) + return aFunctor.template Get(theModule, theEntry); + //else if(aType == VVTK_Viewer::Type()) + //return aFunctor.template Get(theModule, theEntry); + } + return QString(); + } +}; + + +//---------------------------------------------------------------------------- +template +bool +GetPrs3dSelectionInfo(const SalomeApp_Module* theModule, + const QString& theEntry, + VISU::Prs3d_i*& thePrs3d, + SVTK_ViewWindow*& theViewWindow, + VISU_Actor*& thenActor) +{ + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(theModule), (const char*)theEntry.toLatin1()); + thePrs3d = GetPrs3dFromBase(anObjectInfo.myBase); + if(!thePrs3d) + return false; + + typedef typename TViewer::TViewWindow TViewWindow; + theViewWindow = GetActiveViewWindow(theModule); + if(!theViewWindow) + return false; + + thenActor = FindActor(theViewWindow, thePrs3d); + if(!thenActor) + return false; + + return true; +} - if (anIO->hasEntry()) { - SalomeApp_Study* theStudy = dynamic_cast(anApp->activeStudy()); - _PTR(Study) aStudy = theStudy->studyDS(); - aSObject = aStudy->FindObjectID(anIO->getEntry()); - if (aSObject) { - CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject); +//---------------------------------------------------------------------------- +struct TViewFunctor +{ + template + QString + Get(const SalomeApp_Module* theModule, + const QString& theEntry) + { + VISU_Actor* anActor = NULL; + VISU::Prs3d_i* aPrs3d = NULL; + VISU_ActorBase* anActorBase = NULL; + VISU::PointMap3d_i* aPointMap3d = NULL; + SVTK_ViewWindow* aViewWindow = NULL; + if(GetPrs3dSelectionInfo(theModule, theEntry, aPrs3d, aViewWindow, anActor)) + return get(aPrs3d, aViewWindow, anActor); + else { + aViewWindow = GetActiveViewWindow(theModule); + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule); + if ( aSelectionInfo.empty() ) + return QString(); + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + aPointMap3d = dynamic_cast(aSelectionItem.myObjectInfo.myBase); + anActorBase = VISU::FindActorBase(aViewWindow, aPointMap3d); + return getPointMap(aPointMap3d, aViewWindow, anActorBase); + } + } + + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + return QString(); + } + + QString + virtual + getPointMap(VISU::PointMap3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_ActorBase* theActor) + { + return QString(); + } +}; - if (!CORBA::is_nil(anObject)) { - PortableServer::ServantBase_var aServant = VISU::GetServant(anObject); - if (aServant.in()) { - aPrs3d = dynamic_cast(aServant.in()); - } - } - } +//---------------------------------------------------------------------------- +struct TGetRepesentationFunctor: TViewFunctor +{ + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + QString aResStr; + switch (theActor->GetRepresentation()) { + ENUM2STRING( aResStr, VISU::POINT ); + ENUM2STRING( aResStr, VISU::WIREFRAME ); + ENUM2STRING( aResStr, VISU::SHADED ); + ENUM2STRING( aResStr, VISU::INSIDEFRAME ); + ENUM2STRING( aResStr, VISU::SURFACEFRAME ); + ENUM2STRING( aResStr, VISU::FEATURE_EDGES ); } + return aResStr; } - if (aPrs3d) { - VISU::Storable::TRestoringMap aMap; - if (aSObject) { - _PTR(GenericAttribute) anAttr; - if (aSObject->FindAttribute(anAttr, "AttributeComment")) { - _PTR(AttributeComment) aComment (anAttr); - std::string aString = aComment->Value(); - QString strIn( aString.c_str() ); - VISU::Storable::StrToMap(strIn, aMap); + QString + virtual + getPointMap(VISU::PointMap3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_ActorBase* theActorBase) + { + QString aResStr = ""; + if (theActorBase) { + switch (theActorBase->GetRepresentation()) { + ENUM2STRING( aResStr, VISU::WIREFRAME ); // = 1 + ENUM2STRING( aResStr, VISU::SHADED ); // = 2 } } + return aResStr; + } +}; - QString aMeshName("NULL"), aFieldName("NULL"); - if (!aMap.empty()) { - aMeshName = VISU::Storable::FindValue(aMap, "myMeshName"); - aFieldName = VISU::Storable::FindValue(aMap, "myFieldName"); - } +QString VisuGUI_Selection::representation( const int ind ) const +{ + return TPopupDispatcher()(myModule, entry(ind)); +} - myMeshName ->setText((aMeshName == "NULL") ? QString("No name") : aMeshName); - myFieldName->setText((aFieldName == "NULL") ? QString("No name") : aFieldName); - - VISU_Actor* anVISUActor = - VISU::FindActor(aViewWindow, aSObject->GetID().c_str()); - if (anVISUActor) { - vtkFloatingPointType aCoord[6]; - anVISUActor->GetBounds(aCoord); - myXPosLbl->setText(QString::number( aCoord[0] )); - myYPosLbl->setText(QString::number( aCoord[2] )); - myZPosLbl->setText(QString::number( aCoord[4] )); - - myDXLbl->setText(QString::number( ABS(aCoord[1]-aCoord[0]) )); - myDYLbl->setText(QString::number( ABS(aCoord[3]-aCoord[2]) )); - myDZLbl->setText(QString::number( ABS(aCoord[5]-aCoord[4]) )); - - TColStd_IndexedMapOfInteger aMapIndex; - typedef map PointsMap; - PointsMap aPointsMap; - - aSelector->GetIndex(anIO, aMapIndex); - - vtkDataSet* aDataSet = anVISUActor->GetInput(); - vtkPointData* aPntData = aDataSet->GetPointData(); - - for (int ind = 1; ind <= aMapIndex.Extent(); ind++) { - int anID = aMapIndex(ind); - - switch (aType) { - case 0: - { - vtkFloatingPointType* aCoord = anVISUActor->GetNodeCoord(anID); - int aVTKID = anVISUActor->GetNodeVTKID(anID); - myXValLbl->setText( QString::number( aCoord[0] ) ); - myYValLbl->setText( QString::number( aCoord[1] ) ); - myZValLbl->setText( QString::number( aCoord[2] ) ); - myIDValLbl->setText( QString::number(anID) ); - myScalarValLbl->setText(getValue(aPntData, aVTKID)); - myVectorValLbl->setText(getVector(aPntData, aVTKID)); - } - break; - case 1: - { - vtkCellData* aCellData = aDataSet->GetCellData(); - vtkCell* aCell = anVISUActor->GetElemCell(anID); - int aVTKID = anVISUActor->GetElemVTKID(anID); - if (aCell != NULL) { - int aNbOfPoints = aCell->GetNumberOfPoints(); - if ( aNbOfPoints <= 1 ) { // Cell is point - clearFields(); - } else { - myCellIDValLbl->setText( QString::number(anID) ); - myCellScalarValLbl->setText(getValue(aCellData, aVTKID)); - myCellVectorValLbl->setText(getVector(aCellData, aVTKID)); - - vtkFloatingPointType* aCoord; - vtkIdList *aPointList = aCell->GetPointIds(); - - for (int i = 0; i < aNbOfPoints; i++) { - int idCurrent = aPointList->GetId(i); - aCoord = aDataSet->GetPoint(idCurrent); - aPointsMap.insert(PointsMap::value_type(idCurrent,aCoord)); - } - } - } - } - break; - } - } +//---------------------------------------------------------------------------- +SalomeApp_Study* VisuGUI_Selection::GetStudy() const + +{ + LightApp_Study* aLightStudy = const_cast( study() ); + return dynamic_cast( aLightStudy ); +} - myListPoints->setNumRows(aPointsMap.size()); - PointsMap::const_iterator It = aPointsMap.begin(); - for (int i = 0; It != aPointsMap.end() && i < myListPoints->numRows(); It++, i++) { - myListPoints->verticalHeader()->setLabel(i, QString::number( i )); - int id = It->first; - myListPoints->setText(i, 0, QString::number( id )); - vtkFloatingPointType* aCoord = It->second; - myListPoints->setText(i, 1, QString::number( aCoord[0] )); - myListPoints->setText(i, 2, QString::number( aCoord[1] )); - myListPoints->setText(i, 3, QString::number( aCoord[2] )); - myListPoints->setText(i, 4, getValue(aPntData, id)); - myListPoints->setText(i, 5, getVector(aPntData, id)); +//---------------------------------------------------------------------------- +int VisuGUI_Selection::nbChild( const int ind, const bool named ) const +{ + int cnt = 0; + SalomeApp_Study* aSStudy = GetStudy(); + if ( !aSStudy ) + return cnt; + _PTR(Study) aStudy = GetCStudy( aSStudy ); + if ( aStudy ){ + _PTR(SObject) SO = aStudy->FindObjectID( (const char*)entry( ind ).toLatin1() ); + if ( SO ){ + for ( _PTR(ChildIterator) Iter = aStudy->NewChildIterator( SO ); Iter->More(); Iter->Next() ) { + _PTR(SObject) refSO; + if ( !Iter->Value()->ReferencedObject( refSO ) && ( !named || Iter->Value()->GetName().size() ) ) + cnt++; } } - } else { - clearFields(); } - myFl = false; + return cnt; +} + +//---------------------------------------------------------------------------- +int VisuGUI_Selection::nbChildren( const int ind ) const +{ + return nbChild( ind, false ); } -#undef ABS - - -void VisuGUI_SelectionDlg::clearFields() { - int aType = myWidgetStack->id(myWidgetStack->visibleWidget()); - switch (aType) { - case 0: - myXValLbl->setText( "" ); - myYValLbl->setText( "" ); - myZValLbl->setText( "" ); - myIDValLbl->setText( "" ); - myScalarValLbl->setText(""); - myVectorValLbl->setText(""); - break; - case 1: - myCellIDValLbl->setText( "" ); - myCellScalarValLbl->setText(""); - myCellVectorValLbl->setText(""); - myListPoints->setNumRows(0); - break; - case 2: - myXPosLbl->setText(""); - myYPosLbl->setText(""); - myZPosLbl->setText(""); - myDXLbl->setText(""); - myDYLbl->setText(""); - myDZLbl->setText(""); + +//---------------------------------------------------------------------------- +int VisuGUI_Selection::nbNamedChildren( const int ind ) const +{ + return nbChild( ind, true ); +} + + +//---------------------------------------------------------------------------- +struct TIsVisibleFunctor: TViewFunctor +{ + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + return theActor->GetVisibility() ? "true" : "false"; } +}; + +QString VisuGUI_Selection::isVisible( const int ind ) const +{ + return TPopupDispatcher()(myModule, entry(ind)); } -typedef vtkIdType (vtkDataSet::* TDataSetMethod)(); -bool onIdEdit (const QString& theText, - TDataSetMethod theMethod, - bool theIsCell, - const SalomeApp_Module* theModule, - LightApp_SelectionMgr* theSelectionMgr, - QLabel* theMeshName, - QString theValue, - QLabel* theFieldName) +//---------------------------------------------------------------------------- +struct TIsShrunkFunctor: TViewFunctor { - SalomeApp_Application* anApp = theModule->getApp(); - SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(theModule); - if (!aViewWindow) return false; - SVTK_Selector* aSelector = aViewWindow->GetSelector(); + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + return theActor->IsShrunk() ? "1" : "0"; + } - VISU::Prs3d_i* aPrs3d = NULL; - Handle(SALOME_InteractiveObject) anIO; + QString + virtual + getPointMap(VISU::PointMap3d_i* thePointMap, + SVTK_ViewWindow* theViewWindow, + VISU_ActorBase* theActorBase) + { + if (theActorBase) + return theActorBase->IsShrunk() ? "1" : "0"; + else return "0"; + } +}; - SALOME_ListIO aListIO; - theSelectionMgr->selectedObjects(aListIO, SVTK_Viewer::Type()); +QString VisuGUI_Selection::isShrunk( const int ind ) const +{ + return TPopupDispatcher()(myModule, entry(ind)); +} - if (aListIO.Extent() == 1) { - anIO = aListIO.First(); - if (anIO->hasEntry()) { - SalomeApp_Study* theStudy = dynamic_cast(anApp->activeStudy()); - _PTR(Study) aStudy = theStudy->studyDS(); - _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry()); +//---------------------------------------------------------------------------- +bool VisuGUI_Selection::hasActor( const int ind ) const +{ + return !representation( ind ).isEmpty(); +} - if (aSObject) { - CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject); - if (!CORBA::is_nil(anObject)) { - PortableServer::ServantBase_var aServant = VISU::GetServant(anObject); +//---------------------------------------------------------------------------- +struct TIsShadingFunctor: TViewFunctor +{ + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + if(VISU_ScalarMapAct* anActor = dynamic_cast(theActor)) + return anActor->IsShading() ? "1" : "0"; + return QString(); + } +}; - if (aServant.in()) { - aPrs3d = dynamic_cast(aServant.in()); - } - } - } - } +QString VisuGUI_Selection::isShading( const int ind ) const +{ + return TPopupDispatcher()(myModule, entry(ind)); +} + + +//---------------------------------------------------------------------------- +struct TIsScalarMapActFunctor: TViewFunctor +{ + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + return dynamic_cast(theActor)? "1" : "0"; + } +}; + + +//--------------------------------------------------------------- +QString VisuGUI_Selection::isScalarMapAct( const int ind ) const +{ + return TPopupDispatcher()(myModule, entry(ind)); +} + +//---------------------------------------------------------------------------- +struct TIsGaussPtsActFunctor: TViewFunctor +{ + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + return dynamic_cast(theActor)? "1" : "0"; } +}; - if (aPrs3d) { - int anId = theText.toInt(); - vtkDataSet* aDataSet = aPrs3d->GetPL()->GetMapper()->GetInput(); - int aMaxId = (aDataSet->*theMethod)(); - if (anId < 0) anId = 0; - if (anId >= aMaxId) anId = aMaxId - 1; - TColStd_MapOfInteger newIndices; - newIndices.Add(anId); - aSelector->AddOrRemoveIndex(anIO, newIndices, false); - aViewWindow->highlight(anIO, true, true); +//--------------------------------------------------------------- +QString VisuGUI_Selection::isGaussPtsAct( const int ind ) const +{ + return TPopupDispatcher()(myModule, entry(ind)); +} - return true; +//---------------------------------------------------------------------------- +bool VisuGUI_Selection::isVisuComponent( const int ind ) const +{ + SalomeApp_Study* study = GetStudy(); + if ( !study ) + return false; + + _PTR(SObject) obj = study->studyDS()->FindObjectID( (const char*)entry( ind ).toLatin1() ); + if ( !obj ) + return false; + CORBA::Object_var anObj = VISU::ClientSObjectToObject( obj ); + if( CORBA::is_nil( anObj ) ) + return false; + + return dynamic_cast( VISU::GetServant( anObj ).in() ); +} - } else { - theMeshName->setText(theValue); - theFieldName->setText(""); +//--------------------------------------------------------------------------- +bool VisuGUI_Selection::findDisplayedCurves( const int ind, bool findHidden ) const +{ + // findHidden == false - find at least one Visible curve in the childs of ind + // findHidden == true - find at least one Hidden curve in the childs of ind + SalomeApp_Study* aSStudy = GetStudy(); + if ( !aSStudy ) + return false; + + QString entryId; + _PTR(Study) aStudy = GetCStudy( aSStudy ); + if ( aStudy ){ + _PTR(SObject) SO = aStudy->FindObjectID( (const char*) entry( ind ).toLatin1() ); + if ( SO ){ + for ( _PTR(ChildIterator) Iter = aStudy->NewChildIterator( SO ); Iter->More(); Iter->Next() ) { + _PTR(SObject) refSO; + if ( Iter->Value()->ReferencedObject(refSO) ) + entryId = refSO->GetID().c_str(); + else + entryId = Iter->Value()->GetID().c_str(); + + LightApp_Displayer* displayer = LightApp_Displayer::FindDisplayer( myModule->moduleName(), false ); + if ( displayer->IsDisplayed( entryId ) && findHidden == false ) + return true; + else if ( !displayer->IsDisplayed( entryId ) && findHidden == true ) + return true; + } + } } return false; } -void VisuGUI_SelectionDlg::onPointIdEdit (const QString& theText) +//--------------------------------------------------------------------------- +bool VisuGUI_Selection::hasCurves( const int ind ) const { - if (myFl) return; - TDataSetMethod aMethod = &vtkDataSet::GetNumberOfPoints; - bool anIsSelected = onIdEdit(theText,aMethod,false,myModule,mySelectionMgr, - myMeshName,tr("WRN_NO_AVAILABLE_DATA"), - myFieldName); - if (anIsSelected) - // as selection manager doesn't send signal currentSelectionChanged() - onSelectionEvent(); - else - clearFields(); + SalomeApp_Study* aSStudy = GetStudy(); + if ( !aSStudy ) + return false; + + QString entryId; + _PTR(Study) aStudy = GetCStudy( aSStudy ); + if ( aStudy ){ + _PTR(SObject) SO = aStudy->FindObjectID( (const char*) entry( ind ).toLatin1() ); + if ( SO ){ + for ( _PTR(ChildIterator) Iter = aStudy->NewChildIterator( SO ); Iter->More(); Iter->Next() ) { + _PTR(SObject) refSO; + if ( Iter->Value()->ReferencedObject(refSO) ) { + // reference on curve + } + else + refSO = Iter->Value(); + + CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(refSO); + if(!CORBA::is_nil(aCORBAObject)){ + PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject); + if(dynamic_cast(aServant.in())) + return true; + } + } + } + } + return false; } -void VisuGUI_SelectionDlg::onCellIdEdit (const QString& theText) +//--------------------------------------------------------------------------- +bool VisuGUI_Selection::Plot2dViewerType( const int ind ) const { - if (myFl) return; - TDataSetMethod aMethod = &vtkDataSet::GetNumberOfCells; - bool anIsSelected = onIdEdit(theText,aMethod,true,myModule,mySelectionMgr, - myMeshName,tr("WRN_NO_AVAILABLE_DATA"), - myFieldName); - if (anIsSelected) - // as selection manager doesn't send signal currentSelectionChanged() - onSelectionEvent(); - else - clearFields(); + QString viewerType; + SUIT_Session* session = SUIT_Session::session(); + if( SUIT_Application* app = session->activeApplication() ) + if( LightApp_Application* sApp = dynamic_cast( app ) ) + if( SUIT_ViewManager* vman = sApp->activeViewManager() ) + if( SUIT_ViewModel* vmod = vman->getViewModel() ) { + viewerType = vmod->getType(); + if (viewerType ==SPlot2d_Viewer::Type()) + return true; + } + return false; } -void VisuGUI_SelectionDlg::onHelp() -{ - QString aHelpFileName = "/files/getting_elements_attributes.htm"; - LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); - if (app) - app->onHelpContextModule(myModule ? app->moduleName(myModule->moduleName()) : QString(""), aHelpFileName); - else { - SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), - QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName), - QObject::tr("BUT_OK")); +//---------------------------------------------------------------------------- +struct TIsValuesLabeled : TViewFunctor +{ + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + return theActor && theActor->GetValuesLabeled() ? "true" : "false"; } +}; + +QString VisuGUI_Selection::isValuesLabeled( const int ind ) const +{ + return TPopupDispatcher()(myModule, entry(ind)); +} + +//---------------------------------------------------------------------------- +struct TIsScalarBarVisibleFunctor: TViewFunctor +{ + QString + virtual + get(VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + if(VISU_ScalarMapAct* anActor = dynamic_cast(theActor)) + return anActor->GetBarVisibility() ? "true" : "false"; + else if ( VISU_GaussPtsAct* anActor = dynamic_cast(theActor)) + return anActor->GetBarVisibility() ? "true" : "false"; + return QString(); + } +}; + +bool VisuGUI_Selection::isScalarBarVisible( const int ind ) const +{ + return TPopupDispatcher()(myModule, entry(ind)) == "true"; +} + +struct TGetQuadratic2DRepresentation: TViewFunctor +{ + QString virtual get (VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow, + VISU_Actor* theActor) + { + if(theActor->GetQuadratic2DRepresentation() == VISU_Actor::eLines) + return "VISU::LINES"; + else if (theActor->GetQuadratic2DRepresentation() == VISU_Actor::eArcs) + return "VISU::ARCS"; + + return QString(); + } +}; + + +QString VisuGUI_Selection::quadratic2DMode( const int ind) const +{ + return TPopupDispatcher()(myModule, entry(ind)); }