// Module : VISU
#include "VisuGUI_PopupTools.h"
+
+#include "VisuGUI_ViewTools.h"
#include "VisuGUI_Tools.h"
+#include "VISU_Result_i.hh"
+
#include "VISU_Actor.h"
+#include "VISU_ScalarMapAct.h"
+
+#include "SalomeApp_Study.h"
+#include "LightApp_Study.h"
using namespace VISU;
QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const
{
- QtxValue val( SalomeApp_Selection::param( ind, p ) );
+ QtxValue val( LightApp_Selection::param( ind, p ) );
if ( !val.isValid() ) {
if ( p == "type" ) val = QtxValue( type( ind ) );
else if ( p == "nbComponents" ) val = QtxValue( nbComponents( ind ) );
+ else if ( p == "medEntity" ) val = QtxValue( medEntity( ind ) );
+ else if ( p == "medSource" ) val = QtxValue( medSource( ind ) );
else if ( p == "representation" ) val = QtxValue( representation( ind ) );
else if ( p == "nbTimeStamps" ) val = QtxValue( nbTimeStamps( ind ) );
else if ( p == "nbChildren" ) val = QtxValue( nbChildren( ind ) );
else if ( p == "isVisible" ) val = QtxValue( isVisible( ind ) );
else if ( p == "isShrunk" ) val = QtxValue( isShrunk( ind ) );
else if ( p == "hasActor" ) val = QtxValue( hasActor( ind ) );
+ else if ( p == "isShading" ) val = QtxValue( isShading( ind ) );
+ else if ( p == "isScalarMapAct" ) val = QtxValue( isScalarMapAct( ind ) );
}
return val;
{
QString aResStr;
VISU::Storable::TRestoringMap aMap;
- CORBA::Object_var anObject = GetSelectedObj( study(), entry( ind ), &aMap );
+ SalomeApp_Study* aStudy = GetStudy();
+ if ( !aStudy )
+ return aResStr;
+ CORBA::Object_var anObject = GetSelectedObj( aStudy, entry( ind ), &aMap );
VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
if ( !CORBA::is_nil( aVisuObj ) ){
ENUM2STRING( aResStr, VISU::TSCALARMAP );
ENUM2STRING( aResStr, VISU::TISOSURFACE );
ENUM2STRING( aResStr, VISU::TDEFORMEDSHAPE );
+ ENUM2STRING( aResStr, VISU::TSCALARMAPONDEFORMEDSHAPE );
ENUM2STRING( aResStr, VISU::TCUTPLANES );
ENUM2STRING( aResStr, VISU::TCUTLINES );
ENUM2STRING( aResStr, VISU::TVECTORS );
{
QString aResStr;
VISU::Storable::TRestoringMap aMap;
- GetSelectedObj( study(), entry( ind ), &aMap );
+ SalomeApp_Study* aStudy = GetStudy();
+ if ( !aStudy )
+ return aResStr;
+ GetSelectedObj( aStudy, entry( ind ), &aMap );
bool isExist;
const QString& aVal = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist);
if ( isExist )
return aResStr;
}
+QString VisuGUI_Selection::medEntity( const int ind ) const
+{
+ bool isExist;
+ VISU::Storable::TRestoringMap aMap;
+ GetSelectedObj( GetStudy(), entry( ind ), &aMap );
+ const 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(entry(ind))){
+ 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;
VISU::Storable::TRestoringMap aMap;
- GetSelectedObj( study(), entry( ind ), &aMap );
+ SalomeApp_Study* aStudy = GetStudy();
+ if ( !aStudy )
+ return aResStr;
+ GetSelectedObj( aStudy, entry( ind ), &aMap );
bool isExist;
const QString& aVal = VISU::Storable::FindValue(aMap,"myNbTimeStamps",&isExist);
if ( isExist )
{
QString aResStr;
- if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) ){
- if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) ){
+ if (SVTK_ViewWindow* aView = GetActiveViewWindow<SVTK_ViewWindow>(myModule)) {
+ if (VISU_Actor* anVISUActor = FindActor(aView, entry(ind).latin1())) {
int aRepresent = anVISUActor->GetRepresentation();
- switch ( aRepresent ){
+ switch (aRepresent) {
ENUM2STRING( aResStr, VISU::POINT );
ENUM2STRING( aResStr, VISU::WIREFRAME );
ENUM2STRING( aResStr, VISU::SHADED );
return aResStr;
}
+SalomeApp_Study* VisuGUI_Selection::GetStudy() const
+
+{
+ LightApp_Study* aLightStudy = const_cast<LightApp_Study*>( study() );
+ return dynamic_cast<SalomeApp_Study*>( aLightStudy );
+}
+
int VisuGUI_Selection::nbChild( const int ind, const bool named ) const
{
int cnt = 0;
- _PTR(Study) aStudy = GetCStudy( study() );
+ SalomeApp_Study* aSStudy = GetStudy();
+ if ( !aSStudy )
+ return cnt;
+ _PTR(Study) aStudy = GetCStudy( aSStudy );
if ( aStudy ){
_PTR(SObject) SO = aStudy->FindObjectID( entry( ind ).latin1() );
if ( SO ){
return aResStr;
}
-QString VisuGUI_Selection::isVisible( const int ind ) const
+namespace
{
- QString aResStr;
+ struct TIsVisibleFunctor
+ {
+ template<class TViewer>
+ QString
+ Get(VisuGUI* theModule,
+ const QString& theEntry)
+ {
+ typedef typename TViewer::TViewWindow TViewWindow;
+ if (TViewWindow* aViewWindow = GetActiveViewWindow<TViewWindow>(theModule))
+ if (VISU_Actor* anActor = FindActor(aViewWindow,theEntry.latin1()))
+ return anActor->GetVisibility() ? "true" : "false";
- if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) )
- if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
- aResStr = anVISUActor->GetVisibility() ? "1" : "0";
+ return QString();
+ }
+ };
- return aResStr;
+ template<class TPopupFunctor>
+ struct TPopupDispatcher
+ {
+ QString
+ operator()(VisuGUI* 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<SVTK_Viewer>(theModule,theEntry);
+ else if(aType == VVTK_Viewer::Type())
+ return aFunctor.template Get<VVTK_Viewer>(theModule,theEntry);
+ }
+ return QString();
+ }
+ };
+}
+
+QString VisuGUI_Selection::isVisible( const int ind ) const
+{
+ return TPopupDispatcher<TIsVisibleFunctor>()((VisuGUI*)myModule,entry(ind));
}
QString VisuGUI_Selection::isShrunk( const int ind ) const
{
QString aResStr;
- if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) )
+ if ( SVTK_ViewWindow* aView = GetActiveViewWindow<SVTK_ViewWindow>(myModule) )
if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
if ( anVISUActor->IsShrunkable() )
aResStr = anVISUActor->IsShrunk() ? "1" : "0";
{
return representation( ind ).isEmpty() ? "0" : "1";
}
+
+QString VisuGUI_Selection::isShading( const int ind ) const
+{
+ QString aResStr;
+
+ if ( SVTK_ViewWindow* aView = GetActiveViewWindow<SVTK_ViewWindow>(myModule) )
+ if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
+ if ( VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(anVISUActor) )
+ aResStr = anActor->IsShading() ? "1" : "0";
+
+ return aResStr;
+}
+
+QString VisuGUI_Selection::isScalarMapAct( const int ind ) const
+{
+ QString aResStr;
+
+ if ( SVTK_ViewWindow* aView = GetActiveViewWindow<SVTK_ViewWindow>(myModule) )
+ if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
+ {
+ VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(anVISUActor);
+ aResStr = anActor ? "1" : "0";
+ }
+
+ return aResStr;
+}