SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
# Common CMake macros
# ===================
return intId != -1 ? id : -1;
}
+/*!
+ Clears given toolbar.
+ \param title - title of toolbar
+*/
+void CAM_Module::clearTool( const QString& title )
+{
+ if ( toolMgr() )
+ toolMgr()->clear( title );
+}
+
/*!
\brief Create menu or submenu.
int createTool( const int, const QString&, const int = -1 );
int createTool( QAction*, const int, const int = -1, const int = -1 );
int createTool( QAction*, const QString&, const int = -1, const int = -1 );
+ void clearTool( const QString& title );
int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1,QMenu * = 0);
int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
remove( id, find( title ) );
}
+/*!
+ \brief Remove all actions from toolbar.
+ \param tid toolbar ID
+*/
+void QtxActionToolMgr::clear( const int tid )
+{
+ if ( !myToolBars.contains( tid ) )
+ return;
+
+ myToolBars[tid].nodes.clear();
+
+ triggerUpdate( tid );
+}
+
+/*!
+ \brief Remove all actions from toolbar.
+ \param title toolbar title
+*/
+void QtxActionToolMgr::clear( const QString& title )
+{
+ clear( find( title ) );
+}
+
/*!
\brief Get toolbar by given \a tid.
\param tid toolbar ID
void remove( const int, const int );
void remove( const int, const QString& );
+ void clear( const int );
+ void clear( const QString& );
QToolBar* toolBar( const int ) const;
QToolBar* toolBar( const QString& ) const;
CrTool( QAction* action, const QString& tBar, const int id, const int idx )
: myCase( 4 ), myAction( action ), myTbTitle( tBar ), myId( id ), myIndex( idx ) {}
- int execute( LightApp_Module* module ) const
+ int execute() const
{
- if ( module ) {
- switch ( myCase ) {
- case 0:
- return module->createTool( myTbTitle, myTbName );
- case 1:
- return module->createTool( myId, myTbId, myIndex );
- case 2:
- return module->createTool( myId, myTbTitle, myIndex );
- case 3:
- return module->createTool( myAction, myTbId, myId, myIndex );
- case 4:
- return module->createTool( myAction, myTbTitle, myId, myIndex );
- }
+ switch ( myCase ) {
+ case 0:
+ if ( getActiveModule() )
+ return getActiveModule()->createTool( myTbTitle, myTbName );
+ else if ( getApplication() )
+ return getApplication()->createTool( myTbTitle, myTbName );
+ case 1:
+ if ( getActiveModule() )
+ return getActiveModule()->createTool( myId, myTbId, myIndex );
+ else if ( getApplication() )
+ return getApplication()->createTool( myId, myTbId, myIndex );
+ case 2:
+ if ( getActiveModule() )
+ return getActiveModule()->createTool( myId, myTbTitle, myIndex );
+ else if ( getApplication() )
+ return getApplication()->createTool( myId, myTbTitle, myIndex );
+ case 3:
+ if ( getActiveModule() )
+ return getActiveModule()->createTool( myAction, myTbId, myId, myIndex );
+ else if ( getApplication() )
+ return getApplication()->createTool( myAction, myTbId, myId, myIndex );
+ case 4:
+ if ( getActiveModule() )
+ return getActiveModule()->createTool( myAction, myTbTitle, myId, myIndex );
+ else if ( getApplication() )
+ return getApplication()->createTool( myAction, myTbTitle, myId, myIndex );
}
return -1;
}
: myResult( -1 ), myCrTool( crTool ) {}
virtual void Execute()
{
- LightApp_Module* module = getActiveModule();
- if ( module )
- myResult = myCrTool.execute( module );
+ myResult = myCrTool.execute();
}
};
return ProcessEvent( new TCreateToolEvent( CrTool( a, tBar, id, idx ) ) );
}
+
+/*!
+ \brief Clear given toolbar.
+ \param title toolbar's title
+*/
+void SalomePyQt::clearTool( const QString& title )
+{
+ class TEvent: public SALOME_Event
+ {
+ QString myTitle;
+ public:
+ TEvent( const QString& title )
+ : myTitle( title ) {}
+ virtual void Execute()
+ {
+ if ( getActiveModule() )
+ return getActiveModule()->clearTool( myTitle );
+ else if ( getApplication() )
+ return getApplication()->clearTool( myTitle );
+ }
+ };
+ ProcessVoidEvent( new TEvent( title ) );
+}
+
/*!
\brief Insert action to the toolbar.
\param a action
CrMenu( QAction* action, const QString& menu, const int id, const int group, const int idx )
: myCase( 5 ), myAction( action ), myMenuName( menu ), myId( id ), myGroup( group ), myIndex( idx ) {}
- int execute( LightApp_Module* module ) const
+ int execute() const
{
- if ( module ) {
- switch ( myCase ) {
- case 0:
- return module->createMenu( mySubMenuName, myMenuId, myId, myGroup, myIndex );
- case 1:
- return module->createMenu( mySubMenuName, myMenuName, myId, myGroup, myIndex );
- case 2:
- return module->createMenu( myId, myMenuId, myGroup, myIndex );
- case 3:
- return module->createMenu( myId, myMenuName, myGroup, myIndex );
- case 4:
- return module->createMenu( myAction, myMenuId, myId, myGroup, myIndex );
- case 5:
- return module->createMenu( myAction, myMenuName, myId, myGroup, myIndex );
- }
+ switch ( myCase ) {
+ case 0:
+ if ( getActiveModule() )
+ return getActiveModule()->createMenu( mySubMenuName, myMenuId, myId, myGroup, myIndex );
+ else if ( getApplication() )
+ return getApplication()->createMenu( mySubMenuName, myMenuId, myId, myGroup, myIndex );
+ case 1:
+ if ( getActiveModule() )
+ return getActiveModule()->createMenu( mySubMenuName, myMenuName, myId, myGroup, myIndex );
+ else if ( getApplication() )
+ return getApplication()->createMenu( mySubMenuName, myMenuName, myId, myGroup, myIndex );
+ case 2:
+ if ( getActiveModule() )
+ return getActiveModule()->createMenu( myId, myMenuId, myGroup, myIndex );
+ else if ( getApplication() )
+ return getApplication()->createMenu( myId, myMenuId, myGroup, myIndex );
+ case 3:
+ if ( getActiveModule() )
+ return getActiveModule()->createMenu( myId, myMenuName, myGroup, myIndex );
+ else if ( getApplication() )
+ return getApplication()->createMenu( myId, myMenuName, myGroup, myIndex );
+ case 4:
+ if ( getActiveModule() )
+ return getActiveModule()->createMenu( myAction, myMenuId, myId, myGroup, myIndex );
+ else if ( getApplication() )
+ return getApplication()->createMenu( myAction, myMenuId, myId, myGroup, myIndex );
+ case 5:
+ if ( getActiveModule() )
+ return getActiveModule()->createMenu( myAction, myMenuName, myId, myGroup, myIndex );
+ else if ( getApplication() )
+ return getApplication()->createMenu( myAction, myMenuName, myId, myGroup, myIndex );
}
return -1;
}
: myResult( -1 ), myCrMenu( crMenu ) {}
virtual void Execute()
{
- LightApp_Module* module = getActiveModule();
- if ( module )
- myResult = myCrMenu.execute( module );
+ myResult = myCrMenu.execute();
}
};
static int createTool( const int, const QString&, const int = -1 );
static int createTool( QAction*, const int, const int = -1, const int = -1 );
static int createTool( QAction*, const QString&, const int = -1, const int = -1 );
+ static void clearTool( const QString& );
static int createMenu( const QString&, const int = -1,
const int = -1, const int = -1, const int = -1 );
static int createTool( const int, const QString&, const int = -1 ) /ReleaseGIL/ ;
static int createTool( QAction*, const int, const int = -1, const int = -1 ) /ReleaseGIL/ ;
static int createTool( QAction*, const QString&, const int = -1, const int = -1 ) /ReleaseGIL/ ;
+ static void clearTool( const QString& ) /ReleaseGIL/ ;
static int createMenu( const QString&, const int,
const int = -1, const int = -1, const int = -1 ) /ReleaseGIL/ ;
return intId != -1 ? id : -1;
}
+/*!
+ Clears given toolbar.
+ \param title - title of toolbar
+*/
+void SUIT_Application::clearTool( const QString& title )
+{
+ if ( desktop() && desktop()->toolMgr() )
+ desktop()->toolMgr()->clear( title );
+}
+
/*!
Creates new menu item
\return identificator of new action in menu manager
void addPostRoutine( void (*theRoutine)() );
+ /** @name Create tool functions*/ //@{
+ int createTool( const QString&, const QString& = QString() );
+ int createTool( const int, const int, const int = -1 );
+ int createTool( const int, const QString&, const int = -1 );
+ int createTool( QAction*, const int, const int = -1, const int = -1 );
+ int createTool( QAction*, const QString&, const int = -1, const int = -1 );//@}
+ void clearTool( const QString& );
+
+ /** @name Create menu functions*/ //@{
+ int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
+ int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
+ int createMenu( const int, const int, const int = -1, const int = -1 );
+ int createMenu( const int, const QString&, const int = -1, const int = -1 );
+ int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
+ int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );//@}
+
signals:
void applicationClosed( SUIT_Application* );
void activated( SUIT_Application* );
virtual SUIT_Study* createNewStudy();
virtual void setActiveStudy( SUIT_Study* );
- /** @name Create tool functions*/ //@{
- int createTool( const QString&, const QString& = QString() );
- int createTool( const int, const int, const int = -1 );
- int createTool( const int, const QString&, const int = -1 );
- int createTool( QAction*, const int, const int = -1, const int = -1 );
- int createTool( QAction*, const QString&, const int = -1, const int = -1 );//@}
-
- /** @name Create menu functions*/ //@{
- int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
- int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
- int createMenu( const int, const int, const int = -1, const int = -1 );
- int createMenu( const int, const QString&, const int = -1, const int = -1 );
- int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
- int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );//@}
-
/** @name Set menu shown functions*/ //@{
void setMenuShown( QAction*, const bool );
void setMenuShown( const int, const bool );//@}
self.lasttime=0
self.plugindirs=[]
self.plugins_files=[]
+ self.toolbar = None
# MODULES plugins directory.
# The SALOME modules may provides natively some plugins. These
else:
self.menu=QMenu(self.menuname,self.basemenu)
self.basemenu.addMenu(self.menu)
+ self.toolbar=sgPyQt.createTool(self.menuname)
self.menu.menuAction().setVisible(False)
self.basemenu.aboutToShow.connect(self.importPlugins)
+ self.importPlugins() # to create toolbar immediately
+
def analyseFile(self,filename):
"""
This function checks if the specified file is a plugins python
self.plugindirs.append(dirpath)
logger.debug("The directory %s has been added to plugin paths"%dirpath)
- def AddFunction(self,name,description,script):
+ def AddFunction(self,name,description,script,icon=None):
""" Add a plugin function
"""
- self.registry[name]=script,description
+ self.registry[name]=script,description,icon
self.entries.append(name)
def handler(obj=self,script=script):
def updateMenu(self):
"""Update the Plugins menu"""
self.menu.clear()
+ sgPyQt.clearTool(self.menuname)
for entry in self.entries:
names=entry.split("/")
if len(names) < 1:continue
name=names.pop(0)
act=parentMenu.addAction(name,self.handlers[entry])
act.setStatusTip(self.registry[entry][1])
+ icon = self.registry[entry][2] if len(self.registry[entry])>2 else None
+ if icon is not None and not icon.isNull() and icon.availableSizes():
+ act.setIcon(icon)
+ sgPyQt.createTool(act, self.toolbar)
self.menu.menuAction().setVisible(True)
-def AddFunction(name,description,script):
+def AddFunction(name,description,script,icon=None):
""" Add a plugin function
Called by a user to register a function (script)
"""
- return current_plugins_manager.AddFunction(name,description,script)
+ return current_plugins_manager.AddFunction(name,description,script,icon)
def entries():
""" Return the list of entries in menu: can be sorted or modified in place to customize menu content """
virtual bool notify( QObject* receiver, QEvent* e )
{
-
- try {
- return myHandler ? myHandler->handle( receiver, e ) : QApplication::notify( receiver, e );
- }
- catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
+ QString debug_exceptions = ::getenv("SALOME_DEBUG_EXCEPTIONS");
+ if ( debug_exceptions.length() > 0 ) {
+ return QApplication::notify( receiver, e );
}
- catch (CORBA::Exception& e) {
- std::cerr << "Caught CORBA::Exception" << std::endl;
- CORBA::Any tmp;
- tmp<<= e;
- CORBA::TypeCode_var tc = tmp.type();
- const char *p = tc->name();
- std::cerr << "notify(): CORBA exception of the kind : " << p << " is caught" << std::endl;
- }
- catch (...) {
- std::cerr << "Unknown exception caught in Qt handler: it's probably a bug in SALOME platform" << std::endl;
+ else {
+ try {
+ return myHandler ? myHandler->handle( receiver, e ) : QApplication::notify( receiver, e );
+ }
+ catch (std::exception& e) {
+ std::cerr << e.what() << std::endl;
+ }
+ catch (CORBA::Exception& e) {
+ std::cerr << "Caught CORBA::Exception" << std::endl;
+ CORBA::Any tmp;
+ tmp<<= e;
+ CORBA::TypeCode_var tc = tmp.type();
+ const char *p = tc->name();
+ std::cerr << "notify(): CORBA exception of the kind : " << p << " is caught" << std::endl;
+ }
+ catch (...) {
+ std::cerr << "Unknown exception caught in Qt handler: it's probably a bug in SALOME platform" << std::endl;
+ }
+ return false; // return false when exception is caught
}
- return false; // return false when exception is caught
}
SUIT_ExceptionHandler* handler() const { return myHandler; }
void setHandler( SUIT_ExceptionHandler* h ) { myHandler = h; }