virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& title ) {};
virtual void updateCommandsStatus() {};
+ /** @name Set Menu Shown*/
+ //@{
+ void setMenuShown( const bool );
+ void setMenuShown( QAction*, const bool );
+ void setMenuShown( const int, const bool );
+ //@}
+
+ /** @name Set Tool Shown*/
+ //@{
+ void setToolShown( const bool );
+ void setToolShown( QAction*, const bool );
+ void setToolShown( const int, const bool );
+ //@}
+
public slots:
virtual bool activateModule( SUIT_Study* );
virtual bool deactivateModule( SUIT_Study* );
int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );
//@}
- /** @name Set Menu Shown*/
- //@{
- void setMenuShown( const bool );
- void setMenuShown( QAction*, const bool );
- void setMenuShown( const int, const bool );
- //@}
-
- /** @name Set Tool Shown*/
- //@{
- void setToolShown( const bool );
- void setToolShown( QAction*, const bool );
- void setToolShown( const int, const bool );
- //@}
-
static QAction* separator();
/**Action ids methods.*/
ListOfTypes aTypes;
aTypes.append( QVariant::Bool );
+ aTypes.append( QVariant::Int );
+ aTypes.append( QVariant::UInt );
addTypes( aTypes );
}
{
bool ok = true;
if( str.lower()=="true" )
- v = true;
+ v = QtxValue( true, 0 );
else if( str.lower()=="false" )
- v = false;
+ v = QtxValue( false, 0 );
else
ok = QtxStdOperations::createValue( str, v );
return 0;
}
+bool boolean_value( const QtxValue& v )
+{
+ if( v.type()==QVariant::Bool )
+ return v.toBool();
+ else if( v.type()==QVariant::Int )
+ return v.toInt()!=0;
+ else if( v.type()==QVariant::UInt )
+ return v.toUInt()!=0;
+ else
+ return false;
+}
+
//================================================================
// Function :
// Purpose :
QtxValue& v1, QtxValue& v2 ) const
{
QtxParser::Error err = QtxParser::OK;
+ bool val1 = boolean_value( v1 ),
+ val2 = boolean_value( v2 );
if( v1.isValid() && v2.isValid() )
{
if( op=="and" || op=="&&" )
- set( v1, v1.toBool() && v2.toBool() );
+ set( v1, val1 && val2 );
else if( op=="or" || op=="||" )
- set( v1, v1.toBool() || v2.toBool() );
+ set( v1, val1 || val2 );
else if( op=="xor" )
- set( v1, ( !v1.toBool() && v2.toBool() ) || ( v1.toBool() && !v2.toBool() ) );
+ set( v1, ( !val1 && val2 ) || ( val1 && !val2 ) );
else if( op=="imp" )
- set( v1, !v1.toBool() || v2.toBool() );
+ set( v1, !val1 || val2 );
else if( op=="=" )
- set( v1, v1.toBool()==v2.toBool() );
+ set( v1, val1==val2 );
}
else
if( op=="not" || op=="!" )
- set( v2, !v2.toBool() );
+ set( v2, !val2 );
return err;
}
SALOME_Prs* SPlot2d_Viewer::CreatePrs( const char* entry )
{
Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
- if(aViewFrame) {
- return new SPlot2d_Prs(aViewFrame->CreatePrs(entry));
+ if(aViewFrame)
+ {
+ Plot2d_Prs* prs = aViewFrame->CreatePrs(entry);
+ if( prs )
+ return new SPlot2d_Prs( prs );
}
return NULL;
if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
if(SVTK_RenderWindow* aRW = aView->getRenderWindow())
+ {
+ aView->getRenderer()->Render();
+ aView->getRWInteractor()->unHighlightAll();
aRW->update();
+ }
}
void
SalomeApp_Operation.h \
SalomeApp_Dialog.h \
SalomeApp_UpdateFlags.h \
- SalomeApp_SwitchOp.cxx
+ SalomeApp_Displayer.h
# .po files to transform in .qm
PO_FILES = SalomeApp_images.po \
SalomeApp_CheckFileDlg.cxx \
SalomeApp_Operation.cxx \
SalomeApp_Dialog.cxx \
- SalomeApp_SwitchOp.cxx
+ SalomeApp_SwitchOp.cxx \
+ SalomeApp_Displayer.cxx \
+ SalomeApp_ShowHideOp.cxx
LIB_MOC = SalomeApp_AboutDlg.h \
SalomeApp_Application.h \
SalomeApp_CheckFileDlg.h \
SalomeApp_Operation.h \
SalomeApp_Dialog.h \
- SalomeApp_SwitchOp.h
+ SalomeApp_SwitchOp.h \
+ SalomeApp_ShowHideOp.h
LIB_CLIENT_IDL = SALOMEDS.idl \
SALOME_Exception.idl \
CPPFLAGS+=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) -I${KERNEL_ROOT_DIR}/include/salome
LDFLAGS+=$(PYTHON_LIBS) $(QT_MT_LIBS)
-LIBS+= -lsuit -lstd -lCAM -lObjBrowser -L$(KERNEL_ROOT_DIR)/lib/salome -lOpUtil -lSALOMELocalTrace $(CAS_KERNEL) -lSPlot2d -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSVTK -lSOCC -lPyInterp -lPythonConsole -lLogWindow -lSalomeContainer -lToolsGUI
+LIBS+= -lsuit -lstd -lCAM -lObjBrowser -lSalomePrs -L$(KERNEL_ROOT_DIR)/lib/salome -lOpUtil -lSALOMELocalTrace $(CAS_KERNEL) -lSPlot2d -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSVTK -lSOCC -lPyInterp -lPythonConsole -lLogWindow -lSalomeContainer -lToolsGUI
@CONCLUDE@
--- /dev/null
+
+#include "SalomeApp_Displayer.h"
+#include "SalomeApp_Application.h"
+
+#include <SALOME_InteractiveObject.hxx>
+
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_ViewModel.h>
+#include <SUIT_ViewWindow.h>
+
+#include <qstring.h>
+
+SalomeApp_Displayer::SalomeApp_Displayer()
+{
+}
+
+SalomeApp_Displayer::~SalomeApp_Displayer()
+{
+}
+
+void SalomeApp_Displayer::Display( const QString& entry, const bool updateViewer, SALOME_View* theViewFrame )
+{
+ SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+ if ( vf )
+ {
+ SALOME_Prs* prs = buildPresentation( entry, vf );
+
+ if ( prs )
+ {
+ vf->BeforeDisplay( this );
+ vf->Display( prs );
+ vf->AfterDisplay( this );
+
+ if ( updateViewer )
+ vf->Repaint();
+
+ delete prs; // delete presentation because displayer is its owner
+ }
+ }
+}
+
+void SalomeApp_Displayer::Redisplay( const QString& entry, const bool updateViewer )
+{
+ // Remove the object permanently (<forced> == true)
+ SUIT_Session* ses = SUIT_Session::session();
+ SUIT_Application* app = ses->activeApplication();
+ if ( app )
+ {
+ SUIT_Desktop* desk = app->desktop();
+ QPtrList<SUIT_ViewWindow> wnds = desk->windows();
+ SUIT_ViewWindow* wnd;
+ for ( wnd = wnds.first(); wnd; wnd = wnds.next() )
+ {
+ SUIT_ViewManager* vman = wnd->getViewManager();
+ if( !vman )
+ continue;
+
+ SUIT_ViewModel* vmodel = vman->getViewModel();
+ if( !vmodel )
+ continue;
+
+ SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel);
+ if( view && ( IsDisplayed( entry, view ) || view == GetActiveView() ) )
+ {
+ Erase( entry, true, false, view );
+ Display( entry, updateViewer, view );
+ }
+ }
+ }
+}
+
+void SalomeApp_Displayer::Erase( const QString& entry, const bool forced,
+ const bool updateViewer, SALOME_View* theViewFrame )
+{
+ SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+
+ if ( vf ) {
+ SALOME_Prs* prs = vf->CreatePrs( entry.latin1() );
+ if ( prs ) {
+ vf->Erase( prs, forced );
+ if ( updateViewer )
+ vf->Repaint();
+ delete prs; // delete presentation because displayer is its owner
+ }
+ }
+}
+
+void SalomeApp_Displayer::EraseAll( const bool forced, const bool updateViewer, SALOME_View* theViewFrame ) const
+{
+ SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+
+ if ( vf ) {
+ vf->EraseAll( forced );
+ if ( updateViewer )
+ vf->Repaint();
+ }
+}
+
+bool SalomeApp_Displayer::IsDisplayed( const QString& entry, SALOME_View* theViewFrame ) const
+{
+ SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+ if( vf )
+ {
+ Handle( SALOME_InteractiveObject ) temp = new SALOME_InteractiveObject();
+ temp->setEntry( entry.latin1() );
+ return vf->isVisible( temp );
+ }
+ else
+ return false;
+}
+
+void SalomeApp_Displayer::UpdateViewer() const
+{
+ SALOME_View* vf = GetActiveView();
+ if ( vf )
+ vf->Repaint();
+}
+
+SALOME_Prs* SalomeApp_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame )
+{
+ SALOME_Prs* prs = 0;
+
+ SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+
+ if ( vf )
+ prs = vf->CreatePrs( entry.latin1() );
+
+ return prs;
+}
+
+SALOME_View* SalomeApp_Displayer::GetActiveView()
+{
+ SUIT_Session* session = SUIT_Session::session();
+ if ( SUIT_Application* app = session->activeApplication() ) {
+ if ( SalomeApp_Application* sApp = dynamic_cast<SalomeApp_Application*>( app ) ) {
+ if( SUIT_ViewManager* vman = sApp->activeViewManager() ) {
+ if ( SUIT_ViewModel* vmod = vman->getViewModel() )
+ return dynamic_cast<SALOME_View*>( vmod );
+ }
+ }
+ }
+ return 0;
+}
--- /dev/null
+
+#ifndef SALOMEAPP_DISPLAYER_HEADER
+#define SALOMEAPP_DISPLAYER_HEADER
+
+#include <SALOME_Prs.h>
+
+class QString;
+
+class SalomeApp_Displayer : public SALOME_Displayer
+{
+public:
+ SalomeApp_Displayer();
+ virtual ~SalomeApp_Displayer();
+
+ void Display( const QString&, const bool = true, SALOME_View* = 0 );
+ void Redisplay( const QString&, const bool = true );
+ void Erase( const QString&, const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 );
+ void EraseAll( const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 ) const;
+ bool IsDisplayed( const QString&, SALOME_View* = 0 ) const;
+ void UpdateViewer() const;
+
+ static SALOME_View* GetActiveView();
+
+protected:
+ virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
+};
+
+#endif
#include "SalomeApp_UpdateFlags.h"
#include "SalomeApp_Operation.h"
#include "SalomeApp_SwitchOp.h"
+#include "SalomeApp_ShowHideOp.h"
#include <OB_Browser.h>
SalomeApp_Module::SalomeApp_Module( const QString& name )
: CAM_Module( name ),
myPopupMgr( 0 ),
-mySwitchOp( 0 )
+mySwitchOp( 0 ),
+myDisplay( -1 ),
+myErase( -1 ),
+myDisplayOnly( -1 )
{
}
QtxPopupMgr* SalomeApp_Module::popupMgr()
{
if ( !myPopupMgr )
+ {
myPopupMgr = new QtxPopupMgr( 0, this );
+
+ QPixmap p;
+ SUIT_Desktop* d = application()->desktop();
+
+ QAction
+ *disp = createAction( -1, tr( "TOP_DISPLAY" ), p, tr( "MEN_DISPLAY" ), tr( "STB_DISPLAY" ),
+ 0, d, false, this, SLOT( onShowHide() ) ),
+ *erase = createAction( -1, tr( "TOP_ERASE" ), p, tr( "MEN_ERASE" ), tr( "STB_ERASE" ),
+ 0, d, false, this, SLOT( onShowHide() ) ),
+ *dispOnly = createAction( -1, tr( "TOP_DISPLAY_ONLY" ), p, tr( "MEN_DISPLAY_ONLY" ), tr( "STB_DISPLAY_ONLY" ),
+ 0, d, false, this, SLOT( onShowHide() ) );
+ myDisplay = actionId( disp );
+ myErase = actionId( erase );
+ myDisplayOnly = actionId( dispOnly );
+
+ myPopupMgr->insert( disp, -1, 0 );
+ myPopupMgr->insert( erase, -1, 0 );
+ myPopupMgr->insert( dispOnly, -1, 0 );
+ myPopupMgr->insert( separator(), -1, 0 );
+
+ QString uniform = "( count( $component ) = 1 ) and ( component != activeModule )";
+ myPopupMgr->setRule( disp, QString( "( not isVisible ) and " ) + uniform, true );
+ myPopupMgr->setRule( erase, QString( "( isVisible ) and " ) + uniform, true );
+ myPopupMgr->setRule( dispOnly, uniform, true );
+ }
return myPopupMgr;
}
* automatically from startOperation. You may redefine this method in concrete module to
* create operations.
*/
-SalomeApp_Operation* SalomeApp_Module::createOperation( const int /*id*/ ) const
+SalomeApp_Operation* SalomeApp_Module::createOperation( const int id ) const
{
- return 0;
+ if( id==-1 )
+ return 0;
+
+ if( id==myDisplay )
+ return new SalomeApp_ShowHideOp( SalomeApp_ShowHideOp::DISPLAY );
+ else if( id==myErase )
+ return new SalomeApp_ShowHideOp( SalomeApp_ShowHideOp::ERASE );
+ else if( id==myDisplayOnly )
+ return new SalomeApp_ShowHideOp( SalomeApp_ShowHideOp::DISPLAY_ONLY );
+ else
+ return 0;
}
/*!
}
}
}
+
+SalomeApp_Displayer* SalomeApp_Module::displayer()
+{
+ return 0;
+}
+
+void SalomeApp_Module::onShowHide()
+{
+ if( !sender()->inherits( "QAction" ) || !popupMgr() )
+ return;
+
+ QAction* act = ( QAction* )sender();
+ int id = actionId( act );
+ if( id!=-1 )
+ startOperation( id );
+}
class SalomeApp_SelectionManager;
class SalomeApp_Operation;
class SalomeApp_SwitchOp;
+class SalomeApp_Displayer;
/*!
* \brief Base class for all salome modules
virtual void initialize( CAM_Application* );
virtual void windows( QMap<int, int>& ) const;
virtual void viewManagers( QStringList& ) const;
+ virtual SalomeApp_Displayer* displayer();
/*! engineIOR() should be a pure virtual method, to avoid logical errors!\n
* Implementation in derived classes can return the following values:\n
virtual void onModelClosed();
virtual void onOperationStopped( SUIT_Operation* );
virtual void onOperationDestroyed();
+ virtual void onShowHide();
protected:
QtxPopupMgr* popupMgr();
QtxPopupMgr* myPopupMgr;
MapOfOperation myOperations;
SalomeApp_SwitchOp* mySwitchOp;
+ int myDisplay, myErase, myDisplayOnly;
};
#endif
#include "SalomeApp_Selection.h"
-
#include "SalomeApp_SelectionMgr.h"
#include "SalomeApp_DataOwner.h"
#include "SalomeApp_Study.h"
#include "SalomeApp_Application.h"
+#include "SalomeApp_Displayer.h"
#include "SUIT_Session.h"
#include "SUIT_ViewWindow.h"
/*!
Gets QtxValue();
*/
-QtxValue SalomeApp_Selection::param( const int, const QString& p ) const
+QtxValue SalomeApp_Selection::param( const int ind, const QString& p ) const
{
+ if( !( ind>=0 && ind<count() ) )
+ return QtxValue();
+
+ if( p=="isVisible" )
+ {
+ SalomeApp_Displayer d;
+ bool vis = d.IsDisplayed( myEntries[ ind ] );
+ return QtxValue( vis, 0 );
+ }
+ else if( p=="component" )
+ {
+ _PTR(SObject) obj( study()->studyDS()->FindObjectID( myEntries[ ind ] ) );
+ _PTR(SComponent) comp = obj->GetFatherComponent();
+ QString mod_name = comp->ComponentDataType().c_str();
+ //cout << "component : " << ind << " >> " << mod_name.latin1() << endl;
+ if( !mod_name.isEmpty() )
+ return mod_name;
+ }
+
return QtxValue();
}
QtxValue SalomeApp_Selection::globalParam( const QString& p ) const
{
if ( p == "client" ) return QtxValue( myPopupClient );
+ else if ( p == "activeModule" )
+ {
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( myStudy->application() );
+ QString mod_name = app ? QString( app->activeModule()->name() ) : QString::null;
+ //cout << "activeModule : " << mod_name.latin1() << endl;
+ if( !mod_name.isEmpty() )
+ return mod_name;
+ else
+ return QtxValue();
+ }
else if ( p == "isActiveView" ) return QtxValue( (bool)activeVW() );
else if ( p == "activeView" ) return QtxValue( activeViewType() );
#ifndef WNT
--- /dev/null
+
+#include "SalomeApp_ShowHideOp.h"
+#include "SalomeApp_Application.h"
+#include "SalomeApp_SelectionMgr.h"
+#include "SalomeApp_DataOwner.h"
+#include "SalomeApp_Selection.h"
+#include "SalomeApp_Module.h"
+#include "SalomeApp_Displayer.h"
+
+SalomeApp_ShowHideOp::SalomeApp_ShowHideOp( ActionType type )
+: SalomeApp_Operation(),
+ myActionType( type )
+{
+}
+
+SalomeApp_ShowHideOp::~SalomeApp_ShowHideOp()
+{
+}
+
+void SalomeApp_ShowHideOp::startOperation()
+{
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
+ if( !app )
+ {
+ abort();
+ return;
+ }
+
+ SalomeApp_SelectionMgr* mgr = app->selectionMgr();
+ SalomeApp_Selection sel; sel.init( "", mgr );
+ if( sel.count()==0 )
+ {
+ abort();
+ return;
+ }
+
+ QString mod_name = app->moduleTitle( sel.param( 0, "component" ).toString() );
+ SalomeApp_Module* m = dynamic_cast<SalomeApp_Module*>( app ? app->module( mod_name ) : 0 );
+ if( !m )
+ {
+ m = dynamic_cast<SalomeApp_Module*>( app->loadModule( mod_name ) );
+ app->addModule( m );
+ m->setMenuShown( false );
+ m->setToolShown( false );
+ }
+
+ SalomeApp_Displayer* d = m ? m->displayer(): 0;
+ if( !d )
+ {
+ abort();
+ return;
+ }
+
+ if( myActionType==DISPLAY_ONLY )
+ d->EraseAll( false, false, 0 );
+
+ SUIT_DataOwnerPtrList selected;
+ mgr->selected( selected );
+ SUIT_DataOwnerPtrList::const_iterator anIt = selected.begin(), aLast = selected.end();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ SalomeApp_DataOwner* owner = dynamic_cast<SalomeApp_DataOwner*>( (*anIt).operator->() );
+ if( !owner )
+ continue;
+
+ if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY )
+ d->Display( owner->entry(), false, 0 );
+ else if( myActionType==ERASE )
+ d->Erase( owner->entry(), false, false, 0 );
+ }
+ d->UpdateViewer();
+ commit();
+}
+
--- /dev/null
+
+#ifndef SALOMEAPP_SHOW_HIDE_OPERATION_HEADER
+#define SALOMEAPP_SHOW_HIDE_OPERATION_HEADER
+
+#include "SalomeApp_Operation.h"
+
+class SalomeApp_ShowHideOp : public SalomeApp_Operation
+{
+ Q_OBJECT
+
+public:
+ typedef enum { DISPLAY, ERASE, DISPLAY_ONLY } ActionType;
+
+public:
+ SalomeApp_ShowHideOp( ActionType );
+ ~SalomeApp_ShowHideOp();
+
+protected:
+ virtual void startOperation();
+
+private:
+ ActionType myActionType;
+};
+
+#endif
+