1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : QAD_Desktop.cxx
25 // Author : Nicolas REJNERI
30 \class QAD_Desktop QAD_Desktop.h
31 \brief Main desktop of QAD-based application.
33 # include "Utils_ORB_INIT.hxx"
34 # include "Utils_SINGLETON.hxx"
36 #define INCLUDE_MENUITEM_DEF
37 #define DEFAULT_BROWSER "mozilla"
42 #include "QAD_Tools.h"
43 #include "QAD_Desktop.h"
44 #include "QAD_LeftFrame.h"
45 #include "QAD_RightFrame.h"
46 #include "QAD_PyEditor.h"
47 #include "QAD_Operation.h"
48 #include "QAD_XmlHandler.h"
49 #include "QAD_MessageBox.h"
50 #include "QAD_Application.h"
51 #include "QAD_Settings.h"
52 #include "QAD_Config.h"
53 #include "QAD_ObjectBrowser.h"
54 #include "QAD_Resource.h"
55 #include "QAD_FileDlg.h"
56 //NRI #include "QAD_HelpWindow.h"
57 #include "QAD_DirListDlg.h"
58 #include "QAD_WaitCursor.h"
59 #include "SALOMEGUI.h"
60 #include "SALOMEGUI_OpenWith.h"
61 #include "SALOMEGUI_StudyPropertiesDlg.h"
62 #include "SALOMEGUI_TrihedronSizeDlg.h"
63 #include "SALOMEGUI_ExternalBrowserDlg.h"
64 #include "SALOMEGUI_LoadStudiesDlg.h"
65 //#include "SALOME_Selection.h"
66 #include "SALOME_InteractiveObject.hxx"
67 #include "SALOME_ListIteratorOfListIO.hxx"
68 #include "SALOMEGUI_AboutDlg.h"
69 #include "SALOMEGUI_ViewChoiceDlg.h"
70 #include "SALOMEGUI_SetValueDlg.h"
71 #include "utilities.h"
73 #include "SALOMEGUI_CloseDlg.h"
74 #include "SALOMEGUI_ActivateComponentDlg.h"
75 #include "SALOMEGUI_QtCatchCorbaException.hxx"
77 #include "SALOME_Event.hxx"
83 #include <qmessagebox.h>
84 #include <qcolordialog.h>
85 #include <qradiobutton.h>
86 #include <qapplication.h>
87 #include <qvbuttongroup.h>
89 #include <qmessagebox.h>
92 #include <qpopupmenu.h>
93 #include <qlistview.h>
97 #include <qfontdialog.h>
98 #include <qlineedit.h>
99 #include <qdatetime.h>
101 #include <qtooltip.h>
102 #include <qstringlist.h>
105 #include <qlistbox.h>
109 // Open CASCADE Includes
110 #include <OSD_SharedLibrary.hxx>
111 #include <OSD_LoadMode.hxx>
112 #include <OSD_Function.hxx>
113 #include <TCollection_AsciiString.hxx>
116 static const char* SEPARATOR = ":";
135 QAD_ResourceMgr* QAD_Desktop::resourceMgr = 0;
136 QPalette* QAD_Desktop::palette = 0;
138 static QString createString( int theItemId, int thePosId )
140 QString aRetString = QString("item-id=");
142 QString aItemId = aString.setNum(theItemId);
143 QString aPosId = aString.setNum(thePosId);
144 aRetString = aRetString + '"'; aRetString = aRetString + aItemId; aRetString = aRetString + '"';
145 aRetString = aRetString + " pos-id="; aRetString = aRetString + '"';
146 aRetString = aRetString + aPosId;
147 aRetString = aRetString + '"'; aRetString = aRetString + ">";
152 Creates the resource manager [ static ]
154 QAD_ResourceMgr* QAD_Desktop::createResourceManager()
157 resourceMgr = new QAD_ResourceMgr;
162 Returns the resource manager [ static ]
164 QAD_ResourceMgr* QAD_Desktop::getResourceManager()
171 Loads the palette from settings [ static ]
173 QPalette* QAD_Desktop::createPalette()
176 palette = new QPalette();
182 Returns the palette [ static ]
184 QPalette* QAD_Desktop::getPalette()
190 // Gets window ratio width/heght [ static ]
193 //static double getWindowRatio()
195 // return myWindowRatio;
199 // Sets window ratio width/heght [ static ]
201 //static void setWindowRatio(double aRatio)
203 // myWindowRatio = aRatio;
209 QAD_Desktop::QAD_Desktop(SALOME_NamingService* name_service) :
210 QMainWindow(0, 0, WType_TopLevel | WDestructiveClose),
216 //NRImyHelpWindow(0),
217 myDefaultTitle( tr("DESK_DEFAULTTITLE") ),
218 myQueryClose( true ),
219 myAboutToClose( false )
221 /* Force reading of user config file */
222 QAD_CONFIG->readConfigFile();
224 /* menubar and status bar */
225 myStatusBar = statusBar();
226 myMainMenu = menuBar();
228 myNameService = name_service;
230 /* default background icon */
231 QPixmap backgroundicon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
232 tr("ICON_DESK_BACKGROUNDICON") ));
233 //myToolBarAction.setAutoDelete( true );
235 /* default icon and title */
236 QPixmap icon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
237 tr("ICON_DESK_DEFAULTICON") ));
238 if ( !icon.isNull() ) {
239 myDefaultIcon = icon;
240 setIcon( myDefaultIcon );
242 setCaption( myDefaultTitle );
244 /* set size as 1/2 of the screen and center it */
245 QWidget* d = QApplication::desktop();
246 resize( 2*d->width()/3, 2*d->height()/3 );
247 QAD_Tools::centerWidget( this, d );
249 /* workspace will manage child frames */
250 QHBox* border = new QHBox ( this );
251 border->setFrameStyle ( QFrame::Panel | QFrame::Sunken );
252 setCentralWidget( border );
253 myWorkspace = new QWorkspaceP( border );
255 QPalette pal = QAD_Application::getPalette();
257 QColorGroup cgA = pal.active();
258 QColorGroup cgI = pal.inactive();
259 QColorGroup cgD = pal.disabled();
260 cgA.setColor( QColorGroup::Background, QColor(192, 192, 192));
261 cgI.setColor( QColorGroup::Background, QColor(192, 192, 192));
262 cgD.setColor( QColorGroup::Background, QColor(192, 192, 192));
263 pal.setActive ( cgA );
264 pal.setInactive( cgI );
265 pal.setDisabled( cgD );
266 myWorkspace->setPalette( pal );
267 if ( !backgroundicon.isNull() ) {
268 MESSAGE("!!!DESKTOP background icon found!!!");
269 myWorkspace->setPaletteBackgroundPixmap(backgroundicon);
272 /* define standard file commands */
275 /* define operator menus for xml */
276 myOperatorMenus = new QAD_OperatorMenus(this);
277 myXmlHandler = new QAD_XmlHandler();
280 CORBA::Object_var objVarN = myNameService->Resolve("/Kernel/ModulCatalog");
281 myCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
283 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants =
284 myCatalogue->GetComponentIconeList();
287 QToolBar* tbComponent = new QToolBar( tr("MEN_DESK_COMPONENTTOOLBAR"), this );
288 tbComponent->setCloseMode( QDockWindow::Undocked );
289 addToolBar(tbComponent, tr("MEN_DESK_COMPONENTTOOLBAR"), Bottom, TRUE );
290 setDockEnabled( tbComponent, DockLeft, false );
291 setDockEnabled( tbComponent, DockRight, false );
293 myCombo = new QComboBox( FALSE, tbComponent, "comboBox" );
294 myCombo->setFocusPolicy( NoFocus );
296 tbComponent->addSeparator();
298 // PG : add ResourceManager to get function findFile !!
299 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
301 for (unsigned int ind = 0; ind < list_composants->length();ind++) {
304 /* find component icon */
305 QString iconfile = CORBA::string_dup(list_composants[ind].moduleicone) ;
306 QString modulename = CORBA::string_dup(list_composants[ind].modulename) ;
307 QString moduleusername = CORBA::string_dup(list_composants[ind].moduleusername) ;
308 QString moduleversion = CORBA::string_dup(list_composants[ind].moduleversion) ;
309 QString modulecomment = CORBA::string_dup(list_composants[ind].modulecomment) ;
311 // MESSAGE ( " MODULE = " << modulename )
312 // MESSAGE ( " MODULE icon = " << iconfile )
313 // MESSAGE ( " MODULE username = " << moduleusername )
315 if ( mapComponentName.contains( moduleusername ) ) {
316 QMessageBox::warning( this, tr("WRN_WARNING"), QString( moduleusername + " is already associated with " + mapComponentName[moduleusername] + ".\nPlease, change the component username of " + modulename) , tr ("BUT_OK") );
319 mapComponentName.insert( moduleusername, modulename );
321 resDir = resMgr->findFile(iconfile,modulename) ;
324 MESSAGE ( "resDir" << resDir )
325 //resDir = QAD_Tools::addSlash(resDir) ;
326 //QPixmap Icone(resDir+iconfile) ;
327 QPixmap Icone( QAD_Tools::addSlash( resDir ) + iconfile );
328 QToolButton * toolb =
329 new QToolButton( QIconSet( Icone ), moduleusername, QString::null, this,
330 SLOT( onButtonActiveComponent () ),tbComponent );
331 QString ttip = QString("<b>") + moduleusername + QString("</b>");
332 if ( !moduleversion.isEmpty() ) ttip += QString("<br>Version: ") + moduleversion;
333 toolb->setToggleButton( true );
334 QToolTip::add(toolb, ttip, this->toolTipGroup(), modulecomment);
335 myComponentButton.append(toolb);
339 QString errMsg = tr("INF_ICON_RESOURCES").arg(iconfile).arg(modulename) +
341 //QMessageBox::warning( this, tr("WRN_WARNING"), errMsg, tr ("BUT_OK") );
343 if ( ( resDir || moduleusername == "Salome" ) && !modulename.isEmpty() ) // VSR: Force "Salome" component to appear in the combo box
344 myCombo->insertItem( moduleusername );
347 myCombo->adjustSize();
348 connect( myCombo, SIGNAL(activated(const QString&)),
349 this, SLOT( onComboActiveComponent(const QString&) ) );
351 /* new LifeCycleCORBA client, for Engines */
352 myEnginesLifeCycle = new SALOME_LifeCycleCORBA(name_service);
354 /* VSR 13/01/03 : installing global event filter for the application */
355 qApp->installEventFilter( this );
357 /* init pseudo random numbers generator */
358 QTime cTime = QTime::currentTime();
359 int secs = cTime.second() + 1;
360 for ( int s = 0; s < secs; s++ ) random();
366 QAD_Desktop::~QAD_Desktop ()
368 qApp->removeEventFilter( this );
372 myObjBrowserPopup.clear();
373 //VRV: T2.5 - add default viewer
374 myDefaultViewer.clear();
375 //VRV: T2.5 - add default viewer
376 myViewerPopup.clear();
378 myNewViewPopup.clear();
380 myHelpContentsModulePopup.clear();
381 myToolsPopup.clear();
383 myStdActions.clear();
385 myToolBarsPopup.clear();
386 myToolBarAction.clear();
389 //NRI if (myHelpWindow)
390 // myHelpWindow->close();
392 QAD_Application::desktop = 0;
395 const int IdCut = 1001;
396 const int IdCopy = 1002;
397 const int IdPaste = 1003;
398 const int IdSelectAll = 1004;
400 #include <qkeysequence.h>
401 #define ACCEL_KEY(k) "\t" + QString(QKeySequence( Qt::CTRL | Qt::Key_ ## k ))
403 #define ACCEL_KEY(k) "\t" + QString("Ctrl+" #k)
405 #include <qclipboard.h>
407 Global event filter for qapplication (VSR 13/01/03)
409 bool QAD_Desktop::eventFilter( QObject* o, QEvent* e )
411 if (e->type() == QEvent::Close && o == this )
412 myAboutToClose = true;
413 else if (e->type() == 2000 ) {
414 QMessageBox::information (this, tr ( "Help Information" ), tr ( "Can't run choosen browser.\nRunning default browser (Mozilla). "));
417 else if (e->type() == 2001 ) {
418 QMessageBox::critical(this, tr ( "Help Error" ), tr ( "Can't run the default browser.") );
421 else if ( e->type() == QEvent::ContextMenu ) {
422 QContextMenuEvent* ce = (QContextMenuEvent*)e;
423 if ( o->inherits("QRenameEdit") ) {
426 else if ( o->inherits("QLineEdit") ) {
427 QLineEdit* le = (QLineEdit*)o;
428 if ( le->parentWidget() ) {
429 if ( ( le->parentWidget()->inherits("QSpinBox") ||
430 le->parentWidget()->inherits("QSpinWidget") ||
431 le->parentWidget()->inherits("QAD_SpinBoxDbl") ) &&
433 QPopupMenu* popup = new QPopupMenu( 0, "qt_edit_menu" );
434 popup->insertItem( tr( "EDIT_CUT_CMD" ) + ACCEL_KEY( X ), IdCut );
435 popup->insertItem( tr( "EDIT_COPY_CMD" ) + ACCEL_KEY( C ), IdCopy );
436 popup->insertItem( tr( "EDIT_PASTE_CMD" ) + ACCEL_KEY( V ), IdPaste );
437 popup->insertSeparator();
438 #if defined(Q_WS_X11)
439 popup->insertItem( tr( "EDIT_SELECTALL_CMD" ), IdSelectAll );
441 popup->insertItem( tr( "EDIT_SELECTALL_CMD" ) + ACCEL_KEY( A ), IdSelectAll );
443 bool enableCut = !le->isReadOnly() && le->hasSelectedText();
444 popup->setItemEnabled( IdCut, enableCut );
445 popup->setItemEnabled( IdCopy, le->hasSelectedText() );
446 bool enablePaste = !le->isReadOnly() && !QApplication::clipboard()->text().isEmpty();
447 popup->setItemEnabled( IdPaste, enablePaste );
448 bool allSelected = (le->selectedText() == le->text() );
449 popup->setItemEnabled( IdSelectAll, (bool)(le->text().length()) && !allSelected );
451 QPoint pos = ce->reason() == QContextMenuEvent::Mouse ? ce->globalPos() :
452 le->mapToGlobal( QPoint(ce->pos().x(), 0) ) + QPoint( le->width() / 2, le->height() / 2 );
454 int r = popup->exec( pos );
476 else if ( e->type() == SALOME_EVENT ) {
477 SALOME_Event* aSE = (SALOME_Event*)((QCustomEvent*)e)->data();
479 ((QCustomEvent*)e)->setData( 0 );
482 return QMainWindow::eventFilter( o, e );
486 Dispatches <theEvent> to the target component GUI
488 void QAD_Desktop::processEvent( SALOME_Event* theEvent )
492 // Signal the calling thread that the event has been processed
493 theEvent->processed();
498 Creates and initializes the standard file operations
499 such as 'New/Open/Save/SaveAs/Close' and 'Help'.
501 void QAD_Desktop::createActions()
504 /* Used for string compare */
505 const QString& aTrueQString = "true" ;
507 /* create 'standard' toolbar */
508 if ( !myStdToolBar ) {
509 myStdToolBar = new QToolBar ( tr("MEN_DESK_VIEW_STDTOOLBAR"), this );
510 myStdToolBar->setCloseMode( QDockWindow::Undocked );
513 if ( !myMainMenu->count() ) {
514 /* Create main menu bar */
515 myMainMenu->insertItem ( tr("MEN_DESK_FILE"), &myFilePopup, 1 ); /* add popup FILE */
516 myMainMenu->insertItem ( tr("MEN_DESK_VIEW"), &myViewPopup, 2 ); /* add popup VIEW */
517 myMainMenu->insertItem ( tr("MEN_DESK_TOOLS"), &myToolsPopup, 5 ); /* add popup TOOLS */
518 myMainMenu->insertItem ( tr("MEN_DESK_PREF"), &myPrefPopup, 4 ); /* add popup PREF */
519 myMainMenu->insertItem ( tr("MEN_DESK_WINDOW"), &myWindowPopup, 6 ); /* add popup WINDOW */
520 myMainMenu->insertItem ( tr("MEN_DESK_HELP"), &myHelpPopup, 7 ); /* add popup HELP */
522 /* Applications will insert their items after 'File' 'Edit' and 'View'
523 ( 'Edit' will be inserted later )
528 /* insert logo picture to menu bar */
529 QHBox* aLogoFrm = new QHBox(this);
530 aLogoFrm->setFrameStyle( QFrame::Plain | QFrame::NoFrame );
531 QPixmap aLogoPixmap ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
532 tr("ICON_DESK_LOGO") ));
533 QLabel* aLogoLab = new QLabel(aLogoFrm);
534 aLogoLab->setPixmap(aLogoPixmap);
535 aLogoLab->setAlignment(AlignCenter);
536 aLogoLab->setScaledContents(false);
537 myMainMenu->insertItem(aLogoFrm);
539 if ( myStdActions.isEmpty() ) {
540 /* Define standard actions. They should be inserted
541 into the list in order of their IDs.
546 QAD_ResourceMgr* rmgr = QAD_Desktop::getResourceManager();
547 QActionP* fileNewAction = new QActionP ( tr("TOT_DESK_FILE_NEW"),
548 rmgr->loadPixmap( "QAD", tr("ICON_FILE_NEW") ) ,
549 tr("MEN_DESK_FILE_NEW"), CTRL+Key_N, this );
550 fileNewAction->setStatusTip ( tr("PRP_DESK_FILE_NEW") );
551 fileNewAction->setEnabled ( true );
552 QAD_ASSERT ( connect( fileNewAction, SIGNAL( activated() ), this, SLOT( onNewStudy() )));
553 fileNewAction->addTo( myStdToolBar );
554 fileNewAction->addTo( &myFilePopup );
555 myStdActions.insert ( FileNewId, fileNewAction );
558 QActionP* fileOpenAction = new QActionP( tr("TOT_DESK_FILE_OPEN"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_OPEN") ),
559 tr("MEN_DESK_FILE_OPEN"), CTRL+Key_O, this );
560 fileOpenAction->setStatusTip ( tr("PRP_DESK_FILE_OPEN") );
561 fileOpenAction->setEnabled ( true );
562 QAD_ASSERT ( connect( fileOpenAction, SIGNAL( activated() ), this, SLOT( onOpenStudy() )));
563 fileOpenAction->addTo( myStdToolBar );
564 fileOpenAction->addTo( &myFilePopup );
565 myStdActions.insert ( FileOpenId, fileOpenAction );
568 QActionP* fileLoadAction = new QActionP( tr("TOT_DESK_FILE_LOAD"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_LOAD") ),
569 tr("MEN_DESK_FILE_LOAD"), CTRL+Key_L, this );
570 fileLoadAction->setStatusTip ( tr("PRP_DESK_FILE_LOAD") );
571 fileLoadAction->setEnabled ( true );
572 QAD_ASSERT ( connect( fileLoadAction, SIGNAL( activated() ), this, SLOT( onLoadStudy() )));
573 fileLoadAction->addTo( &myFilePopup );
574 myStdActions.insert ( FileLoadId, fileLoadAction );
577 QActionP* fileCloseAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_FILE_CLOSE") ),
578 tr("MEN_DESK_FILE_CLOSE"), CTRL+Key_W, this );
579 fileCloseAction->setStatusTip ( tr("PRP_DESK_FILE_CLOSE") );
580 QAD_ASSERT ( connect( fileCloseAction, SIGNAL( activated() ), this, SLOT( onCloseStudy() )));
581 fileCloseAction->addTo( &myFilePopup );
582 myStdActions.insert ( FileCloseId, fileCloseAction );
585 myFilePopup.insertSeparator();
588 QActionP* fileSaveAction = new QActionP( tr("TOT_DESK_FILE_SAVE"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_SAVE") ),
589 tr("MEN_DESK_FILE_SAVE"), CTRL+Key_S, this );
590 fileSaveAction->setStatusTip ( tr("PRP_DESK_FILE_SAVE") );
591 QAD_ASSERT ( connect( fileSaveAction, SIGNAL( activated() ), this, SLOT( onSaveStudy() )));
592 fileSaveAction->addTo( myStdToolBar );
593 fileSaveAction->addTo( &myFilePopup );
594 myStdActions.insert ( FileSaveId, fileSaveAction );
597 QActionP* fileSaveAsAction = new QActionP( "", tr("MEN_DESK_FILE_SAVEAS"), 0, this );
598 fileSaveAsAction->setStatusTip ( tr("PRP_DESK_FILE_SAVEAS") );
599 QAD_ASSERT ( connect( fileSaveAsAction, SIGNAL( activated() ),
600 this, SLOT( onSaveAsStudy() )));
601 fileSaveAsAction->addTo( &myFilePopup );
602 myStdActions.insert ( FileSaveAsId, fileSaveAsAction );
606 myFilePopup.insertSeparator();
609 QActionP* filePropsAction = new QActionP( "", QPixmap(), tr("MEN_DESK_FILE_PROPERTIES"), 0, this );
610 filePropsAction->setStatusTip ( tr("PRP_DESK_FILE_PROPERTIES") );
611 filePropsAction->setEnabled(false);
612 QAD_ASSERT ( connect( filePropsAction, SIGNAL( activated() ), this, SLOT( onStudyProperties() )));
613 filePropsAction->addTo( &myFilePopup );
614 myStdActions.insert ( FilePropsId, filePropsAction );
617 int id = myFilePopup.insertSeparator();
618 /* keep the position from which an application will insert its items
619 to menu 'File' at the time of customization of the desktop */
621 myFilePos = myFilePopup.indexOf( id ) + 1;
623 /* exit application */
624 QActionP* exitAction = new QActionP( "", tr("MEN_DESK_FILE_EXIT"),
626 exitAction->setStatusTip ( tr("PRP_DESK_FILE_EXIT") );
627 QAD_ASSERT ( connect( exitAction, SIGNAL( activated() ),
628 this, SLOT( onExit() )));
629 exitAction->addTo( &myFilePopup );
630 myStdActions.insert ( FileExitId, exitAction );
632 QAD_ASSERT( connect( &myFilePopup, SIGNAL(highlighted( int )),
633 this, SLOT(onFilePopupStatusText( int )) ));
636 /* 'Edit' actions : provided by application only */
639 QAD_ASSERT( connect( &myEditPopup, SIGNAL(highlighted( int )),
640 this, SLOT(onEditPopupStatusText( int )) ));
643 /* toolbars popup menu */
644 myViewPopup.insertItem( tr("MEN_DESK_VIEW_TOOLBARS"), &myToolBarsPopup );
645 QAD_ASSERT( connect ( &myViewPopup, SIGNAL(aboutToShow()),
646 this, SLOT(onToolBarPopupAboutToShow()) ));
649 QActionP* viewStatusBarAction = new QActionP( "",
650 tr("MEN_DESK_VIEW_STATUSBAR"),
652 viewStatusBarAction->setStatusTip ( tr("PRP_DESK_VIEW_STATUSBAR") );
653 viewStatusBarAction->setOn( true );
654 QAD_ASSERT(connect( viewStatusBarAction, SIGNAL(activated()), this, SLOT(onViewStatusBar() )));
655 viewStatusBarAction->addTo( &myViewPopup );
656 myStdActions.insert( ViewStatusBarId, viewStatusBarAction );
658 // myViewPopup.insertItem( tr("MEN_DESK_SELECTION_MODE"), &mySelectionModePopup );
660 QActionP* SelectionPointAction = new QActionP( "", tr("MEN_DESK_SELECTION_POINT"), 0, this, 0, true );
661 QAD_ASSERT(connect( SelectionPointAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
662 SelectionPointAction->addTo( &mySelectionModePopup );
663 myStdActions.insert( SelectionPointId, SelectionPointAction );
665 QActionP* SelectionEdgeAction = new QActionP( "", tr("MEN_DESK_SELECTION_EDGE"), 0, this, 0, true );
666 QAD_ASSERT(connect( SelectionEdgeAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
667 SelectionEdgeAction->addTo( &mySelectionModePopup );
668 myStdActions.insert( SelectionEdgeId, SelectionEdgeAction );
670 QActionP* SelectionCellAction = new QActionP( "", tr("MEN_DESK_SELECTION_CELL"), 0, this, 0, true );
671 QAD_ASSERT(connect( SelectionCellAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
672 SelectionCellAction->addTo( &mySelectionModePopup );
673 myStdActions.insert( SelectionCellId, SelectionCellAction );
675 QActionP* SelectionActorAction = new QActionP( "", tr("MEN_DESK_SELECTION_ACTOR"), 0, this, 0, true );
676 QAD_ASSERT(connect( SelectionActorAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
677 SelectionActorAction->addTo( &mySelectionModePopup );
678 myStdActions.insert( SelectionActorId, SelectionActorAction );
679 SelectionActorAction->setOn(true);
681 myViewPos = myViewPopup.count();
683 QAD_ASSERT( connect( &myViewPopup, SIGNAL(highlighted( int )),
684 this, SLOT(onViewPopupStatusText( int )) ));
687 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
690 if(!resMgr->loadResources( "ToolsGUI", msg ))
692 //NRI QCString errMsg;
693 // errMsg.sprintf( "Do not load all resources for module ToolsGUI.\n" );
694 QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
698 myOperatorMenus = new QAD_OperatorMenus(this);
699 myXmlHandler = new QAD_XmlHandler();
700 ASSERT(myXmlHandler) ;
701 myXmlHandler->setMainWindow(this);
702 if ( myXmlHandler->setComponent( resMgr->resources( "ToolsGUI" ) ) ) {
703 QString language = resMgr->language( "ToolsGUI" );
704 QString ToolsXml = QString( "Tools_" ) + language + QString( ".xml" );
706 //ToolsXml = resMgr->resources("ToolsGUI") ;
707 //ToolsXml = QAD_Tools::addSlash(ToolsXml) ;
708 //ToolsXml = ToolsXml + "Tools_" + language + ".xml" ;
709 ToolsXml = QAD_Tools::addSlash( resMgr->findFile( ToolsXml, "ToolsGUI" ) ) + ToolsXml;
711 QFile file( QAD_Tools::unix2win( ToolsXml ) );
712 if ( file.exists() && file.open( IO_ReadOnly ) ) {
714 QXmlInputSource source( file );
715 QXmlSimpleReader reader;
716 reader.setContentHandler( myXmlHandler );
717 reader.setErrorHandler( myXmlHandler );
718 bool ok = reader.parse( source );
721 QMessageBox::critical( 0,
722 tr( "INF_PARSE_ERROR" ),
723 tr( myXmlHandler->errorProtocol() ) );
725 myMenusList=myXmlHandler->myMenusList;
726 myActiveMenus=myMenusList.at(0);
727 myOperatorMenus->showMenuBar(0);
728 myActiveMenus->showAllToolBars();
734 if ( myToolsPopup.count() == 0 ) {
735 myMainMenu->removeItem(5);
739 /* Viewer BackgroundColor */
740 myPrefPopup.insertItem( tr("MEN_DESK_PREF_VIEWER"), &myViewerPopup );
742 QActionP* viewerOCCAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this );
743 QAD_ASSERT(connect( viewerOCCAction, SIGNAL(activated()), this, SLOT(onViewerOCC() )));
744 viewerOCCAction->addTo( &myViewerPopup );
745 myStdActions.insert( PrefViewerOCCId, viewerOCCAction );
747 QActionP* viewerVTKAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this );
748 QAD_ASSERT(connect( viewerVTKAction, SIGNAL(activated()), this, SLOT(onViewerVTK() )));
749 viewerVTKAction->addTo( &myViewerPopup );
750 myStdActions.insert( PrefViewerVTKId, viewerVTKAction );
752 QActionP* graphSupervisorAction = new QActionP( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this );
753 QAD_ASSERT(connect( graphSupervisorAction, SIGNAL(activated()), this, SLOT(onGraphSupervisor() )));
754 graphSupervisorAction->addTo( &myViewerPopup );
755 myStdActions.insert( PrefGraphSupervisorId, graphSupervisorAction );
757 QActionP* viewerPlot2dAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this );
758 QAD_ASSERT(connect( viewerPlot2dAction, SIGNAL(activated()), this, SLOT(onPlot2d() )));
759 viewerPlot2dAction->addTo( &myViewerPopup );
760 myStdActions.insert( PrefViewerPlot2dId, viewerPlot2dAction );
762 //VRV: T2.5 - add default viewer
763 QString viewerValue = QAD_CONFIG->getSetting( "Viewer:DefaultViewer" );
765 int aViewerValue = viewerValue.toInt( &ok, 10 );
766 if (!ok || aViewerValue < VIEW_OCC || aViewerValue >= VIEW_TYPE_MAX)
767 aViewerValue = VIEW_VTK;
769 myPrefPopup.insertItem( tr("MEN_DESK_PREF_DEFAULT_VIEWER"), &myDefaultViewer );
770 QActionPGroup* myQAG = new QActionPGroup ( this);
771 QActionP* viewerOCCAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this );
772 viewerOCCAction1->setToggleAction ( true);
773 viewerOCCAction1->setOn ( aViewerValue == VIEW_OCC );
774 myQAG->insert( viewerOCCAction1 );
775 myStdActions.insert( DefaultViewerOCCId, viewerOCCAction1 );
777 QActionP* viewerVTKAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this );
778 viewerVTKAction1->setToggleAction ( true);
779 viewerVTKAction1->setOn ( aViewerValue == VIEW_VTK );
780 myQAG->insert( viewerVTKAction1 );
781 myStdActions.insert( DefaultViewerVTKId, viewerVTKAction1 );
783 /* Remove Supervisor viewer from setting the background */
784 // QActionP* graphSupervisorAction1 = new QActionP( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this );
785 // graphSupervisorAction1->setToggleAction ( true);
786 // graphSupervisorAction1->setOn ( aViewerValue == VIEW_GRAPHSUPERV );
787 // myQAG->insert( graphSupervisorAction1 );
788 // myStdActions.insert( DefaultGraphSupervisorId, graphSupervisorAction1 );
790 QActionP* viewerPlot2dAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this );
791 viewerPlot2dAction1->setToggleAction ( true);
792 viewerPlot2dAction1->setOn ( aViewerValue == VIEW_PLOT2D );
793 myQAG->insert( viewerPlot2dAction1 );
794 myStdActions.insert( DefaultPlot2dId, viewerPlot2dAction1 );
796 myQAG->addTo( &myDefaultViewer );
797 QAD_ASSERT(connect( myQAG, SIGNAL(selected(QActionP * )), this, SLOT(onDefaultViewer(QActionP *) )));
798 //VRV: T2.5 - add default viewer
800 myPrefPopup.insertSeparator();
802 QActionP* viewerTrihedronAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_TRIHEDRON"), 0, this );
803 QAD_ASSERT(connect( viewerTrihedronAction, SIGNAL(activated()), this, SLOT(onViewerTrihedron() )));
804 viewerTrihedronAction->addTo( &myPrefPopup );
805 myStdActions.insert( PrefViewerTrihedronId, viewerTrihedronAction );
807 QActionP* consoleFontAction = new QActionP( "", tr("MEN_DESK_PREF_CONSOLE_FONT"), 0, this );
808 QAD_ASSERT(connect( consoleFontAction, SIGNAL(activated()), this, SLOT(onConsoleFontAction() )));
809 consoleFontAction->addTo( &myPrefPopup );
810 myStdActions.insert( PrefConsoleFontId, consoleFontAction );
813 QActionP* multiFileSaveAction = new QActionP( "", tr("MEN_DESK_PREF_MULTI_FILE_SAVE"), 0, this, 0, true );
814 QAD_ASSERT(connect( multiFileSaveAction, SIGNAL(activated()), this, SLOT(onMultiFileSave() )));
815 multiFileSaveAction->setToggleAction( true );
816 QString MultiSave = QAD_CONFIG->getSetting("Desktop:MultiFileSave");
817 multiFileSaveAction->setOn( MultiSave.compare( aTrueQString ) == 0 );
818 multiFileSaveAction->addTo( &myPrefPopup );
819 myStdActions.insert( PrefMultiFileSave, multiFileSaveAction );
822 QActionP* ASCIISaveAction = new QActionP( "", tr("MEN_DESK_PREF_ASCII_SAVE"), 0, this, 0, true );
823 QAD_ASSERT(connect( ASCIISaveAction, SIGNAL(activated()), this, SLOT(onASCIISave() )));
824 ASCIISaveAction->setToggleAction( true );
825 QString ASCIISave = QAD_CONFIG->getSetting("Desktop:ASCIISave");
826 ASCIISaveAction->setOn( ASCIISave.compare( aTrueQString ) == 0 );
827 ASCIISaveAction->addTo( &myPrefPopup );
828 myStdActions.insert( PrefASCIISave, ASCIISaveAction );
831 QActionP* UndoLevelAction = new QActionP( "", tr("MEN_DESK_PREF_UNDO_LEVEL"), 0, this );
832 QAD_ASSERT(connect( UndoLevelAction, SIGNAL(activated()), this, SLOT(onUndoLevel() )));
833 UndoLevelAction->addTo( &myPrefPopup );
834 myStdActions.insert( PrefUndoLevelId, UndoLevelAction );
836 myPrefPopup.insertSeparator();
838 /* External Browser */
839 QActionP* externalBrowserAction = new QActionP( "", tr("MEN_DESK_PREF_EXTERNAL_BROWSER"), 0, this );
840 QAD_ASSERT(connect( externalBrowserAction, SIGNAL(activated()), this, SLOT(onExternalBrowser() )));
841 externalBrowserAction->addTo( &myPrefPopup );
842 myStdActions.insert( PrefExternalBrowserId, externalBrowserAction );
844 myPrefPopup.insertSeparator();
846 myPrefPopup.insertItem( tr("MEN_DESK_PREF_OBJECTBROWSER"), &myObjBrowserPopup );
848 QActionP* objectBrowserEntryAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_ENTRY"), 0, this, 0, true );
849 QAD_ASSERT(connect( objectBrowserEntryAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
850 objectBrowserEntryAction->setToggleAction(true);
851 QString AddColumn = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn");
853 if ( AddColumn.compare( aTrueQString ) == 0 )
854 objectBrowserEntryAction->setOn(true);
856 objectBrowserEntryAction->setOn(false);
858 objectBrowserEntryAction->addTo( &myObjBrowserPopup );
859 myStdActions.insert( PrefObjectBrowserEntryId, objectBrowserEntryAction );
861 QActionP* objectBrowserValueAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_VALUE"), 0, this, 0, true );
862 QAD_ASSERT(connect( objectBrowserValueAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
863 objectBrowserValueAction->setToggleAction(true);
864 QString ValueColumn = QAD_CONFIG->getSetting("ObjectBrowser:ValueColumn");
866 if ( ValueColumn.compare( aTrueQString ) == 0 )
867 objectBrowserValueAction->setOn(true);
869 objectBrowserValueAction->setOn(false);
871 objectBrowserValueAction->addTo( &myObjBrowserPopup );
872 myStdActions.insert( PrefObjectBrowserValueId, objectBrowserValueAction );
874 QActionP* objectBrowserIAPPAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_IAPP"), 0, this, 0, true );
875 QAD_ASSERT(connect( objectBrowserIAPPAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
876 objectBrowserIAPPAction->setToggleAction(true);
877 QString showIAPP = QAD_CONFIG->getSetting("ObjectBrowser:IAPP");
879 if ( showIAPP.compare( aTrueQString ) == 0 )
880 objectBrowserIAPPAction->setOn(true);
882 objectBrowserIAPPAction->setOn(false);
884 objectBrowserIAPPAction->addTo( &myObjBrowserPopup );
885 myStdActions.insert( PrefObjectBrowserIAPPId, objectBrowserIAPPAction );
887 /* Chronological sorting of shapes on the entry creation */
888 QActionP* objectBrowserCHRONO_SORTAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_CHRONO_SORT"), 0, this, 0, true );
889 QAD_ASSERT(connect( objectBrowserCHRONO_SORTAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
890 objectBrowserCHRONO_SORTAction->setToggleAction(true);
891 QString showSORT = QAD_CONFIG->getSetting("ObjectBrowser:ChronologicalSort");
893 if ( showSORT.compare( aTrueQString ) == 0 )
894 objectBrowserCHRONO_SORTAction->setOn(true) ;
896 objectBrowserCHRONO_SORTAction->setOn(false) ;
898 objectBrowserCHRONO_SORTAction->addTo( &myObjBrowserPopup );
899 myStdActions.insert( PrefObjectBrowserCHRONO_SORTId, objectBrowserCHRONO_SORTAction ) ;
901 /* Show or don't Show UseCase browser */
902 QActionP* objectBrowserShowUseCaseAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_SHOW_USECASE"), 0, this, 0, true );
903 QAD_ASSERT(connect( objectBrowserShowUseCaseAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
904 objectBrowserShowUseCaseAction->setToggleAction(true);
905 QString showUseCase = QAD_CONFIG->getSetting("ObjectBrowser:ShowUseCaseBrowser");
907 if ( showUseCase.compare( aTrueQString ) == 0 )
908 objectBrowserShowUseCaseAction->setOn(true) ;
910 objectBrowserShowUseCaseAction->setOn(false) ;
912 objectBrowserShowUseCaseAction->addTo( &myObjBrowserPopup );
913 myStdActions.insert( PrefObjectBrowserShowUseCaseId, objectBrowserShowUseCaseAction ) ;
915 /* Resize or don't resize columns automatically */
916 QActionP* objectBrowserNoAutoSizeAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_NO_AUTOSIZE"), 0, this, 0, true );
917 QAD_ASSERT(connect( objectBrowserNoAutoSizeAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
918 objectBrowserNoAutoSizeAction->setToggleAction(true);
919 QString noAutoSize = QAD_CONFIG->getSetting("ObjectBrowser:NoAutoSizeColumns");
921 if ( noAutoSize.compare( aTrueQString ) == 0 )
922 objectBrowserNoAutoSizeAction->setOn(true) ;
924 objectBrowserNoAutoSizeAction->setOn(false) ;
926 objectBrowserNoAutoSizeAction->addTo( &myObjBrowserPopup );
927 myStdActions.insert( PrefObjectBrowserNoAutoSizeColumnsId, objectBrowserNoAutoSizeAction ) ;
929 myPrefPopup.insertSeparator();
931 QActionP* dirAction = new QActionP( "", tr("MEN_DESK_PREF_DIRICTORIES"), ALT+Key_D, this );
932 QAD_ASSERT(connect( dirAction, SIGNAL(activated()), this, SLOT(onDirList() )));
933 dirAction->addTo( &myPrefPopup );
934 myStdActions.insert( PrefDirsId, dirAction );
936 myPrefPopup.insertSeparator();
938 QActionP* saveAction = new QActionP( "", tr("MEN_DESK_PREF_SAVE"), 0, this );
939 QAD_ASSERT(connect( saveAction, SIGNAL(activated()), this, SLOT(onSavePref() )));
940 saveAction->addTo( &myPrefPopup );
941 myStdActions.insert( PrefSaveId, saveAction );
943 /* 'Window' actions */
946 myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId );
948 QActionP* viewOCCAction = new QActionP( "", tr("MEN_DESK_VIEW_OCC"), ALT+Key_O, this );
949 QAD_ASSERT(connect( viewOCCAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
950 viewOCCAction->addTo( &myNewViewPopup );
951 myStdActions.insert( ViewOCCId, viewOCCAction );
953 QActionP* viewVTKAction = new QActionP( "", tr("MEN_DESK_VIEW_VTK"), ALT+Key_K, this );
954 QAD_ASSERT(connect( viewVTKAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
955 viewVTKAction->addTo( &myNewViewPopup );
956 myStdActions.insert( ViewVTKId, viewVTKAction );
958 QActionP* viewPlot2dAction = new QActionP( "", tr("MEN_DESK_VIEW_PLOT2D"), ALT+Key_P, this );
959 QAD_ASSERT(connect( viewPlot2dAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
960 viewPlot2dAction->addTo( &myNewViewPopup );
961 myStdActions.insert( ViewPlot2dId, viewPlot2dAction );
963 // QActionP* windowNew3dAction = new QActionP( "",/* rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_NEW3D") ), */
964 /*tr("MEN_DESK_WINDOW_NEW3D"), 0, this );
965 windowNew3dAction->addTo( &myWindowPopup );
966 QAD_ASSERT( connect( windowNew3dAction, SIGNAL(activated()), this ,
967 SLOT( onNewWindow3d() )));
968 myStdActions.insert( WindowNew3dId, windowNew3dAction );
974 QActionP* windowCascadeAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_CASCADE") ),
975 tr("MEN_DESK_WINDOW_CASCADE"), 0, this );
976 windowCascadeAction->setStatusTip ( tr("PRP_DESK_WINDOW_CASCADE") );
977 QAD_ASSERT( connect( windowCascadeAction, SIGNAL(activated()), this,
978 SLOT( onCascade() )));
979 myStdActions.insert( WindowCascadeId, windowCascadeAction );
982 QActionP* windowTileAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_TILE") ),
983 tr("MEN_DESK_WINDOW_TILE"), 0, this );
984 windowTileAction->setStatusTip ( tr("PRP_DESK_WINDOW_TILE") );
985 QAD_ASSERT( connect( windowTileAction, SIGNAL(activated()), myWorkspace, SLOT( tile() )));
986 myStdActions.insert( WindowTileId, windowTileAction );
988 QAD_ASSERT( connect ( &myWindowPopup, SIGNAL(aboutToShow()),
989 this, SLOT(onWindowPopupAboutToShow()) ));
994 // QActionP* helpContentsAction = new QActionP( "", tr("MEN_DESK_HELP_CONTENTS"), Key_F1, this );
995 // helpContentsAction->setStatusTip ( tr("PRP_DESK_HELP_CONTENTS") );
996 // QAD_ASSERT(connect( helpContentsAction, SIGNAL(activated()),
997 // this, SLOT( onHelpContents() )));
998 // helpContentsAction->addTo( &myHelpPopup );
999 // myStdActions.insert( HelpContentsId , helpContentsAction );
1001 // id = myHelpPopup.insertSeparator();
1004 myHelpPopup.insertItem( tr("MEN_DESK_HELP_MODULECONTENTS"), &myHelpContentsModulePopup, HelpContentsModuleId);
1005 bool toEnable = false;
1007 CORBA::Object_var objVarN = myNameService->Resolve("/Kernel/ModulCatalog");
1008 myCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
1010 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants =
1011 myCatalogue->GetComponentIconeList();
1013 for (unsigned int ind = 0; ind < list_composants->length(); ind++) {
1014 QString aModuleName = CORBA::string_dup(list_composants[ind].modulename) ;
1016 if (dir = getenv( aModuleName + "_ROOT_DIR")) {
1017 dir = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc/salome/" );
1018 QString aFileName = aModuleName + "_index.html";
1019 if ( QFileInfo( dir + aFileName ).exists() ) {
1020 QString aModuleUserName = CORBA::string_dup(list_composants[ind].moduleusername) ;
1021 if ( aModuleUserName == "Salome" ) aModuleUserName = "Kernel" ;
1022 QActionP* moduleHelpAction = new QActionP( "", aModuleUserName + " Help" , 0, this, aModuleName);
1023 QAD_ASSERT(connect( moduleHelpAction, SIGNAL(activated()), this, SLOT(onHelpContentsModule() )));
1024 moduleHelpAction->addTo( &myHelpContentsModulePopup );
1025 if (!toEnable) toEnable = true;
1030 myHelpContentsModulePopup.setEnabled(toEnable);
1032 // NRI : Temporary commented
1034 // QActionP* helpContentsActionGUI = new QActionP( "", tr("MEN_DESK_HELP_GUICONTENTS"), 0, this );
1035 // helpContentsActionGUI->setStatusTip ( tr("PRP_DESK_HELP_GUICONTENTS") );
1036 // QAD_ASSERT(connect( helpContentsActionGUI, SIGNAL(activated()),
1037 // this, SLOT( onHelpContentsGUI() )));
1038 // helpContentsActionGUI->addTo( &myHelpPopup );
1039 // myStdActions.insert( HelpContentsId , helpContentsActionGUI );
1044 QActionP* helpContentsActionTUI = new QActionP( "", tr("MEN_DESK_HELP_TUICONTENTS"), 0, this );
1045 helpContentsActionTUI->setStatusTip ( tr("PRP_DESK_HELP_TUICONTENTS") );
1046 QAD_ASSERT(connect( helpContentsActionTUI, SIGNAL(activated()),
1047 this, SLOT( onHelpContentsTUI() )));
1048 helpContentsActionTUI->addTo( &myHelpPopup );
1049 myStdActions.insert( HelpContentsId , helpContentsActionTUI );
1053 // Provide status tip for Module help menu item
1054 QAD_ASSERT( connect( &myHelpPopup, SIGNAL(highlighted( int )), this,
1055 SLOT(onHelpModulePopupStatusText( int )) ));
1059 // QActionP* helpSearchAction = new QActionP( "", tr("MEN_DESK_HELP_SEARCH"), 0, this );
1060 // helpSearchAction->setStatusTip ( tr("PRP_DESK_HELP_SEARCH") );
1061 // QAD_ASSERT( connect( helpSearchAction, SIGNAL(activated()), this, SLOT( onHelpSearch() )));
1062 // helpSearchAction->addTo( &myHelpPopup );
1063 // myStdActions.insert( HelpSearchId, helpSearchAction );
1066 // QActionP* helpWhatsThisAction = new QActionP( "", tr("MEN_DESK_HELP_WHATSTHIS"), SHIFT+Key_F1, this );
1067 // helpWhatsThisAction->setStatusTip ( tr("PRP_DESK_HELP_WHATSTHIS" ));
1068 // QAD_ASSERT( connect( helpWhatsThisAction, SIGNAL(activated()), this, SLOT( whatsThis() )));
1069 // helpWhatsThisAction->addTo( &myHelpPopup );
1070 // myStdActions.insert( HelpWhatsThisId, helpWhatsThisAction );
1071 // (void)QWhatsThis::whatsThisButton( myStdToolBar );
1073 id = myHelpPopup.insertSeparator();
1074 myHelpPos = myHelpPopup.indexOf( id );
1077 QActionP* helpAboutAction = new QActionP( "", tr("MEN_DESK_HELP_ABOUT"), 0, this );
1078 helpAboutAction->setStatusTip ( tr("PRP_DESK_HELP_ABOUT") );
1079 QAD_ASSERT( connect( helpAboutAction, SIGNAL(activated()), this, SLOT( onHelpAbout() )));
1080 helpAboutAction->addTo( &myHelpPopup );
1081 myStdActions.insert(HelpAboutId, helpAboutAction );
1083 /* additional key accelerators */
1084 QAccel* accel = new QAccel( this );
1086 myAccelMap[ accel->insertItem( CTRL+Key_Left ) ] = voPanLeft;
1088 myAccelMap[ accel->insertItem( CTRL+Key_Right ) ] = voPanRight;
1090 myAccelMap[ accel->insertItem( CTRL+Key_Up ) ] = voPanUp;
1092 myAccelMap[ accel->insertItem( CTRL+Key_Down ) ] = voPanDown;
1094 myAccelMap[ accel->insertItem( CTRL+Key_Plus ) ] = voZoomIn;
1096 myAccelMap[ accel->insertItem( CTRL+Key_Minus ) ] = voZoomOut;
1098 myAccelMap[ accel->insertItem( CTRL+Key_Equal ) ] = voZoomIn;
1100 myAccelMap[ accel->insertItem( CTRL+Key_Asterisk ) ] = voZoomFit;
1102 myAccelMap[ accel->insertItem( CTRL+SHIFT+Key_Asterisk ) ] = voZoomFit;
1104 myAccelMap[ accel->insertItem( ALT+Key_Left ) ] = voRotateLeft;
1106 myAccelMap[ accel->insertItem( ALT+Key_Right ) ] = voRotateRight;
1108 myAccelMap[ accel->insertItem( ALT+Key_Up ) ] = voRotateUp;
1110 myAccelMap[ accel->insertItem( ALT+Key_Down ) ] = voRotateDown;
1111 // connect signal to slot
1112 connect( accel, SIGNAL( activated(int) ), this, SLOT( onKeyAccel(int) ) );
1118 Adds the given application into the list of supported applications
1120 void QAD_Desktop::addApplication(QAD_Application* app)
1122 /* add only if is not already in the list */
1123 if ( myApps.findRef( app ) == -1 )
1125 myApps.append( app );
1127 /* set activation/deactivation listener */
1128 QAD_ASSERT ( connect( app, SIGNAL(appActivated(QAD_Application*)),
1129 this, SLOT(onActivateApp(QAD_Application*))) );
1131 QAD_ASSERT ( connect( app, SIGNAL(appDeactivated(QAD_Application*)),
1132 this, SLOT(onDeactivateApp(QAD_Application*))) );
1137 Displays the control panel of the application.
1138 This function is called when the desktop is shown first time.
1140 void QAD_Desktop::showDesktop()
1146 Closes Desktop. If <forceClose> is true query for exit will be skipped.
1148 void QAD_Desktop::closeDesktop( bool forceClose )
1151 myQueryClose = false;
1156 Puts the message to the status bar
1158 void QAD_Desktop::putInfo ( const QString& msg )
1161 //NRI : bug 1209. message is now displayed during 3000 ms
1162 myStatusBar->message ( msg, 3000 );
1166 Puts the message to the status bar for ms milli-seconds
1168 void QAD_Desktop::putInfo ( const QString& msg, int ms )
1171 myStatusBar->message ( msg, ms );
1175 Returns the standard toolbar
1177 QMenuBar* QAD_Desktop::getMainMenuBar() const
1183 Returns the standard toolbar
1185 QToolBar* QAD_Desktop::getStdToolBar() const
1187 return myStdToolBar;
1191 Updates desktop panel (menu, toolbar and status bar) according to current state of
1192 the application. Calls update() for the active application.
1193 The command { UD_ADD_APP or UD_REMOVE_APP ) specifies the desktop components
1194 will be changed according to new active application.
1195 This function is called after activating new study, closing current study etc.
1197 void QAD_Desktop::updateDesktop( UpdateCommand cmd )
1200 updateToolBars( cmd );
1201 updateStatusBar( cmd );
1206 Updates the desktop caption
1208 void QAD_Desktop::updateCaption( UpdateCommand cmd )
1210 if ( cmd == ActivateApp )
1211 { /* application's icon and title */
1212 setIcon( myActiveApp->getApplicationIcon() );
1213 setCaption( myActiveApp->getApplicationName() );
1216 { /* default icon and title */
1217 setIcon( myDefaultIcon );
1218 qApp->processEvents();
1219 setCaption( myDefaultTitle );
1224 Updates status bar when a new application becomes current
1226 void QAD_Desktop::updateStatusBar( UpdateCommand cmd )
1230 bool activate = ( cmd == ActivateApp );
1231 myActiveApp->updateStatusBar ( myStatusBar, activate );
1236 Updates toolbars according to current active application.
1237 This function is called from updateDesktop().
1239 void QAD_Desktop::updateToolBars( UpdateCommand cmd )
1243 bool activate = ( cmd == ActivateApp );
1244 myActiveApp->updateToolBars ( activate );
1249 Updates main menu bar of the application when application is activated
1251 This function is called by updateDesktop()
1253 void QAD_Desktop::updateMenu( UpdateCommand cmd )
1257 bool activate = ( cmd == ActivateApp );
1258 myActiveApp->updateFilePopup( &myFilePopup, activate, myFilePos );
1259 myActiveApp->updateEditPopup( &myEditPopup, activate, myEditPos );
1260 myActiveApp->updateViewPopup( &myViewPopup, activate, myViewPos );
1261 myActiveApp->updateHelpPopup( &myHelpPopup, activate, myHelpPos );
1262 myActiveApp->updateMainMenu( myMainMenu, activate, myMainMenuPos );
1265 Since 'Edit' popup is completely customized by applications
1266 desktop doesn't show it in main menubar without the active
1267 application and we insert/remove this popup from the menubar
1268 when activating/deactivating applications.
1270 We can't have 'Edit' popup be customized by an application
1271 via UpdateMainMenu() method because applications may insert
1272 its items to the menubar only AFTER 'View' item ( this fact
1273 is respected by myMainMenuPos ) and the possibility of an
1274 application to add its items into any arbitrary positions of
1275 the main menubar requires a bit sophisticated implementation,
1276 so we decided to avoid it, sorry :-(.
1278 #if defined( DEBUG )
1280 /* applications MUST clear 'Edit' after themselves */
1281 QAD_ASSERT_DEBUG_ONLY( !myEditPopup.count() );
1284 if ( activate ) /* insert after 'File' item */
1285 myMainMenu->insertItem( tr("MEN_DESK_EDIT"), &myEditPopup, 3, 1 );
1287 myMainMenu->removeItem( 3 );
1292 Returns icon file name used by the application
1294 const QPixmap& QAD_Desktop::getDefaultIcon() const
1296 static QPixmap defaultPixmap( QAD_Desktop::getResourceManager()->loadPixmap( "QAD",
1297 tr("ICON_DESK_DEFAULTICON") ));
1298 return defaultPixmap;
1302 Returns name of the application used as the title of desktop panel
1304 const QString& QAD_Desktop::getDefaultTitle() const
1306 static QString defaultTitle ( tr("DESK_DEFAULTTITLE") );
1307 return defaultTitle;
1311 Returns default name of new studies
1313 const QString& QAD_Desktop::getDefaultStudyName() const
1315 static QString defaultStudyName( tr("DESK_DEFAULTDOC") );
1316 return defaultStudyName;
1320 Returns next name for new study
1322 QString QAD_Desktop::getNewStudyName()
1325 number.sprintf( "%d", ++myCntUntitled );
1326 return ( getDefaultStudyName() + number );
1330 Searches QAD_Study corresponding to <study>, returns NULL if fails
1332 QAD_Study* QAD_Desktop::findStudy( SALOMEDS::Study_ptr theStudy )
1334 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1335 QList<QAD_Study> studies;
1336 studies.setAutoDelete( false );
1337 studies = app->getStudies();
1338 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
1339 if ( study->getStudyDocument()->_is_equivalent( theStudy ) )
1347 Gets value of max undo level for SALOMEDS::Study's from preferences
1349 int QAD_Desktop::getUndoLevel()
1351 static int MAX_UNDO = 10;
1352 int anUndoLevel = MAX_UNDO;
1353 QString aLevel = QAD_CONFIG->getSetting("Desktop:UndoLevel");
1354 if(!aLevel.isEmpty()) anUndoLevel = aLevel.toInt();
1359 Returns current active application
1361 QAD_Application* QAD_Desktop::getActiveApp() const
1367 Returns current active study
1369 QAD_Study* QAD_Desktop::getActiveStudy() const
1371 return myActiveStudy;
1377 QWorkspaceP* QAD_Desktop::getMainFrame() const
1383 Find or load Engine, given a container name and an engine name
1385 Engines::Component_var QAD_Desktop::getEngine(const char *containerName,
1386 const char *componentName)
1388 Engines::Component_var eng =
1389 myEnginesLifeCycle->FindOrLoad_Component(containerName,
1394 QString QAD_Desktop::getComponentName(const char *componentUserName)
1396 if ( mapComponentName.contains(componentUserName) )
1397 return mapComponentName[ componentUserName ] ;
1402 QString QAD_Desktop::getComponentUserName(const char *componentName)
1404 QMap<QString,QString>::Iterator it;
1405 for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it )
1406 if (it.data() == componentName )
1412 // gets application Help Window (and creates if necessary)
1414 // QAD_HelpWindow* QAD_Desktop::getHelpWindow()
1416 // if (!myHelpWindow) {
1417 // myHelpWindow = new QAD_HelpWindow();
1419 // QMap<QString,QString>::Iterator it;
1420 // for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it ) {
1424 // // look for index.html and set homeDir
1425 // // 1. $(MODULE_ROOT_DIR)/doc/index.html
1426 // // 2. $(MODULE_ROOT_DIR)/doc/html/index.html
1427 // // 3. $(MODULE_ROOT_DIR)/doc/html/html/index.html
1429 // if (dir = getenv( QString( it.data() + "_ROOT_DIR")) ) {
1430 // root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" );
1431 // if ( QFileInfo( root + "index.html" ).exists() ) {
1432 // helpContext( root + "index.html", "" );
1435 // root = QAD_Tools::addSlash( root + "html" );
1436 // if ( QFileInfo( root + "index.html" ).exists() ) {
1437 // helpContext( root + "index.html", "" );
1440 // root = QAD_Tools::addSlash( root + "html" );
1441 // if ( QFileInfo( root + "index.html" ).exists() ) {
1442 // helpContext( root + "index.html", "" );
1449 // connect(myHelpWindow, SIGNAL(helpWindowClosed()), this, SLOT(onHelpWindowClosed()));
1451 // return myHelpWindow;
1455 Called when desktop is closing
1457 void QAD_Desktop::closeEvent ( QCloseEvent* e )
1459 bool doClose = true;
1460 if ( myQueryClose ) {
1461 doClose = QAD_MessageBox::info2 ( this, tr("INF_DESK_EXIT"),
1462 tr("QUE_DESK_EXIT"), tr ("BUT_OK"),
1463 tr ("BUT_CANCEL"), QAD_YES,
1464 QAD_NO, QAD_NO ) == QAD_YES;
1467 for ( QAD_Application* app = myApps.first(); doClose && app; app = myApps.next() ) {
1468 QList<QAD_Study>& studies = app->getStudies();
1469 for(QAD_Study* study = studies.first(); doClose && study != 0; study = studies.next()) {
1470 if(myQueryClose && study->getStudyDocument()->IsModified()) {
1471 SALOMEGUI_CloseDlg aDlg( this );
1472 switch ( aDlg.exec() ) {
1474 if ( !onSaveStudy( study ) ) {
1475 putInfo( tr("INF_CANCELLED") );
1485 putInfo( tr("INF_CANCELLED") );
1493 myQueryClose = true;
1496 myAboutToClose = false;
1497 // onActiveStudyChanged() is normally caused by QWorkspace::eventFilter(),
1498 // but this call was blocked by myAboutToClose == true, so now we should do it manually
1499 onActiveStudyChanged();
1508 Called when desktop is resized
1510 void QAD_Desktop::resizeEvent( QResizeEvent* e )
1512 QMainWindow::resizeEvent( e );
1513 myWorkspace->setGeometry( 1,1, centralWidget()->width()-2,
1514 centralWidget()->height()-2 );
1519 Terminates the application.
1521 void QAD_Desktop::onExit()
1526 /************************************************************************
1528 *************************************************************************/
1532 If several application are supported it displays dialog window
1533 to choose type of study.
1535 void QAD_Desktop::createStudy(){
1538 void QAD_Desktop::onNewStudy()
1540 unsigned numApps = myApps.count();
1543 onNewStudy ( myApps.at(0) );
1544 else { /* select the type of application for new study */
1545 Desktop_AppSelectionDlg selDlg( this, myApps );
1546 if ( selDlg.exec() == QDialog::Accepted ) {
1547 onNewStudy ( selDlg.selectedApp() );
1550 } else { /* no applications available in desktop */
1551 QAD_MessageBox::error1( this,
1553 tr("ERR_APP_NOAPP"),
1559 Creates new study for the given application.
1560 Calls the respective function of the application class.
1562 void QAD_Desktop::onNewStudy( QAD_Application* app )
1566 /* create new study of the specific app */
1567 putInfo ( tr ("INF_DOC_CREATING") );
1568 QAD_Study* newStudy = app->newStudy();
1571 /* can't create new study */
1572 QAD_MessageBox::error1( this, tr("ERR_ERROR"),
1573 tr("ERR_DOC_CANTCREATE"),
1576 putInfo ( tr("INF_READY") );
1580 Loads the existing study.
1582 void QAD_Desktop::onLoadStudy()
1584 QString name, studyname, ext;
1586 SALOMEGUI_LoadStudiesDlg* aDlg = new SALOMEGUI_LoadStudiesDlg( this, "Load Study", TRUE);
1588 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1589 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1590 ASSERT(! CORBA::is_nil(myStudyMgr));
1591 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1592 for (unsigned int ind = 0; ind < List->length();ind++) {
1593 studyname = List[ind];
1594 aDlg->ListComponent->insertItem( studyname );
1597 int retVal = aDlg->exec();
1598 studyname = aDlg->ListComponent->currentText();
1600 if (retVal == QDialog::Rejected)
1603 if ( studyname.isNull() || studyname.isEmpty() )
1607 name.replace( QRegExp(":"), "/" );
1610 Try to associate an application to the opened study.
1611 Assumed that the association study<->application is unique.
1613 bool appFound = false;
1614 putInfo ( tr("INF_DOC_OPENING") + " " + name );
1615 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
1617 /* application found */
1618 if ( app->isStudyOpened( name ) )
1620 /* already opened: prompt for reopen */
1621 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1622 tr("QUE_DOC_ALREADYOPEN").arg( name ),
1623 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1624 QAD_NO ) == QAD_NO )
1626 putInfo ( tr("INF_READY") );
1629 /* now the study is closed to be re-opened */
1630 //don't ask user to remove study permanently
1631 if (app->getStudyByName ( name ) != NULL)
1632 onCloseStudy ( app->getStudyByName ( name ), false );
1633 else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )) != NULL)
1634 onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )), false );
1638 /* open the study */
1639 QAD_Study* openStudy = app->loadStudy( studyname );
1641 QAD_MessageBox::error1( this,
1643 tr("ERR_DOC_CANTOPEN") + "\n" + name,
1650 QAD_MessageBox::error1( this,
1652 tr("ERR_DOC_UNKNOWNTYPE"),
1655 putInfo ( tr("INF_READY") );
1660 QAD_Study* QAD_Desktop::loadStudy(QString theStudyName) {
1661 QString studyname("");
1663 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1664 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1665 ASSERT(! CORBA::is_nil(myStudyMgr));
1667 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1668 for (unsigned int ind = 0; ind < List->length();ind++) {
1669 if (theStudyName == QString(List[ind])) {
1670 studyname = theStudyName;
1674 if (studyname == "") {
1677 bool appFound = false;
1678 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1680 QAD_Study* openStudy = app->loadStudy( studyname );
1682 // if (myActiveApp == 0)
1683 //myActiveApp = app;
1693 Opens the existing study.
1694 Displays select file dialog and calls corresponding function of
1696 (application is defined according to extension of selected file).
1698 void QAD_Desktop::onOpenStudy()
1702 /* Select a file to open */
1703 name = selectFileName ( true );
1704 if ( name.isNull() || name.isEmpty() )
1707 // Workaround for non-existent files
1709 if (!fi.exists() || !fi.isFile()) {
1710 QAD_MessageBox::error1 ( this, tr("ERR_ERROR"),
1711 tr("ERR_DOC_CANTOPEN") +": " + name,
1716 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1717 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1718 ASSERT(! CORBA::is_nil(myStudyMgr));
1719 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1720 for (unsigned int ind = 0; ind < List->length();ind++) {
1721 QString NameExistingStudy(List[ind]);
1722 QString NameOpeningStudy = QAD_Tools::getFileNameFromPath( name, true );
1723 if ( NameExistingStudy.compare( NameOpeningStudy ) == 0 ) {
1724 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1725 tr("QUE_DOC_ALREADYEXIST").arg( name ),
1726 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1727 QAD_NO ) == QAD_NO )
1729 putInfo ( tr("INF_READY") );
1741 Try to associate an application to the opened study.
1742 Assumed that the association study<->application is unique.
1744 bool appFound = false;
1745 putInfo ( tr("INF_DOC_OPENING") + " " + name );
1746 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
1748 QString ext = QAD_Tools::getFileExtensionFromPath ( name );
1749 if ( app->getStudyExtension() == ext )
1751 /* application found */
1752 if ( app->isStudyOpened( name ) )
1754 /* already opened: prompt for reopen */
1755 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1756 tr("QUE_DOC_ALREADYOPEN").arg( name ),
1757 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1758 QAD_NO ) == QAD_NO )
1760 putInfo ( tr("INF_READY") );
1763 /* now the study is closed to be re-opened */
1764 //don't ask user to remove study permanently
1765 if (app->getStudyByName ( name ) != NULL)
1766 onCloseStudy ( app->getStudyByName ( name ), false );
1767 else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )) != NULL)
1768 onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, true )), false );
1772 /* open the study */
1773 QAD_Study* openStudy = app->openStudy( name );
1775 QAD_MessageBox::error1( this,
1777 tr("ERR_DOC_CANTOPEN") + "\n" + name,
1786 QAD_MessageBox::error1( this,
1788 tr("ERR_DOC_UNKNOWNTYPE"),
1791 putInfo ( tr("INF_READY") );
1794 bool QAD_Desktop::loadComponentData( const QString& compName )
1798 if ( compName.isEmpty() ) {
1799 MESSAGE("loadComponentData(): empty component name passed!")
1803 // Open component's data in active study if any
1804 MESSAGE("loadComponentData(): Opening " << compName << " component data ")
1805 if (!myActiveStudy) {
1806 MESSAGE("loadComponentData(): No active study exists")
1810 Engines::Component_var comp ;
1811 if ( compName.compare("SUPERV") == 0 ) {
1812 comp = getEngine( "SuperVisionContainer", compName) ;
1815 /* comp = ( compName.compare("Data1") != 0 ) ? getEngine( "FactoryServer", compName) :
1816 getEngine( "FactoryServerPy", compName);
1818 comp = getEngine( "FactoryServer", compName);
1819 if ( comp->_is_nil() )
1820 comp = getEngine( "FactoryServerPy", compName);
1823 if ( CORBA::is_nil( comp ) ) {
1824 MESSAGE("loadComponentData(): Engine is null");
1828 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1829 SALOMEDS::SComponent_var SCO = SALOMEDS::SComponent::_narrow(aStudy->FindObject( getComponentUserName(compName) ));
1831 if (!SCO->_is_nil()) {
1832 SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
1833 if (!CORBA::is_nil(driver)) {
1834 SALOMEDS::StudyBuilder_var B = aStudy->NewBuilder();
1835 if (!CORBA::is_nil(B)) {
1837 B->LoadWith(SCO,driver);
1839 catch( const SALOME::SALOME_Exception& ) {
1840 // Oops, something went wrong while loading -> return an error
1845 MESSAGE("loadComponentData(): Driver is null");
1846 // Incorrect! All components should inherit SALOMEDS::Driver
1850 MESSAGE("loadComponentData(): SComponent is null");
1851 // Don't return false here, for there might be no data
1852 // for a given component in the study yet
1859 Saves the active study
1861 bool QAD_Desktop::onSaveStudy()
1863 return onSaveStudy ( myActiveStudy );
1867 Saves the given study
1869 bool QAD_Desktop::onSaveStudy( QAD_Study* study )
1871 if ( !study ) return true;
1873 if ( !study->isSaved() )
1874 return onSaveAsStudy ( study );
1876 /* saving study... */
1877 QAD_Application* app = study->getApp();
1878 QAD_ASSERT_DEBUG_ONLY ( app );
1879 putInfo ( tr("INF_DOC_SAVING") + study->getTitle() );
1880 if ( !app->saveStudy( study ) )
1882 putInfo( tr("INF_CANCELLED") );
1887 putInfo ( tr("INF_DOC_SAVED").arg( "" ) );
1892 Saves the active study under a new name
1894 bool QAD_Desktop::onSaveAsStudy()
1896 return onSaveAsStudy( myActiveStudy );
1900 Saves the given study under a new name
1902 bool QAD_Desktop::onSaveAsStudy( QAD_Study* study )
1904 if ( !study ) return true;
1906 /* Save study in a format supported by its application
1908 QAD_Application* app = study->getApp();
1909 QAD_ASSERT_DEBUG_ONLY ( app );
1911 /* Select a file where to save
1913 QString name = selectFileName ( false );
1914 if ( name.isNull() || name.isEmpty() )
1916 putInfo( tr("INF_CANCELLED") );
1922 putInfo ( tr("INF_DOC_SAVING") + name );
1923 if ( !app->saveAsStudy( study, name ) ) {
1924 /* can't save the file */
1925 QAD_MessageBox::error1( this,
1927 tr("ERR_DOC_CANTWRITE") + "\n" + name,
1930 return false; /* cannot save */
1932 putInfo ( tr("INF_DOC_SAVED").arg( name ) );
1933 return true; /* saved ok */
1937 Closes the active study
1939 bool QAD_Desktop::onCloseStudy()
1941 bool close = this->onCloseStudy ( getActiveStudy(), true );
1946 Closes the given study and ask user to remove study
1947 from the study manager permanently
1949 bool QAD_Desktop::onCloseStudy( QAD_Study* study )
1951 return onCloseStudy( study, true );
1955 Closes the given study and ask user to remove study
1956 from the study manager permanently if ask is equal true
1958 bool QAD_Desktop::onCloseStudy( QAD_Study* study, bool ask )
1960 bool removePerm = false;
1964 SALOMEGUI_CloseDlg aDlg( this );
1965 int res = aDlg.exec();
1970 //if ( study->isModified() )
1971 if ( !onSaveStudy( study ) ) {
1972 putInfo( tr("INF_CANCELLED") );
1985 putInfo( tr("INF_CANCELLED") );
1989 /* close active component */
1990 if (!myXmlHandler->myIdList.IsEmpty())
1992 deactivateComponent();
1995 myCombo->setCurrentItem (0);
1996 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() )
1997 aButton->setOn(false);
1998 qApp->processEvents();
2000 /* close the study */
2001 return study->getApp()->closeStudy( study, removePerm );
2004 // Displays study properties dialog box
2005 void QAD_Desktop::onStudyProperties()
2007 if (myActiveStudy) {
2009 QAD_Operation* op = new QAD_Operation( myActiveStudy );
2012 SALOMEGUI_StudyPropertiesDlg aDlg(this);
2013 int res = aDlg.exec();
2015 if ( res == QDialog::Accepted && aDlg.isChanged() )
2020 // T2.12 - add the word "locked" to study frame captions if <myActiveStudy> study is locked
2021 myActiveStudy->updateCaptions();
2027 locate all windows in cascade mode
2030 void QAD_Desktop::onCascade()
2032 myWorkspace->cascade();
2033 int w = myWorkspace->width();
2034 int h = myWorkspace->height();
2035 QWidgetList wList = myWorkspace->windowList();
2036 QWidgetListIt it(wList);
2038 for(;it.current(); ++it)
2039 it.current()->resize((int)(0.8*w), (int)(0.8*h));
2043 // called when help window closed
2045 // void QAD_Desktop::onHelpWindowClosed()
2047 // myHelpWindow = 0;
2051 Called when 'view status bar' option
2054 void QAD_Desktop::onViewStatusBar()
2056 bool show = myStdActions.at( ViewStatusBarId )->isOn();
2057 if ( show == myStatusBar->isVisible() )
2060 myStatusBar->show();
2062 myStatusBar->hide();
2066 Called when View/Toolbars popup menu is about to show
2068 void QAD_Desktop::onToolBarPopupAboutToShow()
2070 myToolBarAction.clear();
2071 myToolBarsPopup.clear();
2072 QPtrList<QDockWindow> wlist = dockWindows();
2073 for ( QDockWindow* w = wlist.first(); w; w = wlist.next() ) {
2074 if ( w->inherits( "QToolBar" ) ) {
2075 QToolBar* tb = ( QToolBar* )w;
2076 if ( appropriate( tb ) ) {
2077 ToggleAction* a = new ToggleAction( tb->label(), tb->label(), 0, this, 0, true );
2078 a->setStatusTip ( tr("PRP_DESK_VIEW_TOOLBAR") );
2079 a->setOn( tb->isVisible() );
2080 QAD_ASSERT( connect( a, SIGNAL( toggledOn() ), tb, SLOT( show() ) ) );
2081 QAD_ASSERT( connect( a, SIGNAL( toggledOff() ), tb, SLOT( hide() ) ) );
2082 a->addTo( &myToolBarsPopup );
2083 myToolBarAction.append( a );
2090 Called on 'View\Selection Mode'
2092 void QAD_Desktop::onSelectionMode()
2094 const QActionP* obj = (QActionP*) sender();
2096 Selection_Mode SelectionMode = ActorSelection;
2098 if ( obj == myStdActions.at(SelectionActorId) ) {
2099 SelectionMode = ActorSelection;
2100 if ( obj->isOn() ) {
2101 myStdActions.at(SelectionCellId)->setOn(false);
2102 myStdActions.at(SelectionEdgeId)->setOn(false);
2103 myStdActions.at(SelectionPointId)->setOn(false);
2105 myStdActions.at(SelectionActorId)->setOn(true);
2107 } else if ( obj == myStdActions.at(SelectionCellId) ) {
2108 SelectionMode = CellSelection;
2109 if ( obj->isOn() ) {
2110 myStdActions.at(SelectionActorId)->setOn(false);
2111 myStdActions.at(SelectionEdgeId)->setOn(false);
2112 myStdActions.at(SelectionPointId)->setOn(false);
2114 myStdActions.at(SelectionActorId)->setOn(true);
2116 } else if ( obj == myStdActions.at(SelectionEdgeId) ) {
2117 SelectionMode = EdgeOfCellSelection;
2118 if ( obj->isOn() ) {
2119 myStdActions.at(SelectionActorId)->setOn(false);
2120 myStdActions.at(SelectionCellId)->setOn(false);
2121 myStdActions.at(SelectionPointId)->setOn(false);
2123 myStdActions.at(SelectionActorId)->setOn(true);
2125 } else if ( obj == myStdActions.at(SelectionPointId) ) {
2126 SelectionMode = NodeSelection;
2127 if ( obj->isOn() ) {
2128 myStdActions.at(SelectionEdgeId)->setOn(false);
2129 myStdActions.at(SelectionCellId)->setOn(false);
2130 myStdActions.at(SelectionActorId)->setOn(false);
2132 myStdActions.at(SelectionActorId)->setOn(true);
2135 QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame();
2136 sf->getRightFrame()->getViewFrame()->SetSelectionMode( SelectionMode );
2138 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() );
2139 Sel->SetSelectionMode( SelectionMode );
2143 Called on 'View\Selection Mode'
2145 void QAD_Desktop::SetSelectionMode(Selection_Mode mode, bool activeCompOnly)
2150 myStdActions.at(SelectionEdgeId)->setOn(false);
2151 myStdActions.at(SelectionCellId)->setOn(false);
2152 myStdActions.at(SelectionActorId)->setOn(false);
2153 myStdActions.at(SelectionPointId)->setOn(true);
2156 case EdgeOfCellSelection:
2158 myStdActions.at(SelectionActorId)->setOn(false);
2159 myStdActions.at(SelectionCellId)->setOn(false);
2160 myStdActions.at(SelectionPointId)->setOn(false);
2161 myStdActions.at(SelectionEdgeId)->setOn(true);
2167 case VolumeSelection:
2169 myStdActions.at(SelectionActorId)->setOn(false);
2170 myStdActions.at(SelectionEdgeId)->setOn(false);
2171 myStdActions.at(SelectionPointId)->setOn(false);
2172 myStdActions.at(SelectionCellId)->setOn(true);
2175 case ActorSelection:
2177 myStdActions.at(SelectionCellId)->setOn(false);
2178 myStdActions.at(SelectionEdgeId)->setOn(false);
2179 myStdActions.at(SelectionPointId)->setOn(false);
2180 myStdActions.at(SelectionActorId)->setOn(true);
2185 QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame();
2186 if ( sf->getTypeView() == VIEW_VTK ) {
2187 sf->getRightFrame()->getViewFrame()->SetSelectionMode( mode );
2188 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() );
2189 Sel->SetSelectionMode( mode, activeCompOnly );
2195 Called on 'Window\NewWindow3d'
2197 void QAD_Desktop::onNewWindow3d()
2201 //VRV: T2.5 - add default viewer
2202 QApplication::restoreOverrideCursor();
2203 SALOMEGUI_ViewChoiceDlg *choice = new SALOMEGUI_ViewChoiceDlg(this, "", TRUE);
2204 int r = choice->exec();
2207 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(choice->getSelectedViewer()));
2209 //VRV: T2.5 - add default viewer
2211 const QActionP* obj = (QActionP*) sender();
2212 if ( obj == myStdActions.at(ViewOCCId) ) {
2213 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(0));
2214 } else if ( obj == myStdActions.at(ViewVTKId) ) {
2215 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(1));
2216 } else if ( obj == myStdActions.at(ViewPlot2dId) ) {
2217 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(3));
2222 // Helps to execute command
2223 class RunBrowser: public QThread {
2226 RunBrowser(QString theApp, QString theParams, QString theHelpFile, QString theContext=NULL):
2227 myApp(theApp), myParams(theParams), myHelpFile("file:" + theHelpFile + theContext), myStatus(0) {};
2233 if ( !myApp.isEmpty())
2235 aCommand.sprintf("%s %s %s",myApp.latin1(),myParams.latin1(),myHelpFile.latin1());
2236 myStatus = system(aCommand);
2239 QCustomEvent* ce2000 = new QCustomEvent (2000);
2240 postEvent (qApp, ce2000);
2244 if( myStatus != 0 || myApp.isEmpty())
2247 aCommand.sprintf("%s %s %s", QString(DEFAULT_BROWSER).latin1(),myParams.latin1(), myHelpFile.latin1());
2248 myStatus = system(aCommand);
2251 QCustomEvent* ce2001 = new QCustomEvent (2001);
2252 postEvent (qApp, ce2001);
2265 // Provide status tip for GUI help menu item
2267 void QAD_Desktop::onHelpModulePopupStatusText(int id)
2269 int Id = myHelpPopup.idAt( 0 ); // HelpContentsModuleId
2270 // MESSAGE ( "myHelpContentsModulePopup : " << id << "-" << Id)
2272 putInfo("Shows the help contents of each module");
2276 Called on 'help\contents'
2278 void QAD_Desktop::onHelpContents()
2279 { if (myActiveComp == "")
2280 myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
2285 if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
2286 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + QAD_Tools::addSlash("doc") + "html" );
2287 if ( QFileInfo( root + "index.html" ).exists() ) {
2290 QMessageBox::warning( this, tr("WRN_WARNING"),
2291 QString( "%1index.html doesn't exist." ).arg(root), tr ("BUT_OK") );
2296 QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath();
2297 QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2298 QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2300 RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2305 Called on 'Module Help Reference'
2307 void QAD_Desktop::onHelpContentsModule()
2309 const QActionP* obj = (QActionP*) sender();
2311 QString aComponentName = obj->name();
2312 QString aFileName = aComponentName + "_index.html";
2317 if (dir = getenv( aComponentName + "_ROOT_DIR")) {
2318 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("doc") + QAD_Tools::addSlash("salome") );
2319 if ( QFileInfo( root + aFileName ).exists() ) {
2322 QMessageBox::warning( this, tr("WRN_WARNING"),
2323 QString( "%1"+ aFileName + " doesn't exist." ).arg(root), tr ("BUT_OK") );
2328 QString helpFile = QFileInfo( homeDir + aFileName ).absFilePath();
2329 QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2330 QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2332 RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2337 Called on 'help\TUI Reference'
2341 void QAD_Desktop::onHelpContentsTUI()
2343 if (myActiveComp == "")
2344 myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
2349 if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
2350 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("doc") + "html" );
2351 if ( QFileInfo( root + "index.html" ).exists() ) {
2353 } else if (QFileInfo( root + "html/index.html" ).exists())
2354 homeDir = root + QAD_Tools::addSlash("html");
2356 QMessageBox::warning( this, tr("WRN_WARNING"),
2357 QString( "%1index.html doesn't exist." ).arg(root), tr ("BUT_OK") );
2362 QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath();
2364 QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2365 QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2367 RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2374 // Called on 'help\search'
2376 // void QAD_Desktop::onHelpSearch()
2379 // myActiveApp->helpSearch();
2385 Called on 'help\about'
2387 void QAD_Desktop::onHelpAbout()
2390 myActiveApp->helpAbout();
2397 Activates the application and its active study
2399 void QAD_Desktop::onActivateApp( QAD_Application* activeApp )
2401 bool appChanged = ( activeApp != myActiveApp );
2404 updateDesktop( DeactivateApp );
2408 myActiveApp = activeApp;
2409 myActiveStudy = myActiveApp->getActiveStudy();
2419 updateDesktop( ActivateApp );
2420 updateCaption( (activeApp != NULL) ? ActivateApp : DeactivateApp );
2426 Called when the last study is removed from
2427 the application 'app'.
2429 void QAD_Desktop::onDeactivateApp(QAD_Application* app)
2431 if ( app && app == myActiveApp )
2436 Enables/disables standard actions
2438 void QAD_Desktop::updateActions()
2440 myStdActions.at( FileCloseId )->setEnabled ( myActiveStudy != NULL );
2441 myStdActions.at( FileSaveId )->setEnabled ( myActiveStudy != NULL );
2442 myStdActions.at( FileSaveAsId )->setEnabled ( myActiveStudy != NULL );
2443 myStdActions.at( FilePropsId )->setEnabled( myActiveStudy != NULL );
2444 // myStdActions.at( HelpContentsId )->setEnabled ( myActiveApp != NULL );
2445 // myStdActions.at( HelpSearchId )->setEnabled ( myActiveApp != NULL );
2446 // myStdActions.at( HelpWhatsThisId )->setEnabled ( myActiveApp != NULL );
2447 // myStdActions.at( HelpAboutId )->setEnabled ( myActiveApp != NULL );
2449 // myToolsPopup.setEnabled ( myActiveStudy != NULL );
2450 // myPrefPopup.setEnabled ( myActiveStudy != NULL );
2452 mySelectionModePopup.setEnabled ( myActiveStudy != NULL );
2455 myStdActions.at( ViewOCCId )->setEnabled( myActiveStudy != NULL );
2456 myStdActions.at( ViewVTKId )->setEnabled( myActiveStudy != NULL );
2457 myStdActions.at( ViewPlot2dId )->setEnabled( myActiveStudy != NULL );
2462 Called when 'Window' popup is about to show
2464 void QAD_Desktop::onWindowPopupAboutToShow()
2466 /* add cascade/tile items */
2467 myWindowPopup.clear();
2470 //myStdActions.at( WindowNew3dId )->addTo( &myWindowPopup );
2471 myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId );
2472 //myStdActions.at( WindowNew3dId )->setEnabled( true );
2473 myWindowPopup.setItemEnabled( WindowNew3dId, true );
2475 myStdActions.at( WindowCascadeId )->addTo( &myWindowPopup );
2476 myStdActions.at( WindowCascadeId )->setEnabled( true );
2477 myStdActions.at( WindowTileId )->addTo( &myWindowPopup );
2478 myStdActions.at( WindowTileId )->setEnabled( true );
2480 /* add names of opened studies */
2481 QWidgetList windows = myWorkspace->windowList();
2482 if ( windows.isEmpty() )
2484 //NRI : SAL2214 myStdActions.at( WindowNew3dId )->setEnabled( false );
2485 myWindowPopup.setItemEnabled( WindowNew3dId, false );
2487 myStdActions.at( WindowCascadeId )->setEnabled( false );
2488 myStdActions.at( WindowTileId )->setEnabled( false );
2492 myWindowPopup.insertSeparator();
2493 for ( int i = 0; i < int(windows.count()); ++i )
2495 int id = myWindowPopup.insertItem( windows.at(i)->caption(),
2496 this, SLOT( onWindowsPopupActivated( int ) ) );
2497 myWindowPopup.setItemParameter( id, i );
2498 myWindowPopup.setItemChecked( id, myWorkspace->activeWindow() == windows.at(i) );
2500 QAD_ASSERT( connect( &myWindowPopup, SIGNAL(highlighted( int )), this,
2501 SLOT(onWindowsPopupStatusText( int )) ));
2506 Called when the item with 'id' of 'Windows' popup
2509 void QAD_Desktop::onWindowsPopupStatusText( int id )
2511 int cascadeId = myWindowPopup.idAt( 1 );
2512 int tileId = myWindowPopup.idAt( 2 );
2513 if ( id == cascadeId || id == tileId )
2515 putInfo( tr("PRP_DESK_WINDOW_ACTIVATE") );
2519 Called when user wants to activate a child window with 'wid'
2522 void QAD_Desktop::onWindowsPopupActivated( int wid )
2524 QWidget* w = myWorkspace->windowList().at( wid );
2525 if ( w ) w->setFocus();
2529 Selects a file name when opening or saving files.
2530 The basic implementation just uses the standard
2532 Please redefine if another behaviour is required.
2534 QString QAD_Desktop::selectFileName ( bool open )
2536 QAD_FileDlg* fd = new QAD_FileDlg( this, open, true, true );
2540 QStringList filters;
2543 // All the file types of the supported applications
2545 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
2547 filters += app->getStudyDescription() + " " + tr("DESK_FILES") + " " +
2548 "(*." + app->getStudyExtension() + ")";
2552 QAD_ASSERT_DEBUG_ONLY ( myActiveStudy );
2553 if (myActiveStudy) {
2554 // get file name of active study
2555 name = QAD_Tools::getFileNameFromPath ( myActiveStudy->getTitle() );
2556 // get path to the active study file
2557 dir = QAD_Tools::getDirFromPath ( myActiveStudy->getPath(), false );
2559 QAD_ASSERT_DEBUG_ONLY ( !name.isNull() );
2560 // the file types supported by the active application
2561 filters += myActiveApp->getStudyDescription() + " " + tr("DESK_FILES") + " " +
2562 "(*." + myActiveApp->getStudyExtension() + ")" ;
2564 if (!dir.isEmpty()) {
2565 // when saving document ("Save As" command) - to get dir from active study filename
2566 // for new documents - to use last opened directory
2569 fd->setSelection( name );
2570 fd->setFilters( filters );
2573 QString filename = fd->selectedFile();
2575 qApp->processEvents();
2580 Closes all the studies of 'app'. Returns
2581 'true' if thay are closed OK, 'false' at least
2582 one can't be closed or user cancel the closure.
2584 bool QAD_Desktop::closeAllStudies( QAD_Application* app )
2586 QList<QAD_Study>& studies = app->getStudies();
2587 while ( !studies.isEmpty() )
2589 //don't ask user to remove study permanently
2590 if ( !onCloseStudy( studies.at(0), false ) )
2591 return false; /* user cancelled closing */
2597 Called on Popup item when SComponent representation in Object Browser is selected.
2599 void QAD_Desktop::onOpenWith()
2601 Engines::Component_var comp;
2602 QString ComponentSelected;
2604 SALOMEDS::SObject_var SO;
2605 SALOMEDS::SComponent_var SCO;
2606 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2607 SALOMEDS::GenericAttribute_var anAttr;
2608 SALOMEDS::AttributeName_var aName;
2610 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2611 if ( Sel->IObjectCount() == 1 ) {
2612 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
2613 SO = aStudy->FindObjectID( IO->getEntry() );
2614 SCO = SO->GetFatherComponent();
2616 if (SCO->FindAttribute(anAttr, "AttributeName")) {
2617 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2618 name = aName->Value();
2619 if ( getComponentName( name ).isEmpty() )
2621 SALOME_ModuleCatalog::Acomponent_var Comp = myCatalogue->GetComponent( getComponentName(name) );
2622 if ( !Comp->_is_nil() ) {
2624 SALOME_ModuleCatalog::ListOfComponents_var list_type_composants =
2625 myCatalogue->GetTypedComponentList( Comp->component_type() );
2627 if ( list_type_composants->length() == 1 ) {
2628 ComponentSelected = name;
2629 } else if ( list_type_composants->length() > 1 ) {
2630 SALOMEGUI_OpenWith* aDlg = new SALOMEGUI_OpenWith( this );
2631 for (unsigned int ind = 0; ind < list_type_composants->length();ind++) {
2632 QString compusername = getComponentUserName( (char*)list_type_composants[ind] );
2633 if ( !compusername.isEmpty() )
2634 aDlg->addComponent( compusername );
2637 int retVal = aDlg->exec();
2638 ComponentSelected = aDlg->getComponent();
2640 if ( retVal == QDialog::Rejected || ComponentSelected.isEmpty()) {
2644 MESSAGE( "No component with type : " << Comp->component_type() << " exists" );
2649 MESSAGE( "This component not exists in the catalog" );
2653 QApplication::setOverrideCursor( Qt::waitCursor );
2654 Sel->ClearIObjects();
2656 // if (loadComponentData(ComponentSelected)) {
2657 onComboActiveComponent(ComponentSelected);
2658 // int nbItem = myCombo->count();
2660 // for (int i = 0; i < nbItem; i++) {
2661 // if (myCombo->text(i).compare(ComponentSelected)==0) {
2666 // myCombo->setCurrentItem(Index);
2667 // myActiveStudy->updateObjBrowser(true);
2671 QApplication::restoreOverrideCursor();
2676 Called to define settings of component.
2678 void QAD_Desktop::setSettings()
2680 SALOMEGUI* anActiveGUI = getActiveGUI();
2681 if ( anActiveGUI ) {
2682 QString Component = mapComponentName[myActiveComp];
2683 anActiveGUI->SetSettings( this, (char*)Component.latin1() );
2688 Called to load Component : xml resources and GUI librairy.
2690 bool QAD_Desktop::loadComponent(QString Component)
2692 if ( Component.isEmpty() ) {
2693 MESSAGE("loadComponent(): empty component name passed!")
2698 QString resDir("/"); //NRI : Pb under Windows
2700 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
2703 if (!resMgr->loadResources( Component, msg ))
2705 //NRI QCString errMsg;
2706 // errMsg.sprintf( "Do not load all resources for module %sGUI.\n" ,
2707 // Component.latin1() );
2709 QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
2714 /* Parse xml file */
2715 myXmlHandler = new QAD_XmlHandler();
2716 myXmlHandler->setMainWindow(this);
2717 if (!myXmlHandler->setComponent(resMgr->resources( Component ))) return false;
2719 QString language = resMgr->language( Component );
2721 QString ComponentXml = Component + "_" + language + ".xml";
2722 //ComponentXml = resMgr->resources(Component + "GUI") ;
2723 //ComponentXml = QAD_Tools::addSlash(ComponentXml) ;
2724 ComponentXml = QAD_Tools::addSlash( resMgr->findFile( ComponentXml, Component ) ) + ComponentXml;
2725 QFile file( ComponentXml );
2727 if ( !file.exists() || !file.open( IO_ReadOnly ) ) {
2729 errMsg.sprintf( "Cannot open xml file: %s\n.",
2730 (file.name()).latin1() );
2732 QMessageBox::critical( this, tr("ERR_ERROR"), errMsg, tr ("BUT_OK") );
2737 QXmlInputSource source( file );
2738 QXmlSimpleReader reader;
2739 reader.setContentHandler( myXmlHandler );
2740 reader.setErrorHandler( myXmlHandler );
2742 bool IsMaxActStudy = myActiveStudy->getActiveStudyFrame()->isMaximized();
2743 if (IsMaxActStudy) {
2744 QString aSourceData = source.data();
2745 aSourceData = changeXmlInputSourceData( aSourceData, Component );
2746 source.setData(aSourceData);
2749 bool ok = reader.parse( source );
2753 QMessageBox::critical( this,
2754 tr( "INF_PARSE_ERROR" ),
2755 tr( myXmlHandler->errorProtocol() ) );
2759 myMenusList=myXmlHandler->myMenusList;
2760 myActiveMenus=myMenusList.at(0);
2761 myOperatorMenus->showMenuBar(0);
2762 myActiveMenus->showAllToolBars();
2764 /* Components toolbars */
2767 nbToolbars = myActiveMenus->getToolBarList().count();
2769 /* COMPONENT INTERFACE */
2770 SALOME_ModuleCatalog::Acomponent_ptr aComponent =
2771 myCatalogue->GetComponent(Component.latin1());
2773 if (CORBA::is_nil (aComponent)) {
2774 MESSAGE( "Catalog Error : Component not found in the catalog" )
2778 myActiveStudy->setMessage(QString("Component : ") +
2779 aComponent->componentusername() + " created " );
2780 myActiveStudy->setMessage(QString("Type : ") +
2781 QString::number(aComponent->component_type()));
2782 myActiveStudy->setMessage(QString("Constraint : ") +
2783 aComponent->constraint() );
2785 /* obtain interfaces list of the component */
2786 SALOME_ModuleCatalog::ListOfInterfaces_var _list =
2787 new SALOME_ModuleCatalog::ListOfInterfaces;
2788 _list = aComponent->GetInterfaceList();
2790 if (_list->length() != 0 ) {
2792 for (unsigned int ind = 0; ind < _list->length();ind++)
2793 myActiveStudy->setMessage( QString("Interface name : ") +
2797 /* obtain services list of the component */
2798 SALOME_ModuleCatalog::ListOfServices_var list_services_component =
2799 new SALOME_ModuleCatalog::ListOfServices;
2800 list_services_component = aComponent->GetServiceList(_list[0]);
2802 if (list_services_component->length() != 0 ) {
2804 for (unsigned int ind = 0; ind < list_services_component->length();ind++)
2805 myActiveStudy->setMessage( QString("Service name : ") +
2806 list_services_component[ind] );
2808 // Get a service of the component
2809 SALOME_ModuleCatalog::Service_var service = new SALOME_ModuleCatalog::Service;
2810 service = aComponent->GetService(_list[0],list_services_component[0]) ;
2811 myActiveStudy->setMessage( QString("Service name: ") + service->ServiceName);
2812 for (unsigned int ind1 = 0; ind1 <service->ServiceinParameter.length();ind1++) {
2813 myActiveStudy->setMessage( QString("Type of the in Parameter of this service : ") +
2814 (const char *) service->ServiceinParameter[ind1].Parametertype);
2815 myActiveStudy->setMessage( QString("Name of the in Parameter of this service : ") +
2816 (const char *) service->ServiceinParameter[ind1].Parametername);
2818 for (unsigned int ind1 = 0; ind1 <service->ServiceoutParameter.length();ind1++) {
2819 myActiveStudy->setMessage( QString("Type of the out Parameter of this service : ") +
2820 (const char *) service->ServiceoutParameter[ind1].Parametertype);
2821 myActiveStudy->setMessage( QString("Name of the out Parameter of this service : ") +
2822 (const char *) service->ServiceoutParameter[ind1].Parametername);
2829 QString QAD_Desktop::changeXmlInputSourceData(QString theData, QString theComponent)
2831 // MESSAGE ( " changeXmlInputSourceData : " << theComponent.latin1() )
2832 if ( theComponent=="SUPERV" ) {
2833 //Supervision main menu item
2836 QString aStrOld = createString( aItemId, aPosId );
2837 QString aStrNew = createString( aItemId, aPosId+1 );
2838 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2841 if ( theComponent == "VISU" ) {
2842 //Visualization main menu item
2845 QString aStrOld = createString( aItemId, aPosId );
2846 QString aStrNew = createString( aItemId, aPosId+1 );
2847 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2849 //Selection main menu item
2852 aStrOld = createString( aItemId, aPosId );
2853 aStrNew = createString( aItemId, aPosId+1 );
2854 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2856 //Representation main menu item
2859 aStrOld = createString( aItemId, aPosId );
2860 aStrNew = createString( aItemId, aPosId+1 );
2861 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2864 if ( theComponent == "SMESH" ) {
2865 //Hypotheses main menu item
2868 QString aStrOld = createString( aItemId, aPosId );
2869 QString aStrNew = createString( aItemId, aPosId+1 );
2870 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2872 //Mesh main menu item
2875 aStrOld = createString( aItemId, aPosId );
2876 aStrNew = createString( aItemId, aPosId+1 );
2877 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2879 //Controls main menu item
2882 aStrOld = createString( aItemId, aPosId );
2883 aStrNew = createString( aItemId, aPosId+1 );
2884 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2886 //Modification main menu item
2889 aStrOld = createString( aItemId, aPosId );
2890 aStrNew = createString( aItemId, aPosId+1 );
2891 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2893 //Numbering main menu item
2896 // aStrOld = createString( aItemId, aPosId );
2897 // aStrNew = createString( aItemId, aPosId+1 );
2898 // theData = theData.replace( QRegExp(aStrOld), aStrNew );
2901 if ( theComponent == "GEOM" ) {
2902 //New Entity main menu item
2905 QString aStrOld = createString( aItemId, aPosId );
2906 QString aStrNew = createString( aItemId, aPosId+1 );
2907 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2909 //Operations main menu item
2912 aStrOld = createString( aItemId, aPosId );
2913 aStrNew = createString( aItemId, aPosId+1 );
2914 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2916 //Repair main menu item
2919 aStrOld = createString( aItemId, aPosId );
2920 aStrNew = createString( aItemId, aPosId+1 );
2921 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2923 //Measures main menu item
2926 aStrOld = createString( aItemId, aPosId );
2927 aStrNew = createString( aItemId, aPosId+1 );
2928 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2931 if ( theComponent == "MED" ) {
2932 //MED main menu item
2935 QString aStrOld = createString( aItemId, aPosId );
2936 QString aStrNew = createString( aItemId, aPosId+1 );
2937 theData = theData.replace( QRegExp(aStrOld), aStrNew );
2943 typedef bool OneDim(int, QAD_Desktop*);
2944 typedef void (*PTR_FACTORY_FUNCTION)( CORBA::ORB_var &orb, QWidget *parent, const char *name ) ;
2948 void QAD_Desktop::onDispatch()
2950 const QObject* obj = sender();
2952 QList<QAD_ListMenuIdAction> MenuList = myActiveMenus->getMenuList();
2953 QAD_ListMenuIdAction* aMenu;
2955 for(aMenu=MenuList.first();aMenu!=NULL;aMenu=MenuList.next()) {
2956 if (aMenu->getAction()==obj) {
2957 id = aMenu->getId();
2966 void QAD_Desktop::onDispatchTools(int id)
2968 /* Open Shared Library */
2969 OSD_SharedLibrary ToolsLibrary = OSD_SharedLibrary();
2973 QFileInfo fileInfo ;
2976 bool libToolsGUI = true;
2977 if( QAD_XmlHandler::_bibmap[ id ].isEmpty() )
2979 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
2980 dir = QAD_Tools::addSlash(dir) ;
2982 dir = QAD_Tools::addSlash(dir) ;
2983 dir = dir + "salome" ;
2984 dir = QAD_Tools::addSlash(dir) ;
2986 dir = dir + "libToolsGUI.dll" ;
2988 dir = dir + "libToolsGUI.so" ;
2990 MESSAGE ( " GUI library = " << dir );
2991 fileInfo.setFile(dir) ;
2992 if (fileInfo.exists()) {
2993 ToolsLib = fileInfo.fileName() ;
2999 libToolsGUI = false;
3000 SCRUTE( QAD_XmlHandler::_bibmap[ id ] ) ;
3001 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
3002 dir = QAD_Tools::addSlash(dir) ;
3004 dir = QAD_Tools::addSlash(dir) ;
3005 dir = dir + "salome" ;
3006 dir = QAD_Tools::addSlash(dir) ;
3007 dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ;
3008 MESSAGE ( " GUI library = " << dir );
3009 fileInfo.setFile(dir) ;
3010 if (fileInfo.exists()) {
3011 ToolsLib = fileInfo.fileName() ;
3017 ToolsLibrary.SetName(TCollection_AsciiString((char*)ToolsLib.latin1()).ToCString());
3018 bool ok = ToolsLibrary.DlOpen(OSD_RTLD_LAZY);
3020 if ( libToolsGUI ) {
3021 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
3022 OneDim (*f1) = NULL;
3023 f1 = (bool (*) (int, QAD_Desktop*)) osdF;
3026 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
3027 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
3028 CORBA::ORB_var &orb = init(0 , 0 ) ;
3029 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
3030 PTR_FACTORY_FUNCTION f1 = NULL;
3031 f1 = (PTR_FACTORY_FUNCTION) osdF;
3032 f1(orb,0,"Registry");
3035 QMessageBox::critical( this,
3037 tr( ToolsLibrary.DlError() ) );
3043 void QAD_Desktop::onDispatch(int id)
3045 SALOMEGUI* anActiveGUI = getActiveGUI();
3047 anActiveGUI->OnGUIEvent(id,this);
3051 Returns the component's catalogue
3053 SALOME_ModuleCatalog::ModuleCatalog_var QAD_Desktop::getCatalogue()
3060 void QAD_Desktop::onComboActiveComponent( const QString & component ){
3061 onComboActiveComponent(component,true);
3063 void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoadData)
3065 if (myActiveStudy != 0) {
3066 if (myActiveComp.compare(component)!=0) {
3067 // deactivate previous component
3068 deactivateComponent();
3070 if (!myXmlHandler->myIdList.IsEmpty()) clearMenus();
3071 if ( myCombo->currentText() != component )
3072 myCombo->setCurrentText( component );
3073 //NRI if (component.compare(QString("Salome"))!= 0) {
3074 if (component.compare( getComponentUserName( "KERNEL" ) )!= 0) {
3075 // QApplication::setOverrideCursor( Qt::waitCursor );
3076 bool isOk = ( !isLoadData || loadComponentData( getComponentName(component) ) );
3078 QAD_MessageBox::error1( this,
3080 tr("ERR_COMP_DATA_NOT_LOADED").arg( component ),
3084 if ( !isOk || !loadComponent( getComponentName(component) ) ) {
3085 myCombo->setCurrentItem (0);
3086 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3087 aButton->setOn(false);
3093 myActiveComp = component;
3095 SALOME_Selection* oldSel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3097 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3098 if ( aButton->textLabel().compare(component)==0)
3099 aButton->setOn(true);
3101 aButton->setOn(false);
3104 myActiveStudy->Selection( component );
3106 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3107 SALOME_ListIteratorOfListIO It( oldSel->StoredIObjects() );
3108 for(;It.More();It.Next()) {
3109 int res = Sel->AddIObject( It.Value() );
3112 myActiveStudy->highlight( It.Value(), false );
3114 myActiveStudy->highlight( It.Value(), true );
3121 // IMPORTANT: SetSettings() should be called AFTER SALOME_Selection
3122 // has been created for a newly activated component
3123 getComponentGUI(component)->SetSettings( this, (char*)getComponentName(component).latin1() );
3125 myActiveStudy->updateObjBrowser(true);
3127 // QApplication::restoreOverrideCursor();
3129 } else { // component == "Salome"
3131 //NRI myActiveStudy->Selection( "Salome" );
3132 myActiveStudy->Selection( getComponentUserName( "KERNEL" ) );
3133 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
3134 Sel->ClearIObjects();
3135 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3136 aButton->setOn(false);
3140 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3141 if ( aButton->textLabel().compare(component)==0)
3142 aButton->setOn(true);
3145 } else if (component.compare(QString("Salome"))!= 0) {
3148 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3149 if ( aButton->textLabel().compare( component ) == 0 )
3150 pm = aButton->iconSet().pixmap();
3152 SALOMEGUI_ActivateComponentDlg aDlg( this, component, pm );
3153 int res = aDlg.exec();
3159 onComboActiveComponent(component,true);
3163 onComboActiveComponent(component,true);
3167 onComboActiveComponent(component,true);;
3171 putInfo( tr("INF_CANCELLED") );
3172 myCombo->setCurrentItem (0);
3173 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3174 aButton->setOn(false);
3183 void QAD_Desktop::activateComponent(const QString& theName, bool isLoadData){
3185 int nbItem = myCombo->count();
3188 for (int i = 0; i < nbItem; i++) {
3189 if (myCombo->text(i).compare(theName)==0) {
3194 myCombo->setCurrentItem (Index);
3195 onComboActiveComponent(theName,isLoadData);
3198 void QAD_Desktop::onButtonActiveComponent( )
3200 QToolButton* obj = (QToolButton*)sender();
3201 activateComponent(obj->textLabel());
3205 Clears All Resources of current component
3207 void QAD_Desktop::clearMenus()
3209 // san - commented as presumably obsolete
3210 // onActiveStudyChanged();
3213 myMenusList.clear();
3215 int length = myXmlHandler->myIdList.Length();
3216 for (int k=length; k>0; k--) {
3218 if ( menuBar()->findItem(myXmlHandler->myIdList.Value(k), &parent) )
3219 parent->removeItem( myXmlHandler->myIdList.Value(k) );
3224 if (myActiveMenus) {
3225 int nbtoolbars = myActiveMenus->getToolBarList().count();
3226 for (int k=0; k<nbtoolbars; k++) {
3227 myActiveMenus->getToolBarList().at(k)->hide();
3228 myActiveMenus->getToolBarList().at(k)->clear();
3230 myActiveMenus->clearToolBar();
3233 QList<QAD_ListPopupMenu> PopupList = myActiveMenus->getPopupMenuList();
3234 QAD_ListPopupMenu* aPopup;
3235 for(aPopup=PopupList.first();aPopup!=NULL;aPopup=PopupList.next()){
3236 aPopup->getPopup()->clear();
3239 myActiveMenus->clearPopupMenu();
3245 typedef bool TwoDim1(QKeyEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
3247 Exports Key Events in active component ( GUI Librairy )
3249 void QAD_Desktop::onKeyPress( QKeyEvent* pe )
3251 // MESSAGE ( "QAD_Desktop::onKeyPress" )
3252 SALOMEGUI* anActiveGUI = getActiveGUI();
3254 anActiveGUI->OnKeyPress(pe,this,myActiveStudy->getActiveStudyFrame());
3257 typedef bool TwoDim(QMouseEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
3259 Exports Mouse Press Events in active component ( GUI Librairy )
3261 bool QAD_Desktop::onMousePress( QMouseEvent* pe )
3263 // MESSAGE ( "QAD_Desktop::onMousePress" )
3264 SALOMEGUI* anActiveGUI = getActiveGUI();
3266 return anActiveGUI->OnMousePress(pe,this,myActiveStudy->getActiveStudyFrame());
3271 Exports Mouse Move Events in active component ( GUI Librairy )
3273 void QAD_Desktop::onMouseMove( QMouseEvent* pe )
3275 SALOMEGUI* anActiveGUI = getActiveGUI();
3277 anActiveGUI->OnMouseMove(pe,this,myActiveStudy->getActiveStudyFrame());
3281 Returns name of active component
3283 const QString& QAD_Desktop::getActiveComponent() const
3285 return myActiveComp;
3288 SALOMEGUI* QAD_Desktop::getActiveGUI()
3290 SALOMEGUI* anActiveGUI = 0;
3291 if ( myComponents.find( myActiveComp ) != myComponents.end() )
3292 anActiveGUI = myComponents[myActiveComp];
3296 typedef SALOMEGUI* (*ComponentGUI)();
3298 SALOMEGUI* QAD_Desktop::getComponentGUI( const QString& component )
3300 SALOMEGUI* aCompGUI = 0;
3301 if ( component.isEmpty() || getComponentName( component ).isEmpty() )
3304 // Load component GUI if requested for the first time
3305 if ( myComponents.find( component ) == myComponents.end() ) {
3306 OSD_SharedLibrary aSharedLibrary;
3307 QString ComponentLib;
3309 QFileInfo fileInfo ;
3310 QString fileString ;
3317 if ( libs = getenv("LD_LIBRARY_PATH")) {
3318 // MESSAGE ( " LD_LIBRARY_PATH : " << libs );
3319 QStringList dirList = QStringList::split( SEPARATOR, libs, false ); // skip empty entries
3320 for ( int i = dirList.count()-1; i >= 0; i-- ) {
3323 fileString = QAD_Tools::addSlash( dir ) + "lib" + getComponentName( component ) + "GUI.dll" ;
3325 fileString = QAD_Tools::addSlash( dir ) + "lib" + getComponentName( component ) + "GUI.so" ;
3328 fileInfo.setFile(fileString) ;
3329 if (fileInfo.exists()) {
3330 // MESSAGE( " GUI library = " << fileString.latin1() );
3331 ComponentLib = fileInfo.fileName() ;
3338 if (!_islibso) // component GUI could be in PyQt, use generic library
3340 MESSAGE("GUI library not found, trying generic library for PyQt GUI");
3342 if (dir = getenv("KERNEL_ROOT_DIR"))
3344 dir = QAD_Tools::addSlash(dir) ;
3346 dir = QAD_Tools::addSlash(dir) ;
3347 dir = dir + "salome" ;
3348 dir = QAD_Tools::addSlash(dir) ;
3350 dir = dir + "libSalomePyQtcmodule.dll" ;
3352 dir = dir + "libSalomePyQtcmodule.so" ;
3354 MESSAGE ( " GUI library = " << dir );
3355 fileInfo.setFile(dir) ;
3356 if (fileInfo.exists())
3358 ComponentLib = fileInfo.fileName() ;
3364 QMessageBox::critical( this,
3366 tr("ERR_LIBGUI" ).arg(component) );
3371 aSharedLibrary.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString());
3372 bool ok = aSharedLibrary.DlOpen(OSD_RTLD_LAZY);
3375 QMessageBox::critical( this,
3377 tr( aSharedLibrary.DlError() ) );
3381 OSD_Function osdF = aSharedLibrary.DlSymb("GetComponentGUI");
3382 if ( osdF != NULL ) {
3383 ComponentGUI f1 = (SALOMEGUI* (*) ()) osdF;
3384 SALOMEGUI* aCompGUI = (*f1)();
3386 myComponents.insert( component, aCompGUI );
3389 QMessageBox::critical( this,
3391 tr("ERR_GET_GUI_FAILED" ).arg(component) );
3397 QMessageBox::critical( this,
3399 tr("ERR_GET_GUI_NOT_FOUND" ).arg(ComponentLib) );
3403 aCompGUI = myComponents[component];
3409 Returns name of active component
3411 QString QAD_Desktop::getComponentDataType() const
3413 using namespace SALOMEDS;
3414 Study_var aStudy = getActiveStudy()->getStudyDocument();
3415 SObject_var aSObject = aStudy->FindObject(myActiveComp.latin1());
3416 SComponent_var aComponent = SComponent::_narrow(aSObject);
3417 if(!aComponent->_is_nil()){
3418 CORBA::String_var aString = aComponent->ComponentDataType();
3419 return aString.in();
3424 void QAD_Desktop::definePopup(QString & theContext,
3425 QString & theParent,
3426 QString & theObject )
3428 SALOMEGUI* anActiveGUI = getActiveGUI();
3430 anActiveGUI->DefinePopup(theContext, theParent, theObject);
3435 Copy popup menu [ static ]
3437 static void makePopup( QPopupMenu* popup, QPopupMenu* fromPopup, QAD_Desktop* receiver )
3440 if ( !popup || !fromPopup )
3442 // iterator through all popup items
3443 for ( int i = fromPopup->count()-1; i >= 0; i-- ) {
3444 int cmdId = fromPopup->idAt( i );
3445 QMenuItem* item = fromPopup->findItem( cmdId );
3447 // if item is a separator
3448 if ( item->isSeparator() ) {
3449 popup->insertSeparator( 0 );
3452 QIconSet* iconSet = item->iconSet();
3453 QKeySequence accel = fromPopup->accel( cmdId );
3455 QPopupMenu* popupChild = item->popup();
3456 // if item is a popup
3457 if ( popupChild && popupChild != fromPopup ) {
3458 QPopupMenu* newPopup = new QPopupMenu( popup );
3460 popup->insertItem( *iconSet, item->text(), newPopup, cmdId, 0 );
3462 popup->insertItem( item->text(), newPopup, cmdId, 0 );
3463 makePopup( newPopup, popupChild, receiver );
3465 // if item is a command
3468 popup->insertItem( *iconSet, item->text(), cmdId, 0 );
3470 popup->insertItem( item->text(), cmdId, 0 );
3471 popup->connectItem( cmdId, receiver, SLOT( onDispatch( int ) ) );
3473 popup->setAccel( accel, cmdId );
3482 void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext,
3483 const QString & theParent, const QString & theObject )
3485 if ( !myActiveComp.isEmpty() &&
3486 getOperatorMenus()->createPopupMenu(theContext,theParent,theObject) != NULL ) {
3487 makePopup( popup, getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup(), this );
3490 // Should be moved to SALOMEGUI_Application::onCreatePopup()...
3491 if ( myActiveComp.isEmpty() ) {
3492 popup->removeItem(QAD_Display_Popup_ID);
3493 popup->removeItem(QAD_DisplayOnly_Popup_ID);
3494 popup->removeItem(QAD_Erase_Popup_ID);
3495 int id = popup->idAt(popup->count()-1); // last item
3496 if (id < 0 && id != -1) popup->removeItem(id); // separator
3498 if ( popup && theParent.compare("ObjectBrowser")==0 ) {
3499 if ( popup->count()>0 ) {
3500 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()), 0, -1, 2);
3501 popup->insertSeparator (3);
3504 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()) );
3511 void QAD_Desktop::onActiveStudyChanged()
3513 // Avoid recursive calls caused by QAD_MessageBox
3514 static bool isRecursion = false;
3515 if ( isRecursion || myAboutToClose )
3518 if (myActiveComp != "") {
3519 // Try to load active component's data in the activated study
3520 if ( !loadComponentData(mapComponentName[myActiveComp]) ) {
3522 QAD_MessageBox::error1( this,
3524 tr("ERR_COMP_DATA_NOT_LOADED").arg( myActiveComp ),
3526 // Error while loading component's data -> deactivate it
3527 deactivateComponent();
3528 if (!myXmlHandler->myIdList.IsEmpty()) clearMenus();
3529 myCombo->setCurrentItem (0);
3530 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
3531 aButton->setOn(false);
3534 isRecursion = false;
3538 myActiveStudy->updateObjBrowser(true);
3541 SALOMEGUI* anActiveGUI = getActiveGUI();
3543 anActiveGUI->ActiveStudyChanged(this);
3546 void QAD_Desktop::deactivateComponent()
3548 SALOMEGUI* anActiveGUI = getActiveGUI();
3550 anActiveGUI->Deactivate();
3554 Custom popup ( GUI Library )
3556 void QAD_Desktop::customPopup(QPopupMenu* popup, const QString & theContext,
3557 const QString & theParent, const QString & theObject)
3559 SALOMEGUI* anActiveGUI = getActiveGUI();
3561 anActiveGUI->CustomPopup(this, popup, theContext, theParent, theObject);
3564 void QAD_Desktop::onObjectBrowser()
3566 bool checkDiff = false;
3568 bool state = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn").compare("true") == 0;
3570 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() != state )
3574 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() ) {
3576 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "true");
3579 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "false");
3583 if ( myStdActions.at( PrefObjectBrowserValueId )->isOn() ) {
3585 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "true");
3588 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "false");
3592 if ( myStdActions.at( PrefObjectBrowserIAPPId )->isOn() ) {
3594 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "true");
3597 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "false");
3600 /* To sort created object in chrono order or reverse chrono order */
3601 bool showCHRONO_SORT ;
3602 if ( myStdActions.at( PrefObjectBrowserCHRONO_SORTId )->isOn() ) {
3603 showCHRONO_SORT = true;
3604 QAD_CONFIG->addSetting( "ObjectBrowser:ChronologicalSort", "true");
3606 showCHRONO_SORT = false;
3607 QAD_CONFIG->addSetting( "ObjectBrowser:ChronologicalSort", "false");
3610 /* To show or not to show UseCase browser */
3612 if ( myStdActions.at( PrefObjectBrowserShowUseCaseId )->isOn() ) {
3614 QAD_CONFIG->addSetting( "ObjectBrowser:ShowUseCaseBrowser", "true");
3616 showUseCase = false;
3617 QAD_CONFIG->addSetting( "ObjectBrowser:ShowUseCaseBrowser", "false");
3620 /* Resize or don't resize columns automatically */
3622 if ( myStdActions.at( PrefObjectBrowserNoAutoSizeColumnsId )->isOn() ) {
3624 QAD_CONFIG->addSetting( "ObjectBrowser:NoAutoSizeColumns", "true");
3627 QAD_CONFIG->addSetting( "ObjectBrowser:NoAutoSizeColumns", "false");
3630 if ( myActiveApp ) {
3631 QList<QAD_Study>& studies = myActiveApp->getStudies();
3632 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3633 int nbSf = study->getStudyFramesCount();
3634 for ( int i = 0; i < nbSf; i++ ) {
3635 QAD_StudyFrame* sf = study->getStudyFrame(i);
3636 sf->getLeftFrame()->getObjectBrowser()->setShowInfoColumns( showEntry );
3637 sf->getLeftFrame()->getObjectBrowser()->setShowValueColumn( showValue );
3638 sf->getLeftFrame()->getObjectBrowser()->setEnableChronoSort( showCHRONO_SORT );
3639 // sf->getLeftFrame()->getObjectBrowser()->setShowIAPP( showIAPP ); // this is done by below updateObjBrowser() call
3640 sf->getLeftFrame()->getObjectBrowser()->showUseCaseBrowser( showUseCase );
3641 sf->getLeftFrame()->getObjectBrowser()->autoSizeColumns( autoSize );
3643 study->updateObjBrowser(true);
3648 void QAD_Desktop::onViewerTrihedron()
3650 QString Size = QAD_CONFIG->getSetting("Viewer:TrihedronSize");
3653 SALOMEGUI_TrihedronSizeDlg *Dlg = new SALOMEGUI_TrihedronSizeDlg(this);
3654 if (!Size.isEmpty())
3655 Dlg->setTrihedronSize(Size.toInt());
3656 int r = Dlg->exec();
3657 dim = Dlg->getTrihedronSize();
3660 if (r == QDialog::Accepted) {
3661 QAD_CONFIG->addSetting("Viewer:TrihedronSize", dim);
3664 QList<QAD_Study>& studies = myActiveApp->getStudies();
3665 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3666 int nbSf = study->getStudyFramesCount();
3667 for ( int i = 0; i < nbSf; i++ ) {
3668 study->getStudyFrame(i)->getRightFrame()->getViewFrame()->onAdjustTrihedron();
3675 void QAD_Desktop::onExternalBrowser()
3678 QString theApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
3679 QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3681 SALOMEGUI_ExternalBrowserDlg *Dlg = new SALOMEGUI_ExternalBrowserDlg(this);
3683 if (!theApp.isEmpty())
3685 QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3686 Dlg->setSettings(theApp, theParams);
3688 int r = Dlg->exec();
3689 QString theAppFromDialog = Dlg->getApp();
3690 QString theParamsFromDialog = Dlg->getParams();
3693 if (r == QDialog::Accepted)
3695 QAD_CONFIG->addSetting("ExternalBrowser:Application", theAppFromDialog );
3696 QAD_CONFIG->addSetting("ExternalBrowser:Parameters", theParamsFromDialog );
3702 void QAD_Desktop::onDirList()
3704 // getting dir list from settings
3705 QStringList dirList = QStringList::split(';', QAD_CONFIG->getSetting("FileDlg:QuickDirList"), false);
3706 QAD_DirListDlg* dlg = new QAD_DirListDlg(this);
3707 dlg->setPathList(dirList);
3708 if ( dlg->exec() == QDialog::Accepted) {
3709 dlg->getPathList(dirList);
3710 QAD_CONFIG->addSetting("FileDlg:QuickDirList", dirList.join(";"));
3715 void QAD_Desktop::onConsoleFontAction()
3717 // getting font from settings
3718 QString fntSet = QAD_CONFIG->getSetting("Viewer:ConsoleFont");
3719 QFont font = QAD_Tools::stringToFont( fntSet );
3721 font = QFontDialog::getFont( &bOk, font, this );
3723 fntSet = QAD_Tools::fontToString( font );
3724 QAD_CONFIG->addSetting("Viewer:ConsoleFont", fntSet );
3727 QList<QAD_Study>& studies = myActiveApp->getStudies();
3728 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3729 int nbSf = study->getStudyFramesCount();
3730 for ( int i = 0; i < nbSf; i++ ) {
3731 study->getStudyFrame(i)->getRightFrame()->getPyEditor()->setFont( font );
3732 study->getStudyFrame(i)->getRightFrame()->getMessage()->setFont( font );
3739 void QAD_Desktop::onSavePref()
3741 QAD_CONFIG->createConfigFile(true);
3744 //VRV: T2.5 - add default viewer
3745 void QAD_Desktop::onDefaultViewer(QActionP * theAction)
3747 int type = VIEW_TYPE_MAX;
3750 if (myStdActions.at(DefaultViewerOCCId) == theAction)
3752 else if (myStdActions.at(DefaultViewerVTKId) == theAction)
3754 else if (myStdActions.at(DefaultGraphSupervisorId) == theAction)
3755 type = VIEW_GRAPHSUPERV;
3756 else if (myStdActions.at(DefaultPlot2dId) == theAction)
3758 if ( type != VIEW_TYPE_MAX )
3759 QAD_CONFIG->addSetting( "Viewer:DefaultViewer", QString::number( type ) );
3761 //VRV: T2.5 - add default viewer
3763 void QAD_Desktop::onViewerOCC()
3765 QString BackgroundColorRed = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorRed");
3766 QString BackgroundColorGreen = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorGreen");
3767 QString BackgroundColorBlue = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorBlue");
3770 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3771 color = QColor(BackgroundColorRed.toInt(),
3772 BackgroundColorGreen.toInt(),
3773 BackgroundColorBlue.toInt());
3775 color = QColor(35, 136, 145);
3777 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3780 /* VSR : PAL5420 ---------------------------------------------------
3781 if ( myActiveApp ) {
3782 QList<QAD_Study>& studies = myActiveApp->getStudies();
3783 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3784 int nbSf = study->getStudyFramesCount();
3785 for ( int i = 0; i < nbSf; i++ ) {
3786 QAD_StudyFrame* sf = study->getStudyFrame(i);
3787 if ( sf->getTypeView() == VIEW_OCC ) {
3788 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3793 VSR : PAL5420 --------------------------------------------------- */
3794 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", c.red() );
3795 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", c.green() );
3796 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", c.blue() );
3800 void QAD_Desktop::onGraphSupervisor()
3802 QString BackgroundColorRed = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed");
3803 QString BackgroundColorGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen");
3804 QString BackgroundColorBlue = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue");
3807 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3808 color = QColor(BackgroundColorRed.toInt(),
3809 BackgroundColorGreen.toInt(),
3810 BackgroundColorBlue.toInt());
3812 color = QColor(35, 136, 145);
3814 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3817 /* VSR : PAL5420 ---------------------------------------------------
3818 if ( myActiveApp ) {
3819 QList<QAD_Study>& studies = myActiveApp->getStudies();
3820 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3821 int nbSf = study->getStudyFramesCount();
3822 for ( int i = 0; i < nbSf; i++ ) {
3823 QAD_StudyFrame* sf = study->getStudyFrame(i);
3824 if ( sf->getTypeView() == VIEW_GRAPHSUPERV ) {
3825 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3830 VSR : PAL5420 --------------------------------------------------- */
3831 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorRed", c.red() );
3832 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorGreen", c.green() );
3833 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorBlue", c.blue() );
3837 void QAD_Desktop::onViewerVTK()
3839 QString BackgroundColorRed = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
3840 QString BackgroundColorGreen = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
3841 QString BackgroundColorBlue = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
3844 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3845 color = QColor(BackgroundColorRed.toInt(),
3846 BackgroundColorGreen.toInt(),
3847 BackgroundColorBlue.toInt());
3849 color = QColor(0, 0, 0);
3851 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3854 /* VSR : PAL5420 ---------------------------------------------------
3855 if ( myActiveApp ) {
3856 QList<QAD_Study>& studies = myActiveApp->getStudies();
3857 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3858 int nbSf = study->getStudyFramesCount();
3859 for ( int i = 0; i < nbSf; i++ ) {
3860 QAD_StudyFrame* sf = study->getStudyFrame(i);
3861 if ( sf->getTypeView() == VIEW_VTK ) {
3862 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3867 VSR : PAL5420 --------------------------------------------------- */
3868 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", c.red() );
3869 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", c.green() );
3870 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", c.blue() );
3874 void QAD_Desktop::onPlot2d()
3877 if ( QAD_CONFIG->hasSetting( "Plot2d:Background" ) ) {
3878 QString bgString = QAD_CONFIG->getSetting( "Plot2d:Background" );
3879 QStringList bgData = QStringList::split( ":", bgString, true );
3880 int bgRed = 0, bgGreen = 0, bgBlue = 0;
3881 if ( bgData.count() > 0 ) bgRed = bgData[ 0 ].toInt();
3882 if ( bgData.count() > 1 ) bgGreen = bgData[ 1 ].toInt();
3883 if ( bgData.count() > 2 ) bgBlue = bgData[ 2 ].toInt();
3884 color = QColor( bgRed, bgGreen, bgBlue );
3887 color = QColor(255, 255, 255);
3890 color = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3892 if ( color.isValid() ) {
3893 /* VSR : PAL5420 ---------------------------------------------------
3894 if ( myActiveApp ) {
3895 QList<QAD_Study>& studies = myActiveApp->getStudies();
3896 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3897 int nbSf = study->getStudyFramesCount();
3898 for ( int i = 0; i < nbSf; i++ ) {
3899 QAD_StudyFrame* sf = study->getStudyFrame(i);
3900 if ( sf->getTypeView() == VIEW_PLOT2D ) {
3901 sf->getRightFrame()->getViewFrame()->setBackgroundColor( color );
3906 VSR : PAL5420 --------------------------------------------------- */
3908 bgData.append( QString::number( color.red() ) );
3909 bgData.append( QString::number( color.green() ) );
3910 bgData.append( QString::number( color.blue() ) );
3911 QAD_CONFIG->addSetting( "Plot2d:Background", bgData.join( ":" ) );
3916 void QAD_Desktop::helpAbout()
3918 SALOMEGUI_AboutDlg* About = new SALOMEGUI_AboutDlg( QAD_Application::getDesktop(), tr("MEN_ABOUT"));
3923 // /* Help Search */
3924 // void QAD_Desktop::helpSearch()
3928 // /* Help Contents */
3929 // void QAD_Desktop::helpContents()
3931 // if (myActiveComp == "")
3932 // myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
3936 // if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
3937 // root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" );
3938 // if ( QFileInfo( root + "index.html" ).exists() ) {
3939 // helpContext( root + "index.html", "" );
3942 // root = QAD_Tools::addSlash( root + "html" );
3943 // if ( QFileInfo( root + "index.html" ).exists() ) {
3944 // helpContext( root + "index.html", "" );
3947 // root = QAD_Tools::addSlash( root + "html" );
3948 // if ( QFileInfo( root + "index.html" ).exists() ) {
3949 // helpContext( root + "index.html", "" );
3955 // // //NRI getHelpWindow()->contents();
3956 // // getHelpWindow()->show();
3957 // // getHelpWindow()->raise();
3958 // // getHelpWindow()->setActiveWindow();
3962 //void QAD_Desktop::helpContext(const QString& source, const QString& context)
3964 // //getHelpWindow()->context(source, context); //implemented in QAD_HelpWindow::context( const QString& _source, const QString& _context)
3965 // //getHelpWindow()->show(); //from QMainWindow class
3966 // //getHelpWindow()->raise(); //from QMainWindow class
3967 // //getHelpWindow()->setActiveWindow(); //from QMainWindow class
3969 // QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
3970 // QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3972 // RunBrowser* rs = new RunBrowser(anApp, aParams, source, context);
3976 /* Preferences/MultiFile Save */
3977 void QAD_Desktop::onMultiFileSave()
3979 if ( myStdActions.at( PrefMultiFileSave )->isOn() )
3980 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "true");
3982 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "false");
3985 /* Preferences/ASCII Save */
3986 void QAD_Desktop::onASCIISave()
3988 if ( myStdActions.at( PrefASCIISave )->isOn() )
3989 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "true");
3991 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "false");
3994 /* Preferences / Undo Level */
3995 void QAD_Desktop::onUndoLevel()
3997 static int MAX_UNDO_LEVEL = 1000;
3998 bool isAccepted = false;
3999 static QString aLabel = QString("Level value (%1 ... %2) : ").
4000 arg(1).arg(MAX_UNDO_LEVEL);
4002 SALOMEGUI_SetValueDlg::getInteger("Undo Level",aLabel,
4003 1,MAX_UNDO_LEVEL,getUndoLevel(),
4005 if(!isAccepted) return;
4006 QAD_CONFIG->addSetting("Desktop:UndoLevel", anUndoLevel);
4007 if(!myActiveApp) return;
4008 QList<QAD_Study>& studies = myActiveApp->getStudies();
4009 int aWasWarning = 0;
4010 for(QAD_Study* study = studies.first(); study; study = studies.next()){
4011 SALOMEDS::Study_var aStudyDoc = study->getStudyDocument();
4012 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDoc->NewBuilder();
4013 if (!aStudyDoc->GetProperties()->IsLocked()) {
4014 aStudyBuilder->UndoLimit(anUndoLevel);
4017 QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(),
4018 QObject::tr("WRN_WARNING"),
4019 QObject::tr("WRN_STUDY_LOCKED"),
4020 QObject::tr("BUT_OK"));
4027 /* Update status bar for File menu items */
4028 void QAD_Desktop::onFilePopupStatusText( int id )
4030 QString component = getActiveComponent();
4032 if (component != "") {
4033 //one of the modules is active now
4034 int importId = myFilePopup.idAt(8);
4035 int exportId = myFilePopup.idAt(9);
4036 int importTableId = myFilePopup.idAt(10);
4038 if (component == getComponentUserName("SMESH") || component == getComponentUserName("GEOM")) {
4040 putInfo( tr("PRP_DESK_FILE_IMPORT") );
4042 putInfo( tr("PRP_DESK_FILE_EXPORT") );
4044 if (component == getComponentUserName("VISU")) {
4046 putInfo( tr("PRP_DESK_FILE_IMPORTMED") );
4047 if (id == importTableId)
4048 putInfo( tr("PRP_DESK_FILE_IMPORTTABLE") );
4050 putInfo( tr("PRP_DESK_FILE_EXPLOREMEDFILE") );
4052 if (component == getComponentUserName("SUPERV")) {
4054 putInfo( tr("PRP_DESK_FILE_IMPORTDF") );
4056 putInfo( tr("PRP_DESK_FILE_EXPORTDF") );
4061 /* Update status bar for Edit menu items */
4062 void QAD_Desktop::onEditPopupStatusText( int id )
4064 QString component = getActiveComponent();
4066 if (component != "") {
4067 //one of the modules is active now
4069 if (component == getComponentUserName("SMESH") || component == getComponentUserName("GEOM") ) {
4070 int deleteId = myEditPopup.idAt(5);
4072 putInfo( tr("PRP_DESK_EDIT_DELETE") );
4074 if (component == getComponentUserName("SUPERV") ) {
4075 int newDFId = myEditPopup.idAt(5);
4076 int modifyDFId = myEditPopup.idAt(6);
4078 putInfo( tr("PRP_DESK_EDIT_NEWDF") );
4079 if (id == modifyDFId)
4080 putInfo( tr("PRP_DESK_EDIT_MODIFYDF") );
4085 /* Update status bar for View menu items */
4086 void QAD_Desktop::onViewPopupStatusText( int id )
4088 QString component = getActiveComponent();
4090 if (component != "") {
4091 //one of the modules is active now
4092 int DispModeId = myViewPopup.idAt(2);
4094 if (component == getComponentUserName("GEOM")) {
4095 if (id == DispModeId)
4096 putInfo( tr("PRP_DESK_VIEW_DISPLAYMODE") );
4098 if (component == getComponentUserName("SMESH")) {
4099 int updateId = myViewPopup.idAt(3);
4101 if (id == DispModeId)
4102 putInfo( tr("PRP_DESK_VIEW_DISPLAYMODE") );
4104 putInfo( tr("PRP_DESK_VIEW_UPDATE") );
4109 /* Processes additinal key accelerators, e.g. viewer incremental transfomrations */
4110 void QAD_Desktop::onKeyAccel( int id )
4112 if ( myAccelMap.find( id ) != myAccelMap.end() ) {
4113 int cmd = myAccelMap[ id ];
4114 if ( myActiveApp != 0 && myActiveApp->getActiveStudy() != 0 && myActiveApp->getActiveStudy()->getActiveStudyFrame() != 0 ) {
4115 QAD_ViewFrame* vf = myActiveApp->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
4142 vf->onRotateRight();
4155 /*********************************************************************
4156 ** Class: AppSelectionDlg
4157 ** Descr: Dialog for the selection of the application when several
4158 ** applications exist in the desktop and new study creation
4159 ** is activated by user.
4161 **********************************************************************/
4163 \class Desktop_AppSelectionDlg QAD_Desktop.h
4164 \brief Dialog for the selection of the application when several
4165 applications exist in the desktop and new study creation
4166 is activated by user.
4171 Desktop_AppSelectionDlg::Desktop_AppSelectionDlg( QAD_Desktop* desktop,
4172 QList<QAD_Application>& apps ) :
4173 QDialog( desktop, 0, true ),
4177 QAD_ASSERT_DEBUG_ONLY ( desktop );
4178 setCaption( tr("INF_DESK_DOC_CREATE") );
4179 if ( desktop->icon() )
4180 setIcon( *desktop->icon() );
4182 QBoxLayout* mainLayout = new QVBoxLayout( this, 5 );
4184 /* Create selection buttons */
4185 QVButtonGroup* buttonGrp = new QVButtonGroup ( this );
4186 buttonGrp->setExclusive ( true );
4187 QBoxLayout* vLayout = new QVBoxLayout( mainLayout, 5 );
4188 vLayout->addWidget ( buttonGrp );
4190 /* Create selection button for available app */
4192 for ( QAD_Application* app = myApps.first(); app; app = myApps.next(), id++ )
4194 /* add radio button for application */
4195 buttonGrp->insert( new QRadioButton( app->getStudyDescription() +
4196 " (*." + app->getStudyExtension() + ")", buttonGrp ), id );
4199 /* make the first application selected */
4200 buttonGrp->setButton( 0 );
4202 /* listen to the selection */
4203 QAD_ASSERT ( connect ( buttonGrp, SIGNAL(clicked(int)), this, SLOT(onAppSelected(int)) ));
4205 /* Create OK/Cancel buttons
4207 QBoxLayout* hLayout = new QHBoxLayout( mainLayout, 5 );
4208 QPushButton* buttonOK = new QPushButton( tr("BUT_OK"), this );
4209 QPushButton* buttonCancel = new QPushButton( tr("BUT_CANCEL"), this );
4210 QPushButton* buttonHelp = new QPushButton( tr("BUT_HELP"), this );
4211 buttonOK->setDefault( true );
4213 hLayout->addStretch();
4214 hLayout->addWidget( buttonOK );
4215 hLayout->addWidget( buttonCancel );
4216 hLayout->addWidget( buttonHelp );
4218 /* connect buttons */
4219 QAD_ASSERT ( connect( buttonOK, SIGNAL(clicked()), this, SLOT(accept())) );
4220 QAD_ASSERT ( connect( buttonCancel, SIGNAL(clicked()), this, SLOT(reject())) );
4221 QAD_ASSERT ( connect( buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())) );
4223 /* disable resizing */
4224 setFixedSize( 0, 0 );
4225 setSizePolicy( QSizePolicy ( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
4228 Desktop_AppSelectionDlg::~Desktop_AppSelectionDlg()
4232 QAD_Application* Desktop_AppSelectionDlg::selectedApp() const
4234 return myApps.at( myAppId );
4237 void Desktop_AppSelectionDlg::resizeEvent( QResizeEvent* e )
4239 QAD_Tools::centerWidget( this, parentWidget() );
4245 void Desktop_AppSelectionDlg::onAppSelected( int id )
4250 void Desktop_AppSelectionDlg::onHelp()