From e4b0ab05ee2b7fc2b718c4b39d4b4cf2cfc0a9e4 Mon Sep 17 00:00:00 2001 From: ouv Date: Tue, 13 May 2008 12:08:54 +0000 Subject: [PATCH] Content moved to VisuGUI_Selection --- src/VISUGUI/VisuGUI_PopupTools.cxx | 576 ----------------------------- src/VISUGUI/VisuGUI_PopupTools.h | 81 ---- 2 files changed, 657 deletions(-) delete mode 100644 src/VISUGUI/VisuGUI_PopupTools.cxx delete mode 100644 src/VISUGUI/VisuGUI_PopupTools.h diff --git a/src/VISUGUI/VisuGUI_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx deleted file mode 100644 index 26105e76..00000000 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ /dev/null @@ -1,576 +0,0 @@ -// VISU VISUGUI : GUI of VISU component -// -// Copyright (C) 2005 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 -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// -// -// File : VisuGUI_PopupTools.cxx -// Author : Sergey Anikin -// Module : VISU - -#include "VisuGUI_PopupTools.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_ScalarMapAct.h" - -#include "SalomeApp_Study.h" -#include "LightApp_Study.h" - -using namespace VISU; - -////////////////////////////////////////////////// -// Class: VisuGUI_Selection -////////////////////////////////////////////////// - - -//--------------------------------------------------------------- -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 == "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 ) ); - } - - return val; -} - - -//--------------------------------------------------------------- -// 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 ); - } - } - - 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 ); - } - } - - if(aResStr.isNull()){ - bool anIsExist; - QString aVal = VISU::Storable::FindValue(aMap, "myComment", &anIsExist); - if ( anIsExist && aVal != "MESH" ) - aResStr = "VISU::T" + aVal; - } - - return aResStr; -} - - -//--------------------------------------------------------------- -QString VisuGUI_Selection::nbComponents( 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; - QString aVal = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist); - if ( isExist ) - aResStr = aVal; - return aResStr; -} - - -//--------------------------------------------------------------- -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; -} - - -//--------------------------------------------------------------- -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; -} - - -//--------------------------------------------------------------- -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'); -} - - -//--------------------------------------------------------------- -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"; - } - - return aResStr; -} - - -//--------------------------------------------------------------- -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(); -} - -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(); -} - -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; -} - - -//---------------------------------------------------------------------------- -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; -} - - -//---------------------------------------------------------------------------- -struct TViewFunctor -{ - template - QString - Get(const SalomeApp_Module* theModule, - const QString& theEntry) - { - VISU_Actor* anActor = NULL; - VISU::Prs3d_i* aPrs3d = NULL; - SVTK_ViewWindow* aViewWindow = NULL; - if(!GetPrs3dSelectionInfo(theModule, theEntry, aPrs3d, aViewWindow, anActor)) - return QString(); - - return get(aPrs3d, aViewWindow, anActor); - } - - QString - virtual - get(VISU::Prs3d_i* thePrs3d, - SVTK_ViewWindow* theViewWindow, - VISU_Actor* theActor) - { - return QString(); - } -}; - - -//---------------------------------------------------------------------------- -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 ); - } - return aResStr; - } -}; - -QString VisuGUI_Selection::representation( const int ind ) const -{ - return TPopupDispatcher()(myModule, entry(ind)); -} - -//---------------------------------------------------------------------------- -SalomeApp_Study* VisuGUI_Selection::GetStudy() const - -{ - LightApp_Study* aLightStudy = const_cast( study() ); - return dynamic_cast( aLightStudy ); -} - -//---------------------------------------------------------------------------- -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++; - } - } - } - return cnt; -} - -//---------------------------------------------------------------------------- -QString VisuGUI_Selection::nbChildren( const int ind ) const -{ - QString aResStr; - aResStr.setNum( nbChild( ind, false ) ); - return aResStr; -} - -//---------------------------------------------------------------------------- -QString VisuGUI_Selection::nbNamedChildren( const int ind ) const -{ - QString aResStr; - aResStr.setNum( nbChild( ind, true ) ); - return aResStr; -} - - -//---------------------------------------------------------------------------- -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)); -} - - -//---------------------------------------------------------------------------- -struct TIsShrunkFunctor: TViewFunctor -{ - QString - virtual - get(VISU::Prs3d_i* thePrs3d, - SVTK_ViewWindow* theViewWindow, - VISU_Actor* theActor) - { - return theActor->IsShrunk() ? "1" : "0"; - } -}; - -QString VisuGUI_Selection::isShrunk( const int ind ) const -{ - return TPopupDispatcher()(myModule, entry(ind)); -} - - -//---------------------------------------------------------------------------- -QString VisuGUI_Selection::hasActor( const int ind ) const -{ - return representation( ind ).isEmpty() ? "0" : "1"; -} - - -//---------------------------------------------------------------------------- -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(); - } -}; - -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)); -} - - -//---------------------------------------------------------------------------- -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() ); -} diff --git a/src/VISUGUI/VisuGUI_PopupTools.h b/src/VISUGUI/VisuGUI_PopupTools.h deleted file mode 100644 index 8ab909ad..00000000 --- a/src/VISUGUI/VisuGUI_PopupTools.h +++ /dev/null @@ -1,81 +0,0 @@ -// VISU VISUGUI : GUI of VISU component -// -// Copyright (C) 2005 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 -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// -// -// File : VisuGUI_PopupTools.h -// Author : Sergey Anikin -// Module : VISU - -#ifndef VisuGUI_PopupTools_HeaderFile -#define VisuGUI_PopupTools_HeaderFile - -#include - -////////////////////////////////////////////////// -// Class: VisuGUI_Selection -////////////////////////////////////////////////// - -class SalomeApp_Module; -class SalomeApp_Study; - -class VisuGUI_Selection : public LightApp_Selection -{ -public: - VisuGUI_Selection( SalomeApp_Module* theModule ) - : LightApp_Selection(), myModule( theModule ) {}; - virtual ~VisuGUI_Selection() {}; - - virtual QVariant parameter( const int, const QString& ) const; - -private: - QString type( const int ) const; - QString nbComponents( const int ) const; - QString medEntity( const int ) const; - QString medSource( const int ) const; - QString nbTimeStamps( const int ) const; - QString representation( const int ) const; - QString nbChildren( const int ) const; - QString nbNamedChildren( const int ) const; - QString isVisible( const int ) const; - QString isShrunk( const int ) const; - QString hasActor( const int ) const; - QString isShading( const int ) const; - QString isScalarMapAct( const int ) const; - bool isVisuComponent( const int ) const; - - QString fullResolution( const int ) const; - QString mediumResolution( const int ) const; - QString lowResolution( const int ) const; - QString resolutionState( const int ) const; - -private: - int nbChild( const int, const bool ) const; - SalomeApp_Study* GetStudy() const; - - QString resolutions( const int ) const; - QString resolution( const int, char theResoltuion ) const; - -private: - SalomeApp_Module* myModule; -}; - -#endif -- 2.39.2