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.
34 # include "Utils_ORB_INIT.hxx"
35 # include "Utils_SINGLETON.hxx"
37 #define INCLUDE_MENUITEM_DEF
41 #include "QAD_Tools.h"
42 #include "QAD_Desktop.h"
43 #include "QAD_LeftFrame.h"
44 #include "QAD_RightFrame.h"
45 #include "QAD_Operation.h"
46 #include "QAD_XmlHandler.h"
47 #include "QAD_MessageBox.h"
48 #include "QAD_Application.h"
49 #include "QAD_Settings.h"
50 #include "QAD_Config.h"
51 #include "QAD_ObjectBrowser.h"
52 #include "QAD_Resource.h"
53 #include "QAD_FileDlg.h"
54 #include "QAD_HelpWindow.h"
55 #include "QAD_DirListDlg.h"
56 #include "QAD_WaitCursor.h"
57 #include "SALOMEGUI_OpenWith.h"
58 #include "SALOMEGUI_StudyPropertiesDlg.h"
59 #include "SALOMEGUI_TrihedronSizeDlg.h"
60 #include "SALOMEGUI_LoadStudiesDlg.h"
61 #include "SALOME_Selection.h"
62 #include "SALOME_InteractiveObject.hxx"
63 #include "SALOME_ListIteratorOfListIO.hxx"
64 #include "SALOMEGUI_AboutDlg.h"
65 #include "SALOMEGUI_ViewChoiceDlg.h"
66 #include "utilities.h"
68 #include "SALOMEGUI_CloseDlg.h"
73 #include <qmessagebox.h>
74 #include <qcolordialog.h>
75 #include <qradiobutton.h>
76 #include <qapplication.h>
77 #include <qvbuttongroup.h>
79 #include <qmessagebox.h>
82 #include <qpopupmenu.h>
83 #include <qlistview.h>
87 #include <qfontdialog.h>
88 #include <qlineedit.h>
89 #include <qdatetime.h>
96 // Open CASCADE Includes
97 #include <OSD_LoadMode.hxx>
98 #include <OSD_Function.hxx>
99 #include <TCollection_AsciiString.hxx>
101 static const char* SEPARATOR = ":";
108 QAD_ResourceMgr* QAD_Desktop::resourceMgr = 0;
109 QPalette* QAD_Desktop::palette = 0;
113 Creates the resource manager [ static ]
115 QAD_ResourceMgr* QAD_Desktop::createResourceManager()
118 resourceMgr = new QAD_ResourceMgr;
123 Returns the resource manager [ static ]
125 QAD_ResourceMgr* QAD_Desktop::getResourceManager()
132 Loads the palette from settings [ static ]
134 QPalette* QAD_Desktop::createPalette()
137 palette = new QPalette();
143 Returns the palette [ static ]
145 QPalette* QAD_Desktop::getPalette()
151 Gets window ratio width/heght [ static ]
153 static double myWindowRatio = 1;
154 static double getWindowRatio()
156 return myWindowRatio;
160 Sets window ratio width/heght [ static ]
162 static void setWindowRatio(double aRatio)
164 myWindowRatio = aRatio;
170 QAD_Desktop::QAD_Desktop(SALOME_NamingService* name_service) :
171 QMainWindow(0, 0, WType_TopLevel | WDestructiveClose),
178 myDefaultTitle( tr("DESK_DEFAULTTITLE") ),
181 /* Force reading of user config file */
182 QAD_CONFIG->readConfigFile();
184 /* menubar and status bar */
185 myStatusBar = statusBar();
186 myMainMenu = menuBar();
188 myNameService = name_service;
190 /* default background icon */
191 QPixmap backgroundicon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
192 tr("ICON_DESK_BACKGROUNDICON") ));
193 //myToolBarAction.setAutoDelete( true );
195 /* default icon and title */
196 QPixmap icon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
197 tr("ICON_DESK_DEFAULTICON") ));
198 if ( !icon.isNull() ) {
199 myDefaultIcon = icon;
200 setIcon( myDefaultIcon );
202 setCaption( myDefaultTitle );
204 /* set size as 1/2 of the screen and center it */
205 QWidget* d = QApplication::desktop();
206 resize( 2*d->width()/3, 2*d->height()/3 );
207 QAD_Tools::centerWidget( this, d );
209 /* workspace will manage child frames */
210 QHBox* border = new QHBox ( this );
211 border->setFrameStyle ( QFrame::Panel | QFrame::Sunken );
212 setCentralWidget( border );
213 myWorkspace = new QWorkspaceP( border );
215 QPalette pal = QAD_Application::getPalette();
217 QColorGroup cgA = pal.active();
218 QColorGroup cgI = pal.inactive();
219 QColorGroup cgD = pal.disabled();
220 cgA.setColor( QColorGroup::Background, QColor(192, 192, 192));
221 cgI.setColor( QColorGroup::Background, QColor(192, 192, 192));
222 cgD.setColor( QColorGroup::Background, QColor(192, 192, 192));
223 pal.setActive ( cgA );
224 pal.setInactive( cgI );
225 pal.setDisabled( cgD );
226 myWorkspace->setPalette( pal );
227 if ( !backgroundicon.isNull() ) {
228 MESSAGE("!!!DESKTOP background icon found!!!");
229 myWorkspace->setPaletteBackgroundPixmap(backgroundicon);
232 /* define standard file commands */
235 /* define operator menus for xml */
236 myOperatorMenus = new QAD_OperatorMenus(this);
237 myXmlHandler = new QAD_XmlHandler();
240 CORBA::Object_var objVarN = myNameService->Resolve("/Kernel/ModulCatalog");
241 myCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
243 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants =
244 myCatalogue->GetComponentIconeList();
247 QToolBar* tbComponent = new QToolBar( tr("MEN_DESK_COMPONENTTOOLBAR"), this );
248 tbComponent->setCloseMode( QDockWindow::Undocked );
249 addToolBar(tbComponent, tr("MEN_DESK_COMPONENTTOOLBAR"), Bottom, TRUE );
250 setDockEnabled( tbComponent, DockLeft, false );
251 setDockEnabled( tbComponent, DockRight, false );
253 myCombo = new QComboBox( FALSE, tbComponent, "comboBox" );
254 myCombo->setFocusPolicy( NoFocus );
256 tbComponent->addSeparator();
258 // PG : add ResourceManager to get function findFile !!
259 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
261 for (unsigned int ind = 0; ind < list_composants->length();ind++) {
264 /* find component icon */
265 QString iconfile = strdup(list_composants[ind].moduleicone) ;
266 QString modulename = strdup(list_composants[ind].modulename) ;
267 QString moduleusername = strdup(list_composants[ind].moduleusername) ;
269 // MESSAGE ( " MODULE = " << modulename )
270 // MESSAGE ( " MODULE icon = " << iconfile )
271 // MESSAGE ( " MODULE username = " << moduleusername )
273 if ( mapComponentName.contains( moduleusername ) ) {
274 QMessageBox::warning( this, tr("WRN_WARNING"), QString( moduleusername + " is already associated with " + mapComponentName[moduleusername] + ".\nPlease, change the component username of " + modulename) , tr ("BUT_OK") );
277 mapComponentName.insert( moduleusername, modulename );
279 resDir = resMgr->findFile(iconfile,modulename) ;
282 MESSAGE ( "resDir" << resDir )
283 //resDir = QAD_Tools::addSlash(resDir) ;
284 //QPixmap Icone(resDir+iconfile) ;
285 QPixmap Icone( QAD_Tools::addSlash( resDir ) + iconfile );
286 QToolButton * toolb =
287 new QToolButton( QIconSet( Icone ), moduleusername, QString::null, this,
288 SLOT( onButtonActiveComponent () ),tbComponent );
289 toolb->setToggleButton( true );
290 myComponentButton.append(toolb);
294 QString errMsg = tr("INF_ICON_RESOURCES").arg(iconfile).arg(modulename) +
296 //QMessageBox::warning( this, tr("WRN_WARNING"), errMsg, tr ("BUT_OK") );
299 if ( !QString(list_composants[ind].modulename).isEmpty() )
300 myCombo->insertItem( strdup(list_composants[ind].moduleusername) );
304 myCombo->adjustSize();
305 connect( myCombo, SIGNAL(activated(const QString&)),
306 this, SLOT( onComboActiveComponent(const QString&) ) );
308 /* new LifeCycleCORBA client, for Engines */
309 myEnginesLifeCycle = new SALOME_LifeCycleCORBA(name_service);
311 /* VSR 13/01/03 : installing global event filter for the application */
312 qApp->installEventFilter( this );
314 /* init pseudo random numbers generator */
315 QTime cTime = QTime::currentTime();
316 int secs = cTime.second() + 1;
317 for ( int s = 0; s < secs; s++ ) random();
323 QAD_Desktop::~QAD_Desktop ()
325 qApp->removeEventFilter( this );
329 myObjBrowserPopup.clear();
330 //VRV: T2.5 - add default viewer
331 myDefaultViewer.clear();
332 //VRV: T2.5 - add default viewer
333 myViewerPopup.clear();
335 myNewViewPopup.clear();
337 myToolsPopup.clear();
339 myStdActions.clear();
341 myToolBarsPopup.clear();
342 myToolBarAction.clear();
346 myHelpWindow->close();
348 QAD_Application::desktop = 0;
351 const int IdCut = 1001;
352 const int IdCopy = 1002;
353 const int IdPaste = 1003;
354 const int IdSelectAll = 1004;
356 #include <qkeysequence.h>
357 #define ACCEL_KEY(k) "\t" + QString(QKeySequence( Qt::CTRL | Qt::Key_ ## k ))
359 #define ACCEL_KEY(k) "\t" + QString("Ctrl+" #k)
361 #include <qclipboard.h>
363 Global event filter for qapplication (VSR 13/01/03)
365 bool QAD_Desktop::eventFilter( QObject* o, QEvent* e )
367 if ( e->type() == QEvent::ContextMenu ) {
368 QContextMenuEvent* ce = (QContextMenuEvent*)e;
369 if ( o->inherits("QRenameEdit") ) {
372 else if ( o->inherits("QLineEdit") ) {
373 QLineEdit* le = (QLineEdit*)o;
374 if ( le->parentWidget() ) {
375 if ( ( le->parentWidget()->inherits("QSpinBox") ||
376 le->parentWidget()->inherits("QSpinWidget") ||
377 le->parentWidget()->inherits("QAD_SpinBoxDbl") ) &&
379 QPopupMenu* popup = new QPopupMenu( 0, "qt_edit_menu" );
380 popup->insertItem( tr( "EDIT_CUT_CMD" ) + ACCEL_KEY( X ), IdCut );
381 popup->insertItem( tr( "EDIT_COPY_CMD" ) + ACCEL_KEY( C ), IdCopy );
382 popup->insertItem( tr( "EDIT_PASTE_CMD" ) + ACCEL_KEY( V ), IdPaste );
383 popup->insertSeparator();
384 #if defined(Q_WS_X11)
385 popup->insertItem( tr( "EDIT_SELECTALL_CMD" ), IdSelectAll );
387 popup->insertItem( tr( "EDIT_SELECTALL_CMD" ) + ACCEL_KEY( A ), IdSelectAll );
389 bool enableCut = !le->isReadOnly() && le->hasSelectedText();
390 popup->setItemEnabled( IdCut, enableCut );
391 popup->setItemEnabled( IdCopy, le->hasSelectedText() );
392 bool enablePaste = !le->isReadOnly() && !QApplication::clipboard()->text().isEmpty();
393 popup->setItemEnabled( IdPaste, enablePaste );
394 bool allSelected = (le->selectedText() == le->text() );
395 popup->setItemEnabled( IdSelectAll, (bool)(le->text().length()) && !allSelected );
397 QPoint pos = ce->reason() == QContextMenuEvent::Mouse ? ce->globalPos() :
398 le->mapToGlobal( QPoint(ce->pos().x(), 0) ) + QPoint( le->width() / 2, le->height() / 2 );
400 int r = popup->exec( pos );
422 return QMainWindow::eventFilter( o, e );
426 Creates and initializes the standard file operations
427 such as 'New/Open/Save/SaveAs/Close' and 'Help'.
429 void QAD_Desktop::createActions()
432 /* Used for string compare */
433 const QString& aTrueQString = "true" ;
435 /* create 'standard' toolbar */
436 if ( !myStdToolBar ) {
437 myStdToolBar = new QToolBar ( tr("MEN_DESK_VIEW_STDTOOLBAR"), this );
438 myStdToolBar->setCloseMode( QDockWindow::Undocked );
441 if ( !myMainMenu->count() ) {
442 /* Create main menu bar */
443 myMainMenu->insertItem ( tr("MEN_DESK_FILE"), &myFilePopup, 1 ); /* add popup FILE */
444 myMainMenu->insertItem ( tr("MEN_DESK_VIEW"), &myViewPopup, 2 ); /* add popup VIEW */
445 myMainMenu->insertItem ( tr("MEN_DESK_TOOLS"), &myToolsPopup, 5 ); /* add popup TOOLS */
446 myMainMenu->insertItem ( tr("MEN_DESK_PREF"), &myPrefPopup, 4 ); /* add popup PREF */
447 myMainMenu->insertItem ( tr("MEN_DESK_WINDOW"), &myWindowPopup, 6 ); /* add popup WINDOW */
448 myMainMenu->insertItem ( tr("MEN_DESK_HELP"), &myHelpPopup, 7 ); /* add popup HELP */
450 /* Applications will insert their items after 'File' 'Edit' and 'View'
451 ( 'Edit' will be inserted later )
456 /* insert logo picture to menu bar */
457 QHBox* aLogoFrm = new QHBox(this);
458 aLogoFrm->setFrameStyle( QFrame::Plain | QFrame::NoFrame );
459 QPixmap aLogoPixmap ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
460 tr("ICON_DESK_LOGO") ));
461 QLabel* aLogoLab = new QLabel(aLogoFrm);
462 aLogoLab->setPixmap(aLogoPixmap);
463 aLogoLab->setAlignment(AlignCenter);
464 aLogoLab->setScaledContents(false);
465 myMainMenu->insertItem(aLogoFrm);
467 if ( myStdActions.isEmpty() ) {
468 /* Define standard actions. They should be inserted
469 into the list in order of their IDs.
474 QAD_ResourceMgr* rmgr = QAD_Desktop::getResourceManager();
475 QActionP* fileNewAction = new QActionP ( tr("TOT_DESK_FILE_NEW"),
476 rmgr->loadPixmap( "QAD", tr("ICON_FILE_NEW") ) ,
477 tr("MEN_DESK_FILE_NEW"), CTRL+Key_N, this );
478 fileNewAction->setStatusTip ( tr("PRP_DESK_FILE_NEW") );
479 fileNewAction->setEnabled ( true );
480 QAD_ASSERT ( connect( fileNewAction, SIGNAL( activated() ), this, SLOT( onNewStudy() )));
481 fileNewAction->addTo( myStdToolBar );
482 fileNewAction->addTo( &myFilePopup );
483 myStdActions.insert ( FileNewId, fileNewAction );
486 QActionP* fileOpenAction = new QActionP( tr("TOT_DESK_FILE_OPEN"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_OPEN") ),
487 tr("MEN_DESK_FILE_OPEN"), CTRL+Key_O, this );
488 fileOpenAction->setStatusTip ( tr("PRP_DESK_FILE_OPEN") );
489 fileOpenAction->setEnabled ( true );
490 QAD_ASSERT ( connect( fileOpenAction, SIGNAL( activated() ), this, SLOT( onOpenStudy() )));
491 fileOpenAction->addTo( myStdToolBar );
492 fileOpenAction->addTo( &myFilePopup );
493 myStdActions.insert ( FileOpenId, fileOpenAction );
496 QActionP* fileLoadAction = new QActionP( tr("TOT_DESK_FILE_LOAD"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_LOAD") ),
497 tr("MEN_DESK_FILE_LOAD"), CTRL+Key_L, this );
498 fileLoadAction->setStatusTip ( tr("PRP_DESK_FILE_LOAD") );
499 fileLoadAction->setEnabled ( true );
500 QAD_ASSERT ( connect( fileLoadAction, SIGNAL( activated() ), this, SLOT( onLoadStudy() )));
501 fileLoadAction->addTo( &myFilePopup );
502 myStdActions.insert ( FileLoadId, fileLoadAction );
505 QActionP* fileCloseAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_FILE_CLOSE") ),
506 tr("MEN_DESK_FILE_CLOSE"), CTRL+Key_W, this );
507 fileCloseAction->setStatusTip ( tr("PRP_DESK_FILE_CLOSE") );
508 QAD_ASSERT ( connect( fileCloseAction, SIGNAL( activated() ), this, SLOT( onCloseStudy() )));
509 fileCloseAction->addTo( &myFilePopup );
510 myStdActions.insert ( FileCloseId, fileCloseAction );
513 myFilePopup.insertSeparator();
516 QActionP* fileSaveAction = new QActionP( tr("TOT_DESK_FILE_SAVE"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_SAVE") ),
517 tr("MEN_DESK_FILE_SAVE"), CTRL+Key_S, this );
518 fileSaveAction->setStatusTip ( tr("PRP_DESK_FILE_SAVE") );
519 QAD_ASSERT ( connect( fileSaveAction, SIGNAL( activated() ), this, SLOT( onSaveStudy() )));
520 fileSaveAction->addTo( myStdToolBar );
521 fileSaveAction->addTo( &myFilePopup );
522 myStdActions.insert ( FileSaveId, fileSaveAction );
525 QActionP* fileSaveAsAction = new QActionP( "", tr("MEN_DESK_FILE_SAVEAS"), 0, this );
526 fileSaveAsAction->setStatusTip ( tr("PRP_DESK_FILE_SAVEAS") );
527 QAD_ASSERT ( connect( fileSaveAsAction, SIGNAL( activated() ),
528 this, SLOT( onSaveAsStudy() )));
529 fileSaveAsAction->addTo( &myFilePopup );
530 myStdActions.insert ( FileSaveAsId, fileSaveAsAction );
534 myFilePopup.insertSeparator();
537 QActionP* filePropsAction = new QActionP( "", QPixmap(), tr("MEN_DESK_FILE_PROPERTIES"), 0, this );
538 filePropsAction->setStatusTip ( tr("PRP_DESK_FILE_PROPERTIES") );
539 filePropsAction->setEnabled(false);
540 QAD_ASSERT ( connect( filePropsAction, SIGNAL( activated() ), this, SLOT( onStudyProperties() )));
541 filePropsAction->addTo( &myFilePopup );
542 myStdActions.insert ( FilePropsId, filePropsAction );
545 int id = myFilePopup.insertSeparator();
546 /* keep the position from which an application will insert its items
547 to menu 'File' at the time of customization of the desktop */
549 myFilePos = myFilePopup.indexOf( id ) + 1;
551 /* exit application */
552 QActionP* exitAction = new QActionP( "", tr("MEN_DESK_FILE_EXIT"),
554 exitAction->setStatusTip ( tr("PRP_DESK_FILE_EXIT") );
555 QAD_ASSERT ( connect( exitAction, SIGNAL( activated() ),
556 this, SLOT( onExit() )));
557 exitAction->addTo( &myFilePopup );
558 myStdActions.insert ( FileExitId, exitAction );
560 /* 'Edit' actions : provided by application only */
564 /* toolbars popup menu */
565 myViewPopup.insertItem( tr("MEN_DESK_VIEW_TOOLBARS"), &myToolBarsPopup );
566 QAD_ASSERT( connect ( &myViewPopup, SIGNAL(aboutToShow()),
567 this, SLOT(onToolBarPopupAboutToShow()) ));
570 QActionP* viewStatusBarAction = new QActionP( "",
571 tr("MEN_DESK_VIEW_STATUSBAR"),
573 viewStatusBarAction->setStatusTip ( tr("PRP_DESK_VIEW_STATUSBAR") );
574 viewStatusBarAction->setOn( true );
575 QAD_ASSERT(connect( viewStatusBarAction, SIGNAL(activated()), this, SLOT(onViewStatusBar() )));
576 viewStatusBarAction->addTo( &myViewPopup );
577 myStdActions.insert( ViewStatusBarId, viewStatusBarAction );
579 // myViewPopup.insertItem( tr("MEN_DESK_SELECTION_MODE"), &mySelectionModePopup );
581 QActionP* SelectionPointAction = new QActionP( "", tr("MEN_DESK_SELECTION_POINT"), 0, this, 0, true );
582 QAD_ASSERT(connect( SelectionPointAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
583 SelectionPointAction->addTo( &mySelectionModePopup );
584 myStdActions.insert( SelectionPointId, SelectionPointAction );
586 QActionP* SelectionEdgeAction = new QActionP( "", tr("MEN_DESK_SELECTION_EDGE"), 0, this, 0, true );
587 QAD_ASSERT(connect( SelectionEdgeAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
588 SelectionEdgeAction->addTo( &mySelectionModePopup );
589 myStdActions.insert( SelectionEdgeId, SelectionEdgeAction );
591 QActionP* SelectionCellAction = new QActionP( "", tr("MEN_DESK_SELECTION_CELL"), 0, this, 0, true );
592 QAD_ASSERT(connect( SelectionCellAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
593 SelectionCellAction->addTo( &mySelectionModePopup );
594 myStdActions.insert( SelectionCellId, SelectionCellAction );
596 QActionP* SelectionActorAction = new QActionP( "", tr("MEN_DESK_SELECTION_ACTOR"), 0, this, 0, true );
597 QAD_ASSERT(connect( SelectionActorAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
598 SelectionActorAction->addTo( &mySelectionModePopup );
599 myStdActions.insert( SelectionActorId, SelectionActorAction );
600 SelectionActorAction->setOn(true);
602 myViewPos = myViewPopup.count();
605 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
608 if(!resMgr->loadResources( "ToolsGUI", msg ))
610 //NRI QCString errMsg;
611 // errMsg.sprintf( "Do not load all resources for module ToolsGUI.\n" );
612 QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
616 myOperatorMenus = new QAD_OperatorMenus(this);
617 myXmlHandler = new QAD_XmlHandler();
618 ASSERT(myXmlHandler) ;
619 myXmlHandler->setMainWindow(this);
620 if ( myXmlHandler->setComponent( resMgr->resources( "ToolsGUI" ) ) ) {
621 QString language = resMgr->language( "ToolsGUI" );
622 QString ToolsXml = QString( "Tools_" ) + language + QString( ".xml" );
624 //ToolsXml = resMgr->resources("ToolsGUI") ;
625 //ToolsXml = QAD_Tools::addSlash(ToolsXml) ;
626 //ToolsXml = ToolsXml + "Tools_" + language + ".xml" ;
627 ToolsXml = QAD_Tools::addSlash( resMgr->findFile( ToolsXml, "ToolsGUI" ) ) + ToolsXml;
629 QFile file( QAD_Tools::unix2win( ToolsXml ) );
630 if ( file.exists() && file.open( IO_ReadOnly ) ) {
632 QXmlInputSource source( file );
633 QXmlSimpleReader reader;
634 reader.setContentHandler( myXmlHandler );
635 reader.setErrorHandler( myXmlHandler );
636 bool ok = reader.parse( source );
639 QMessageBox::critical( 0,
640 tr( "INF_PARSE_ERROR" ),
641 tr( myXmlHandler->errorProtocol() ) );
643 myMenusList=myXmlHandler->myMenusList;
644 myActiveMenus=myMenusList.at(0);
645 myOperatorMenus->showMenuBar(0);
646 myActiveMenus->showAllToolBars();
652 if ( myToolsPopup.count() == 0 ) {
653 myMainMenu->removeItem(5);
657 /* Viewer BackgroundColor */
658 myPrefPopup.insertItem( tr("MEN_DESK_PREF_VIEWER"), &myViewerPopup );
660 QActionP* viewerOCCAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this );
661 QAD_ASSERT(connect( viewerOCCAction, SIGNAL(activated()), this, SLOT(onViewerOCC() )));
662 viewerOCCAction->addTo( &myViewerPopup );
663 myStdActions.insert( PrefViewerOCCId, viewerOCCAction );
665 QActionP* viewerVTKAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this );
666 QAD_ASSERT(connect( viewerVTKAction, SIGNAL(activated()), this, SLOT(onViewerVTK() )));
667 viewerVTKAction->addTo( &myViewerPopup );
668 myStdActions.insert( PrefViewerVTKId, viewerVTKAction );
670 QActionP* graphSupervisorAction = new QActionP( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this );
671 QAD_ASSERT(connect( graphSupervisorAction, SIGNAL(activated()), this, SLOT(onGraphSupervisor() )));
672 graphSupervisorAction->addTo( &myViewerPopup );
673 myStdActions.insert( PrefGraphSupervisorId, graphSupervisorAction );
675 QActionP* viewerPlot2dAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this );
676 QAD_ASSERT(connect( viewerPlot2dAction, SIGNAL(activated()), this, SLOT(onPlot2d() )));
677 viewerPlot2dAction->addTo( &myViewerPopup );
678 myStdActions.insert( PrefViewerPlot2dId, viewerPlot2dAction );
680 //VRV: T2.5 - add default viewer
681 QString viewerValue = QAD_CONFIG->getSetting( "Viewer:DefaultViewer" );
683 int aViewerValue = viewerValue.toInt( &ok, 10 );
684 if (!ok || aViewerValue < VIEW_OCC || aViewerValue >= VIEW_TYPE_MAX)
685 aViewerValue = VIEW_VTK;
687 myPrefPopup.insertItem( tr("MEN_DESK_PREF_DEFAULT_VIEWER"), &myDefaultViewer );
688 QActionPGroup* myQAG = new QActionPGroup ( this);
689 QActionP* viewerOCCAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this );
690 viewerOCCAction1->setToggleAction ( true);
691 viewerOCCAction1->setOn ( aViewerValue == VIEW_OCC );
692 myQAG->insert( viewerOCCAction1 );
693 myStdActions.insert( DefaultViewerOCCId, viewerOCCAction1 );
695 QActionP* viewerVTKAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this );
696 viewerVTKAction1->setToggleAction ( true);
697 viewerVTKAction1->setOn ( aViewerValue == VIEW_VTK );
698 myQAG->insert( viewerVTKAction1 );
699 myStdActions.insert( DefaultViewerVTKId, viewerVTKAction1 );
701 /* Remove Supervisor viewer from setting the background */
702 // QActionP* graphSupervisorAction1 = new QActionP( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this );
703 // graphSupervisorAction1->setToggleAction ( true);
704 // graphSupervisorAction1->setOn ( aViewerValue == VIEW_GRAPHSUPERV );
705 // myQAG->insert( graphSupervisorAction1 );
706 // myStdActions.insert( DefaultGraphSupervisorId, graphSupervisorAction1 );
708 QActionP* viewerPlot2dAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this );
709 viewerPlot2dAction1->setToggleAction ( true);
710 viewerPlot2dAction1->setOn ( aViewerValue == VIEW_PLOT2D );
711 myQAG->insert( viewerPlot2dAction1 );
712 myStdActions.insert( DefaultPlot2dId, viewerPlot2dAction1 );
714 myQAG->addTo( &myDefaultViewer );
715 QAD_ASSERT(connect( myQAG, SIGNAL(selected(QActionP * )), this, SLOT(onDefaultViewer(QActionP *) )));
716 //VRV: T2.5 - add default viewer
718 QActionP* viewerTrihedronAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_TRIHEDRON"), 0, this );
719 QAD_ASSERT(connect( viewerTrihedronAction, SIGNAL(activated()), this, SLOT(onViewerTrihedron() )));
720 viewerTrihedronAction->addTo( &myPrefPopup );
721 myStdActions.insert( PrefViewerTrihedronId, viewerTrihedronAction );
723 QActionP* consoleFontAction = new QActionP( "", tr("MEN_DESK_PREF_CONSOLE_FONT"), 0, this );
724 QAD_ASSERT(connect( consoleFontAction, SIGNAL(activated()), this, SLOT(onConsoleFontAction() )));
725 consoleFontAction->addTo( &myPrefPopup );
726 myStdActions.insert( PrefConsoleFontId, consoleFontAction );
729 QActionP* multiFileSaveAction = new QActionP( "", tr("MEN_DESK_PREF_MULTI_FILE_SAVE"), 0, this, 0, true );
730 QAD_ASSERT(connect( multiFileSaveAction, SIGNAL(activated()), this, SLOT(onMultiFileSave() )));
731 multiFileSaveAction->setToggleAction( true );
732 QString MultiSave = QAD_CONFIG->getSetting("Desktop:MultiFileSave");
733 multiFileSaveAction->setOn( MultiSave.compare( aTrueQString ) == 0 );
734 multiFileSaveAction->addTo( &myPrefPopup );
735 myStdActions.insert( PrefMultiFileSave, multiFileSaveAction );
738 QActionP* ASCIISaveAction = new QActionP( "", tr("MEN_DESK_PREF_ASCII_SAVE"), 0, this, 0, true );
739 QAD_ASSERT(connect( ASCIISaveAction, SIGNAL(activated()), this, SLOT(onASCIISave() )));
740 ASCIISaveAction->setToggleAction( true );
741 QString ASCIISave = QAD_CONFIG->getSetting("Desktop:ASCIISave");
742 ASCIISaveAction->setOn( ASCIISave.compare( aTrueQString ) == 0 );
743 ASCIISaveAction->addTo( &myPrefPopup );
744 myStdActions.insert( PrefASCIISave, ASCIISaveAction );
746 myPrefPopup.insertSeparator();
749 myPrefPopup.insertItem( tr("MEN_DESK_PREF_OBJECTBROWSER"), &myObjBrowserPopup );
751 QActionP* objectBrowserEntryAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_ENTRY"), 0, this, 0, true );
752 QAD_ASSERT(connect( objectBrowserEntryAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
753 objectBrowserEntryAction->setToggleAction(true);
754 QString AddColumn = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn");
756 if ( AddColumn.compare( aTrueQString ) == 0 )
757 objectBrowserEntryAction->setOn(true);
759 objectBrowserEntryAction->setOn(false);
761 objectBrowserEntryAction->addTo( &myObjBrowserPopup );
762 myStdActions.insert( PrefObjectBrowserEntryId, objectBrowserEntryAction );
764 QActionP* objectBrowserValueAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_VALUE"), 0, this, 0, true );
765 QAD_ASSERT(connect( objectBrowserValueAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
766 objectBrowserValueAction->setToggleAction(true);
767 QString ValueColumn = QAD_CONFIG->getSetting("ObjectBrowser:ValueColumn");
769 if ( ValueColumn.compare( aTrueQString ) == 0 )
770 objectBrowserValueAction->setOn(true);
772 objectBrowserValueAction->setOn(false);
774 objectBrowserValueAction->addTo( &myObjBrowserPopup );
775 myStdActions.insert( PrefObjectBrowserValueId, objectBrowserValueAction );
777 QActionP* objectBrowserIAPPAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_IAPP"), 0, this, 0, true );
778 QAD_ASSERT(connect( objectBrowserIAPPAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
779 objectBrowserIAPPAction->setToggleAction(true);
780 QString showIAPP = QAD_CONFIG->getSetting("ObjectBrowser:IAPP");
782 if ( showIAPP.compare( aTrueQString ) == 0 )
783 objectBrowserIAPPAction->setOn(true);
785 objectBrowserIAPPAction->setOn(false);
787 objectBrowserIAPPAction->addTo( &myObjBrowserPopup );
788 myStdActions.insert( PrefObjectBrowserIAPPId, objectBrowserIAPPAction );
790 /* Chronological sorting of shapes on the entry creation */
791 QActionP* objectBrowserCHRONO_SORTAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_CHRONO_SORT"), 0, this, 0, true );
792 QAD_ASSERT(connect( objectBrowserCHRONO_SORTAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
793 objectBrowserCHRONO_SORTAction->setToggleAction(true);
794 QString showSORT = QAD_CONFIG->getSetting("ObjectBrowser:CHRONO_SORT");
796 if ( showSORT.compare( aTrueQString ) == 0 )
797 objectBrowserCHRONO_SORTAction->setOn(true) ;
799 objectBrowserCHRONO_SORTAction->setOn(false) ;
801 objectBrowserCHRONO_SORTAction->addTo( &myObjBrowserPopup );
802 myStdActions.insert( PrefObjectBrowserCHRONO_SORTId, objectBrowserCHRONO_SORTAction ) ;
804 myPrefPopup.insertSeparator();
806 QActionP* dirAction = new QActionP( "", tr("MEN_DESK_PREF_DIRICTORIES"), ALT+Key_D, this );
807 QAD_ASSERT(connect( dirAction, SIGNAL(activated()), this, SLOT(onDirList() )));
808 dirAction->addTo( &myPrefPopup );
809 myStdActions.insert( PrefDirsId, dirAction );
811 myPrefPopup.insertSeparator();
813 QActionP* saveAction = new QActionP( "", tr("MEN_DESK_PREF_SAVE"), 0, this );
814 QAD_ASSERT(connect( saveAction, SIGNAL(activated()), this, SLOT(onSavePref() )));
815 saveAction->addTo( &myPrefPopup );
816 myStdActions.insert( PrefSaveId, saveAction );
818 /* 'Window' actions */
821 myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId );
823 QActionP* viewOCCAction = new QActionP( "", tr("MEN_DESK_VIEW_OCC"), ALT+Key_O, this );
824 QAD_ASSERT(connect( viewOCCAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
825 viewOCCAction->addTo( &myNewViewPopup );
826 myStdActions.insert( ViewOCCId, viewOCCAction );
828 QActionP* viewVTKAction = new QActionP( "", tr("MEN_DESK_VIEW_VTK"), ALT+Key_K, this );
829 QAD_ASSERT(connect( viewVTKAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
830 viewVTKAction->addTo( &myNewViewPopup );
831 myStdActions.insert( ViewVTKId, viewVTKAction );
833 QActionP* viewPlot2dAction = new QActionP( "", tr("MEN_DESK_VIEW_PLOT2D"), ALT+Key_P, this );
834 QAD_ASSERT(connect( viewPlot2dAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
835 viewPlot2dAction->addTo( &myNewViewPopup );
836 myStdActions.insert( ViewPlot2dId, viewPlot2dAction );
838 // QActionP* windowNew3dAction = new QActionP( "",/* rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_NEW3D") ), */
839 /*tr("MEN_DESK_WINDOW_NEW3D"), 0, this );
840 windowNew3dAction->addTo( &myWindowPopup );
841 QAD_ASSERT( connect( windowNew3dAction, SIGNAL(activated()), this ,
842 SLOT( onNewWindow3d() )));
843 myStdActions.insert( WindowNew3dId, windowNew3dAction );
849 QActionP* windowCascadeAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_CASCADE") ),
850 tr("MEN_DESK_WINDOW_CASCADE"), 0, this );
851 windowCascadeAction->setStatusTip ( tr("PRP_DESK_WINDOW_CASCADE") );
852 QAD_ASSERT( connect( windowCascadeAction, SIGNAL(activated()), this,
853 SLOT( onCascade() )));
854 myStdActions.insert( WindowCascadeId, windowCascadeAction );
857 QActionP* windowTileAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_TILE") ),
858 tr("MEN_DESK_WINDOW_TILE"), 0, this );
859 windowTileAction->setStatusTip ( tr("PRP_DESK_WINDOW_TILE") );
860 QAD_ASSERT( connect( windowTileAction, SIGNAL(activated()), myWorkspace, SLOT( tile() )));
861 myStdActions.insert( WindowTileId, windowTileAction );
863 QAD_ASSERT( connect ( &myWindowPopup, SIGNAL(aboutToShow()),
864 this, SLOT(onWindowPopupAboutToShow()) ));
868 QActionP* helpContentsAction = new QActionP( "", tr("MEN_DESK_HELP_CONTENTS"), Key_F1, this );
869 helpContentsAction->setStatusTip ( tr("PRP_DESK_HELP_CONTENTS") );
870 QAD_ASSERT(connect( helpContentsAction, SIGNAL(activated()),
871 this, SLOT( onHelpContents() )));
872 helpContentsAction->addTo( &myHelpPopup );
873 myStdActions.insert( HelpContentsId , helpContentsAction );
876 // QActionP* helpSearchAction = new QActionP( "", tr("MEN_DESK_HELP_SEARCH"), 0, this );
877 // helpSearchAction->setStatusTip ( tr("PRP_DESK_HELP_SEARCH") );
878 // QAD_ASSERT( connect( helpSearchAction, SIGNAL(activated()), this, SLOT( onHelpSearch() )));
879 // helpSearchAction->addTo( &myHelpPopup );
880 // myStdActions.insert( HelpSearchId, helpSearchAction );
883 // QActionP* helpWhatsThisAction = new QActionP( "", tr("MEN_DESK_HELP_WHATSTHIS"), SHIFT+Key_F1, this );
884 // helpWhatsThisAction->setStatusTip ( tr("PRP_DESK_HELP_WHATSTHIS" ));
885 // QAD_ASSERT( connect( helpWhatsThisAction, SIGNAL(activated()), this, SLOT( whatsThis() )));
886 // helpWhatsThisAction->addTo( &myHelpPopup );
887 // myStdActions.insert( HelpWhatsThisId, helpWhatsThisAction );
888 // (void)QWhatsThis::whatsThisButton( myStdToolBar );
890 id = myHelpPopup.insertSeparator();
891 myHelpPos = myHelpPopup.indexOf( id );
894 QActionP* helpAboutAction = new QActionP( "", tr("MEN_DESK_HELP_ABOUT"), 0, this );
895 helpAboutAction->setStatusTip ( tr("PRP_DESK_HELP_ABOUT") );
896 QAD_ASSERT( connect( helpAboutAction, SIGNAL(activated()), this, SLOT( onHelpAbout() )));
897 helpAboutAction->addTo( &myHelpPopup );
898 myStdActions.insert(HelpAboutId, helpAboutAction );
904 Adds the given application into the list of supported applications
906 void QAD_Desktop::addApplication(QAD_Application* app)
908 /* add only if is not already in the list */
909 if ( myApps.findRef( app ) == -1 )
911 myApps.append( app );
913 /* set activation/deactivation listener */
914 QAD_ASSERT ( connect( app, SIGNAL(appActivated(QAD_Application*)),
915 this, SLOT(onActivateApp(QAD_Application*))) );
917 QAD_ASSERT ( connect( app, SIGNAL(appDeactivated(QAD_Application*)),
918 this, SLOT(onDeactivateApp(QAD_Application*))) );
923 Displays the control panel of the application.
924 This function is called when the desktop is shown first time.
926 void QAD_Desktop::showDesktop()
932 Closes Desktop. If <forceClose> is true query for exit will be skipped.
934 void QAD_Desktop::closeDesktop( bool forceClose )
937 myQueryClose = false;
942 Puts the message to the status bar
944 void QAD_Desktop::putInfo ( const QString& msg )
947 //NRI : bug 1209. message is now displayed during 3000 ms
948 myStatusBar->message ( msg, 3000 );
952 Puts the message to the status bar for ms milli-seconds
954 void QAD_Desktop::putInfo ( const QString& msg, int ms )
957 myStatusBar->message ( msg, ms );
961 Returns the standard toolbar
963 QMenuBar* QAD_Desktop::getMainMenuBar() const
969 Returns the standard toolbar
971 QToolBar* QAD_Desktop::getStdToolBar() const
977 Updates desktop panel (menu, toolbar and status bar) according to current state of
978 the application. Calls update() for the active application.
979 The command { UD_ADD_APP or UD_REMOVE_APP ) specifies the desktop components
980 will be changed according to new active application.
981 This function is called after activating new study, closing current study etc.
983 void QAD_Desktop::updateDesktop( UpdateCommand cmd )
986 updateToolBars( cmd );
987 updateStatusBar( cmd );
992 Updates the desktop caption
994 void QAD_Desktop::updateCaption( UpdateCommand cmd )
996 if ( cmd == ActivateApp )
997 { /* application's icon and title */
998 setIcon( myActiveApp->getApplicationIcon() );
999 setCaption( myActiveApp->getApplicationName() );
1002 { /* default icon and title */
1003 setIcon( myDefaultIcon );
1004 setCaption( myDefaultTitle );
1009 Updates status bar when a new application becomes current
1011 void QAD_Desktop::updateStatusBar( UpdateCommand cmd )
1015 bool activate = ( cmd == ActivateApp );
1016 myActiveApp->updateStatusBar ( myStatusBar, activate );
1021 Updates toolbars according to current active application.
1022 This function is called from updateDesktop().
1024 void QAD_Desktop::updateToolBars( UpdateCommand cmd )
1028 bool activate = ( cmd == ActivateApp );
1029 myActiveApp->updateToolBars ( activate );
1034 Updates main menu bar of the application when application is activated
1036 This function is called by updateDesktop()
1038 void QAD_Desktop::updateMenu( UpdateCommand cmd )
1042 bool activate = ( cmd == ActivateApp );
1043 myActiveApp->updateFilePopup( &myFilePopup, activate, myFilePos );
1044 myActiveApp->updateEditPopup( &myEditPopup, activate, myEditPos );
1045 myActiveApp->updateViewPopup( &myViewPopup, activate, myViewPos );
1046 myActiveApp->updateHelpPopup( &myHelpPopup, activate, myHelpPos );
1047 myActiveApp->updateMainMenu( myMainMenu, activate, myMainMenuPos );
1050 Since 'Edit' popup is completely customized by applications
1051 desktop doesn't show it in main menubar without the active
1052 application and we insert/remove this popup from the menubar
1053 when activating/deactivating applications.
1055 We can't have 'Edit' popup be customized by an application
1056 via UpdateMainMenu() method because applications may insert
1057 its items to the menubar only AFTER 'View' item ( this fact
1058 is respected by myMainMenuPos ) and the possibility of an
1059 application to add its items into any arbitrary positions of
1060 the main menubar requires a bit sophisticated implementation,
1061 so we decided to avoid it, sorry :-(.
1063 #if defined( DEBUG )
1065 /* applications MUST clear 'Edit' after themselves */
1066 QAD_ASSERT_DEBUG_ONLY( !myEditPopup.count() );
1069 if ( activate ) /* insert after 'File' item */
1070 myMainMenu->insertItem( tr("MEN_DESK_EDIT"), &myEditPopup, 3, 1 );
1072 myMainMenu->removeItem( 3 );
1077 Returns icon file name used by the application
1079 const QPixmap& QAD_Desktop::getDefaultIcon() const
1081 static QPixmap defaultPixmap( QAD_Desktop::getResourceManager()->loadPixmap( "QAD",
1082 tr("ICON_DESK_DEFAULTICON") ));
1083 return defaultPixmap;
1087 Returns name of the application used as the title of desktop panel
1089 const QString& QAD_Desktop::getDefaultTitle() const
1091 static QString defaultTitle ( tr("DESK_DEFAULTTITLE") );
1092 return defaultTitle;
1096 Returns default name of new studies
1098 const QString& QAD_Desktop::getDefaultStudyName() const
1100 static QString defaultStudyName( tr("DESK_DEFAULTDOC") );
1101 return defaultStudyName;
1105 Returns next name for new study
1107 QString QAD_Desktop::getNewStudyName()
1110 number.sprintf( "%d", ++myCntUntitled );
1111 return ( getDefaultStudyName() + number );
1115 Searches QAD_Study corresponding to <study>, returns NULL if fails
1117 QAD_Study* QAD_Desktop::findStudy( SALOMEDS::Study_ptr theStudy )
1119 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1120 QList<QAD_Study> studies;
1121 studies.setAutoDelete( false );
1122 studies = app->getStudies();
1123 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
1124 if ( study->getStudyDocument()->_is_equivalent( theStudy ) )
1132 Returns current active application
1134 QAD_Application* QAD_Desktop::getActiveApp() const
1140 Returns current active study
1142 QAD_Study* QAD_Desktop::getActiveStudy() const
1144 return myActiveStudy;
1150 QWorkspaceP* QAD_Desktop::getMainFrame() const
1156 Find or load Engine, given a container name and an engine name
1158 Engines::Component_var QAD_Desktop::getEngine(const char *containerName,
1159 const char *componentName)
1161 Engines::Component_var eng =
1162 myEnginesLifeCycle->FindOrLoad_Component(containerName,
1167 QString QAD_Desktop::getComponentName(const char *componentUserName)
1169 if ( mapComponentName.contains(componentUserName) )
1170 return mapComponentName[ componentUserName ] ;
1175 QString QAD_Desktop::getComponentUserName(const char *componentName)
1177 QMap<QString,QString>::Iterator it;
1178 for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it )
1179 if (it.data() == componentName )
1185 gets application Help Window (and creates if necessary)
1187 QAD_HelpWindow* QAD_Desktop::getHelpWindow()
1189 if (!myHelpWindow) {
1190 myHelpWindow = new QAD_HelpWindow();
1192 QMap<QString,QString>::Iterator it;
1193 for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it ) {
1197 // look for index.html and set homeDir
1198 // 1. $(MODULE_ROOT_DIR)/doc/index.html
1199 // 2. $(MODULE_ROOT_DIR)/doc/html/index.html
1200 // 3. $(MODULE_ROOT_DIR)/doc/html/html/index.html
1202 if (dir = getenv( QString( it.data() + "_ROOT_DIR")) ) {
1203 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" );
1204 if ( QFileInfo( root + "index.html" ).exists() ) {
1205 helpContext( root + "index.html", "" );
1208 root = QAD_Tools::addSlash( root + "html" );
1209 if ( QFileInfo( root + "index.html" ).exists() ) {
1210 helpContext( root + "index.html", "" );
1213 root = QAD_Tools::addSlash( root + "html" );
1214 if ( QFileInfo( root + "index.html" ).exists() ) {
1215 helpContext( root + "index.html", "" );
1222 connect(myHelpWindow, SIGNAL(helpWindowClosed()), this, SLOT(onHelpWindowClosed()));
1224 return myHelpWindow;
1228 Called when desktop is closing
1230 void QAD_Desktop::closeEvent ( QCloseEvent* e )
1232 bool doClose = true;
1233 if ( myQueryClose ) {
1234 doClose = QAD_MessageBox::info2 ( this, tr("INF_DESK_EXIT"),
1235 tr("QUE_DESK_EXIT"), tr ("BUT_OK"),
1236 tr ("BUT_CANCEL"), QAD_YES,
1237 QAD_NO, QAD_NO ) == QAD_YES;
1241 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1242 QList<QAD_Study>& studies = app->getStudies();
1243 for(QAD_Study* study = studies.first(); study != 0; study = studies.next()) {
1244 if(myQueryClose && study->getStudyDocument()->IsModified()) {
1245 SALOMEGUI_CloseDlg aDlg( this );
1246 switch ( aDlg.exec() ) {
1248 if ( !onSaveStudy( study ) ) {
1249 putInfo( tr("INF_CANCELLED") );
1260 putInfo( tr("INF_CANCELLED") );
1268 myQueryClose = true;
1269 doClose ? e->accept() : e->ignore();
1273 Called when desktop is resized
1275 void QAD_Desktop::resizeEvent( QResizeEvent* e )
1277 QMainWindow::resizeEvent( e );
1278 myWorkspace->setGeometry( 1,1, centralWidget()->width()-2,
1279 centralWidget()->height()-2 );
1284 Terminates the application.
1286 void QAD_Desktop::onExit()
1291 /************************************************************************
1293 *************************************************************************/
1297 If several application are supported it displays dialog window
1298 to choose type of study.
1300 void QAD_Desktop::createStudy(){
1303 void QAD_Desktop::onNewStudy()
1305 unsigned numApps = myApps.count();
1308 onNewStudy ( myApps.at(0) );
1309 else { /* select the type of application for new study */
1310 Desktop_AppSelectionDlg selDlg( this, myApps );
1311 if ( selDlg.exec() == QDialog::Accepted ) {
1312 onNewStudy ( selDlg.selectedApp() );
1315 } else { /* no applications available in desktop */
1316 QAD_MessageBox::error1( this,
1318 tr("ERR_APP_NOAPP"),
1324 Creates new study for the given application.
1325 Calls the respective function of the application class.
1327 void QAD_Desktop::onNewStudy( QAD_Application* app )
1331 /* create new study of the specific app */
1332 putInfo ( tr ("INF_DOC_CREATING") );
1333 QAD_Study* newStudy = app->newStudy();
1336 /* can't create new study */
1337 QAD_MessageBox::error1( this, tr("ERR_ERROR"),
1338 tr("ERR_DOC_CANTCREATE"),
1341 putInfo ( tr("INF_READY") );
1345 Loads the existing study.
1347 void QAD_Desktop::onLoadStudy()
1349 QString name, studyname, ext;
1351 SALOMEGUI_LoadStudiesDlg* aDlg = new SALOMEGUI_LoadStudiesDlg( this, "Load Study", TRUE);
1353 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1354 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1355 ASSERT(! CORBA::is_nil(myStudyMgr));
1356 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1357 for (unsigned int ind = 0; ind < List->length();ind++) {
1358 studyname = List[ind];
1359 aDlg->ListComponent->insertItem( studyname );
1362 int retVal = aDlg->exec();
1363 studyname = aDlg->ListComponent->currentText();
1365 if (retVal == QDialog::Rejected)
1368 if ( studyname.isNull() || studyname.isEmpty() )
1372 name.replace( QRegExp(":"), "/" );
1375 Try to associate an application to the opened study.
1376 Assumed that the association study<->application is unique.
1378 bool appFound = false;
1379 putInfo ( tr("INF_DOC_OPENING") + " " + name );
1380 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
1382 /* application found */
1383 if ( app->isStudyOpened( name ) )
1385 /* already opened: prompt for reopen */
1386 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1387 tr("QUE_DOC_ALREADYOPEN").arg( name ),
1388 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1389 QAD_NO ) == QAD_NO )
1391 putInfo ( tr("INF_READY") );
1394 /* now the study is closed to be re-opened */
1395 //don't ask user to remove study permanently
1396 if (app->getStudyByName ( name ) != NULL)
1397 onCloseStudy ( app->getStudyByName ( name ), false );
1398 else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )) != NULL)
1399 onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )), false );
1403 /* open the study */
1404 QAD_Study* openStudy = app->loadStudy( studyname );
1406 QAD_MessageBox::error1( this,
1408 tr("ERR_DOC_CANTOPEN") + "\n" + name,
1415 QAD_MessageBox::error1( this,
1417 tr("ERR_DOC_UNKNOWNTYPE"),
1420 putInfo ( tr("INF_READY") );
1425 QAD_Study* QAD_Desktop::loadStudy(QString theStudyName) {
1426 QString studyname("");
1428 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1429 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1430 ASSERT(! CORBA::is_nil(myStudyMgr));
1432 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1433 for (unsigned int ind = 0; ind < List->length();ind++) {
1434 if (theStudyName == QString(List[ind])) {
1435 studyname = theStudyName;
1439 if (studyname == "") {
1442 bool appFound = false;
1443 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1445 QAD_Study* openStudy = app->loadStudy( studyname );
1447 // if (myActiveApp == 0)
1448 //myActiveApp = app;
1458 Opens the existing study.
1459 Displays select file dialog and calls corresponding function of
1461 (application is defined according to extension of selected file).
1463 void QAD_Desktop::onOpenStudy()
1467 /* Select a file to open */
1468 name = selectFileName ( true );
1469 if ( name.isNull() || name.isEmpty() )
1472 // Workaround for non-existent files
1474 if (!fi.exists() || !fi.isFile()) {
1475 QAD_MessageBox::error1 ( this, tr("ERR_ERROR"),
1476 tr("ERR_DOC_CANTOPEN") +": " + name,
1481 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1482 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1483 ASSERT(! CORBA::is_nil(myStudyMgr));
1484 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1485 for (unsigned int ind = 0; ind < List->length();ind++) {
1486 QString NameExistingStudy(List[ind]);
1487 QString NameOpeningStudy = QAD_Tools::getFileNameFromPath( name, false );
1489 if ( NameExistingStudy.compare( NameOpeningStudy ) == 0 ) {
1490 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1491 tr("QUE_DOC_ALREADYEXIST").arg( name ),
1492 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1493 QAD_NO ) == QAD_NO )
1495 putInfo ( tr("INF_READY") );
1507 Try to associate an application to the opened study.
1508 Assumed that the association study<->application is unique.
1510 bool appFound = false;
1511 putInfo ( tr("INF_DOC_OPENING") + " " + name );
1512 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
1514 QString ext = QAD_Tools::getFileExtensionFromPath ( name );
1515 if ( app->getStudyExtension() == ext )
1517 /* application found */
1518 if ( app->isStudyOpened( name ) )
1520 /* already opened: prompt for reopen */
1521 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1522 tr("QUE_DOC_ALREADYOPEN").arg( name ),
1523 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1524 QAD_NO ) == QAD_NO )
1526 putInfo ( tr("INF_READY") );
1529 /* now the study is closed to be re-opened */
1530 //don't ask user to remove study permanently
1531 if (app->getStudyByName ( name ) != NULL)
1532 onCloseStudy ( app->getStudyByName ( name ), false );
1533 else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )) != NULL)
1534 onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )), false );
1538 /* open the study */
1539 QAD_Study* openStudy = app->openStudy( name );
1541 QAD_MessageBox::error1( this,
1543 tr("ERR_DOC_CANTOPEN") + "\n" + name,
1545 } else if (myActiveComp != "") {
1546 QApplication::setOverrideCursor( Qt::waitCursor );
1547 loadComponentData(mapComponentName[myActiveComp]);
1548 openStudy->updateObjBrowser(true);
1549 QApplication::restoreOverrideCursor();
1557 QAD_MessageBox::error1( this,
1559 tr("ERR_DOC_UNKNOWNTYPE"),
1562 putInfo ( tr("INF_READY") );
1565 bool QAD_Desktop::loadComponentData( const QString& compName )
1567 // Open component's data in active study if any
1568 MESSAGE("loadComponentData(): Opening " << compName << " component data ")
1569 if (!myActiveStudy) {
1570 MESSAGE("loadComponentData(): No active study exists")
1574 Engines::Component_var comp ;
1575 if ( compName.compare("SUPERV") == 0 ) {
1576 comp = getEngine( "SuperVisionContainer", compName) ;
1579 /* comp = ( compName.compare("Data1") != 0 ) ? getEngine( "FactoryServer", compName) :
1580 getEngine( "FactoryServerPy", compName);
1582 comp = getEngine( "FactoryServer", compName);
1583 if ( comp->_is_nil() )
1584 comp = getEngine( "FactoryServerPy", compName);
1587 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1588 SALOMEDS::SComponent_var SCO = SALOMEDS::SComponent::_narrow(aStudy->FindObject( getComponentUserName(compName) ));
1590 if (!SCO->_is_nil()) {
1591 if (!CORBA::is_nil(comp)) {
1592 SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
1593 if (!CORBA::is_nil(driver)) {
1594 SALOMEDS::StudyBuilder_var B = aStudy->NewBuilder();
1595 if (!CORBA::is_nil(B)) {
1596 QAD_Operation* op = new QAD_Operation( myActiveStudy );
1598 B->LoadWith(SCO,driver);
1604 MESSAGE("loadComponentData(): Driver is null");
1608 MESSAGE("loadComponentData(): Engine is null");
1612 MESSAGE("loadComponentData(): SComponent is null");
1620 Saves the active study
1622 bool QAD_Desktop::onSaveStudy()
1624 return onSaveStudy ( myActiveStudy );
1628 Saves the given study
1630 bool QAD_Desktop::onSaveStudy( QAD_Study* study )
1632 if ( !study ) return true;
1634 if ( !study->isSaved() )
1635 return onSaveAsStudy ( study );
1637 /* saving study... */
1638 QAD_Application* app = study->getApp();
1639 QAD_ASSERT_DEBUG_ONLY ( app );
1640 putInfo ( tr("INF_DOC_SAVING") + study->getTitle() );
1641 if ( !app->saveStudy( study ) )
1643 putInfo( tr("INF_CANCELLED") );
1648 putInfo ( tr("INF_DOC_SAVED").arg( "" ) );
1653 Saves the active study under a new name
1655 bool QAD_Desktop::onSaveAsStudy()
1657 return onSaveAsStudy( myActiveStudy );
1661 Saves the given study under a new name
1663 bool QAD_Desktop::onSaveAsStudy( QAD_Study* study )
1665 if ( !study ) return true;
1667 /* Save study in a format supported by its application
1669 QAD_Application* app = study->getApp();
1670 QAD_ASSERT_DEBUG_ONLY ( app );
1672 /* Select a file where to save
1674 QString name = selectFileName ( false );
1675 if ( name.isNull() || name.isEmpty() )
1677 putInfo( tr("INF_CANCELLED") );
1683 putInfo ( tr("INF_DOC_SAVING") + name );
1684 if ( !app->saveAsStudy( study, name ) ) {
1685 /* can't save the file */
1686 QAD_MessageBox::error1( this,
1688 tr("ERR_DOC_CANTWRITE") + "\n" + name,
1691 return false; /* cannot save */
1693 putInfo ( tr("INF_DOC_SAVED").arg( name ) );
1694 return true; /* saved ok */
1698 Closes the active study
1700 bool QAD_Desktop::onCloseStudy()
1702 bool close = this->onCloseStudy ( myActiveStudy, true );
1703 if ( close && !myXmlHandler->myIdList.IsEmpty() ) {
1706 myCombo->setCurrentItem (0);
1707 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
1708 aButton->setOn(false);
1715 Closes the given study and ask user to remove study
1716 from the study manager permanently
1718 bool QAD_Desktop::onCloseStudy( QAD_Study* study )
1720 return onCloseStudy( study, true );
1724 Closes the given study and ask user to remove study
1725 from the study manager permanently if ask is equal true
1727 bool QAD_Desktop::onCloseStudy( QAD_Study* study, bool ask )
1729 bool removePerm = false;
1733 SALOMEGUI_CloseDlg aDlg( this );
1734 int res = aDlg.exec();
1739 //if ( study->isModified() )
1740 if ( !onSaveStudy( study ) ) {
1741 putInfo( tr("INF_CANCELLED") );
1754 putInfo( tr("INF_CANCELLED") );
1758 /* close active component */
1759 if (!myXmlHandler->myIdList.IsEmpty())
1763 myCombo->setCurrentItem (0);
1764 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() )
1765 aButton->setOn(false);
1766 qApp->processEvents();
1768 /* close the study */
1769 return study->getApp()->closeStudy( study, removePerm );
1772 // Displays study properties dialog box
1773 void QAD_Desktop::onStudyProperties()
1775 if (myActiveStudy) {
1777 QAD_Operation* op = new QAD_Operation( myActiveStudy );
1780 SALOMEGUI_StudyPropertiesDlg aDlg(this);
1781 int res = aDlg.exec();
1783 if ( res == QDialog::Accepted && aDlg.isChanged() )
1788 // T2.12 - add the word "locked" to study frame captions if <myActiveStudy> study is locked
1789 myActiveStudy->updateCaptions();
1795 locate all windows in cascade mode
1798 void QAD_Desktop::onCascade()
1800 myWorkspace->cascade();
1801 int w = myWorkspace->width();
1802 int h = myWorkspace->height();
1803 QWidgetList wList = myWorkspace->windowList();
1804 QWidgetListIt it(wList);
1806 for(;it.current(); ++it)
1807 it.current()->resize((int)(0.8*w), (int)(0.8*h));
1811 called when help window closed
1813 void QAD_Desktop::onHelpWindowClosed()
1819 Called when 'view status bar' option
1822 void QAD_Desktop::onViewStatusBar()
1824 bool show = myStdActions.at( ViewStatusBarId )->isOn();
1825 if ( show == myStatusBar->isVisible() )
1828 myStatusBar->show();
1830 myStatusBar->hide();
1834 Called when View/Toolbars popup menu is about to show
1836 void QAD_Desktop::onToolBarPopupAboutToShow()
1838 myToolBarAction.clear();
1839 myToolBarsPopup.clear();
1840 QPtrList<QDockWindow> wlist = dockWindows();
1841 for ( QDockWindow* w = wlist.first(); w; w = wlist.next() ) {
1842 if ( w->inherits( "QToolBar" ) ) {
1843 QToolBar* tb = ( QToolBar* )w;
1844 if ( appropriate( tb ) ) {
1845 ToggleAction* a = new ToggleAction( tb->label(), tb->label(), 0, this, 0, true );
1846 a->setStatusTip ( tr("PRP_DESK_VIEW_TOOLBAR") );
1847 a->setOn( tb->isVisible() );
1848 QAD_ASSERT( connect( a, SIGNAL( toggledOn() ), tb, SLOT( show() ) ) );
1849 QAD_ASSERT( connect( a, SIGNAL( toggledOff() ), tb, SLOT( hide() ) ) );
1850 a->addTo( &myToolBarsPopup );
1851 myToolBarAction.append( a );
1858 Called on 'View\Selection Mode'
1860 void QAD_Desktop::onSelectionMode()
1862 const QActionP* obj = (QActionP*) sender();
1864 int SelectionMode = 4;
1866 if ( obj == myStdActions.at(SelectionActorId) ) {
1868 if ( obj->isOn() ) {
1869 myStdActions.at(SelectionCellId)->setOn(false);
1870 myStdActions.at(SelectionEdgeId)->setOn(false);
1871 myStdActions.at(SelectionPointId)->setOn(false);
1873 myStdActions.at(SelectionActorId)->setOn(true);
1875 } else if ( obj == myStdActions.at(SelectionCellId) ) {
1877 if ( obj->isOn() ) {
1878 myStdActions.at(SelectionActorId)->setOn(false);
1879 myStdActions.at(SelectionEdgeId)->setOn(false);
1880 myStdActions.at(SelectionPointId)->setOn(false);
1882 myStdActions.at(SelectionActorId)->setOn(true);
1884 } else if ( obj == myStdActions.at(SelectionEdgeId) ) {
1886 if ( obj->isOn() ) {
1887 myStdActions.at(SelectionActorId)->setOn(false);
1888 myStdActions.at(SelectionCellId)->setOn(false);
1889 myStdActions.at(SelectionPointId)->setOn(false);
1891 myStdActions.at(SelectionActorId)->setOn(true);
1893 } else if ( obj == myStdActions.at(SelectionPointId) ) {
1895 if ( obj->isOn() ) {
1896 myStdActions.at(SelectionEdgeId)->setOn(false);
1897 myStdActions.at(SelectionCellId)->setOn(false);
1898 myStdActions.at(SelectionActorId)->setOn(false);
1900 myStdActions.at(SelectionActorId)->setOn(true);
1903 QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame();
1904 sf->getRightFrame()->getViewFrame()->SetSelectionMode( SelectionMode );
1906 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() );
1907 Sel->SetSelectionMode( SelectionMode );
1911 Called on 'View\Selection Mode'
1913 void QAD_Desktop::SetSelectionMode(int mode, bool activeCompOnly)
1918 myStdActions.at(SelectionEdgeId)->setOn(false);
1919 myStdActions.at(SelectionCellId)->setOn(false);
1920 myStdActions.at(SelectionActorId)->setOn(false);
1921 myStdActions.at(SelectionPointId)->setOn(true);
1926 myStdActions.at(SelectionActorId)->setOn(false);
1927 myStdActions.at(SelectionCellId)->setOn(false);
1928 myStdActions.at(SelectionPointId)->setOn(false);
1929 myStdActions.at(SelectionEdgeId)->setOn(true);
1934 myStdActions.at(SelectionActorId)->setOn(false);
1935 myStdActions.at(SelectionEdgeId)->setOn(false);
1936 myStdActions.at(SelectionPointId)->setOn(false);
1937 myStdActions.at(SelectionCellId)->setOn(true);
1942 myStdActions.at(SelectionCellId)->setOn(false);
1943 myStdActions.at(SelectionEdgeId)->setOn(false);
1944 myStdActions.at(SelectionPointId)->setOn(false);
1945 myStdActions.at(SelectionActorId)->setOn(true);
1950 QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame();
1951 if ( sf->getTypeView() == VIEW_VTK ) {
1952 sf->getRightFrame()->getViewFrame()->SetSelectionMode( mode );
1953 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() );
1954 Sel->SetSelectionMode( mode, activeCompOnly );
1960 Called on 'Window\NewWindow3d'
1962 void QAD_Desktop::onNewWindow3d()
1966 //VRV: T2.5 - add default viewer
1967 QApplication::restoreOverrideCursor();
1968 SALOMEGUI_ViewChoiceDlg *choice = new SALOMEGUI_ViewChoiceDlg(this, "", TRUE);
1969 int r = choice->exec();
1972 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(choice->getSelectedViewer()));
1974 //VRV: T2.5 - add default viewer
1976 const QActionP* obj = (QActionP*) sender();
1977 if ( obj == myStdActions.at(ViewOCCId) ) {
1978 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(0));
1979 } else if ( obj == myStdActions.at(ViewVTKId) ) {
1980 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(1));
1981 } else if ( obj == myStdActions.at(ViewPlot2dId) ) {
1982 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(3));
1988 Called on 'help\contents'
1990 void QAD_Desktop::onHelpContents()
1993 myActiveApp->helpContents();
1999 Called on 'help\search'
2001 void QAD_Desktop::onHelpSearch()
2004 myActiveApp->helpSearch();
2010 Called on 'help\about'
2012 void QAD_Desktop::onHelpAbout()
2015 myActiveApp->helpAbout();
2022 Activates the application and its active study
2024 void QAD_Desktop::onActivateApp( QAD_Application* activeApp )
2026 bool appChanged = ( activeApp != myActiveApp );
2029 updateDesktop( DeactivateApp );
2033 myActiveApp = activeApp;
2034 myActiveStudy = myActiveApp->getActiveStudy();
2044 updateDesktop( ActivateApp );
2045 updateCaption( (activeApp != NULL) ? ActivateApp : DeactivateApp );
2051 Called when the last study is removed from
2052 the application 'app'.
2054 void QAD_Desktop::onDeactivateApp(QAD_Application* app)
2056 if ( app && app == myActiveApp )
2061 Enables/disables standard actions
2063 void QAD_Desktop::updateActions()
2065 myStdActions.at( FileCloseId )->setEnabled ( myActiveStudy != NULL );
2066 myStdActions.at( FileSaveId )->setEnabled ( myActiveStudy != NULL );
2067 myStdActions.at( FileSaveAsId )->setEnabled ( myActiveStudy != NULL );
2068 myStdActions.at( FilePropsId )->setEnabled( myActiveStudy != NULL );
2069 // myStdActions.at( HelpContentsId )->setEnabled ( myActiveApp != NULL );
2070 // myStdActions.at( HelpSearchId )->setEnabled ( myActiveApp != NULL );
2071 // myStdActions.at( HelpWhatsThisId )->setEnabled ( myActiveApp != NULL );
2072 // myStdActions.at( HelpAboutId )->setEnabled ( myActiveApp != NULL );
2074 // myToolsPopup.setEnabled ( myActiveStudy != NULL );
2075 // myPrefPopup.setEnabled ( myActiveStudy != NULL );
2077 mySelectionModePopup.setEnabled ( myActiveStudy != NULL );
2080 myStdActions.at( ViewOCCId )->setEnabled( myActiveStudy != NULL );
2081 myStdActions.at( ViewVTKId )->setEnabled( myActiveStudy != NULL );
2082 myStdActions.at( ViewPlot2dId )->setEnabled( myActiveStudy != NULL );
2087 Called when 'Window' popup is about to show
2089 void QAD_Desktop::onWindowPopupAboutToShow()
2091 /* add cascade/tile items */
2092 myWindowPopup.clear();
2095 //myStdActions.at( WindowNew3dId )->addTo( &myWindowPopup );
2096 myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId );
2097 //myStdActions.at( WindowNew3dId )->setEnabled( true );
2098 myWindowPopup.setItemEnabled( WindowNew3dId, true );
2100 myStdActions.at( WindowCascadeId )->addTo( &myWindowPopup );
2101 myStdActions.at( WindowCascadeId )->setEnabled( true );
2102 myStdActions.at( WindowTileId )->addTo( &myWindowPopup );
2103 myStdActions.at( WindowTileId )->setEnabled( true );
2105 /* add names of opened studies */
2106 QWidgetList windows = myWorkspace->windowList();
2107 if ( windows.isEmpty() )
2109 //NRI : SAL2214 myStdActions.at( WindowNew3dId )->setEnabled( false );
2110 myWindowPopup.setItemEnabled( WindowNew3dId, false );
2112 myStdActions.at( WindowCascadeId )->setEnabled( false );
2113 myStdActions.at( WindowTileId )->setEnabled( false );
2117 myWindowPopup.insertSeparator();
2118 for ( int i = 0; i < int(windows.count()); ++i )
2120 int id = myWindowPopup.insertItem( windows.at(i)->caption(),
2121 this, SLOT( onWindowsPopupActivated( int ) ) );
2122 myWindowPopup.setItemParameter( id, i );
2123 myWindowPopup.setItemChecked( id, myWorkspace->activeWindow() == windows.at(i) );
2125 QAD_ASSERT( connect( &myWindowPopup, SIGNAL(highlighted( int )), this,
2126 SLOT(onWindowsPopupStatusText( int )) ));
2131 Called when the item with 'id' of 'Windows' popup
2134 void QAD_Desktop::onWindowsPopupStatusText( int id )
2136 int cascadeId = myWindowPopup.idAt( 0 );
2137 int tileId = myWindowPopup.idAt( 1 );
2138 if ( id == cascadeId || id == tileId )
2140 putInfo( tr("PRP_DESK_WINDOW_ACTIVATE") );
2144 Called when user wants to activate a child window with 'wid'
2147 void QAD_Desktop::onWindowsPopupActivated( int wid )
2149 QWidget* w = myWorkspace->windowList().at( wid );
2150 if ( w ) w->setFocus();
2154 Selects a file name when opening or saving files.
2155 The basic implementation just uses the standard
2157 Please redefine if another behaviour is required.
2159 QString QAD_Desktop::selectFileName ( bool open )
2161 QAD_FileDlg* fd = new QAD_FileDlg( this, open, true, true );
2165 QStringList filters;
2168 // All the file types of the supported applications
2170 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
2172 filters += app->getStudyDescription() + " " + tr("DESK_FILES") + " " +
2173 "(*." + app->getStudyExtension() + ")";
2177 QAD_ASSERT_DEBUG_ONLY ( myActiveStudy );
2178 if (myActiveStudy) {
2179 // get file name of active study
2180 name = QAD_Tools::getFileNameFromPath ( myActiveStudy->getTitle() );
2181 // get path to the active study file
2182 dir = QAD_Tools::getDirFromPath ( myActiveStudy->getPath(), false );
2184 QAD_ASSERT_DEBUG_ONLY ( !name.isNull() );
2185 // the file types supported by the active application
2186 filters += myActiveApp->getStudyDescription() + " " + tr("DESK_FILES") + " " +
2187 "(*." + myActiveApp->getStudyExtension() + ")" ;
2189 if (!dir.isEmpty()) {
2190 // when saving document ("Save As" command) - to get dir from active study filename
2191 // for new documents - to use last opened directory
2194 fd->setSelection( name );
2195 fd->setFilters( filters );
2198 QString filename = fd->selectedFile();
2200 qApp->processEvents();
2205 Closes all the studies of 'app'. Returns
2206 'true' if thay are closed OK, 'false' at least
2207 one can't be closed or user cancel the closure.
2209 bool QAD_Desktop::closeAllStudies( QAD_Application* app )
2211 QList<QAD_Study>& studies = app->getStudies();
2212 while ( !studies.isEmpty() )
2214 //don't ask user to remove study permanently
2215 if ( !onCloseStudy( studies.at(0), false ) )
2216 return false; /* user cancelled closing */
2222 Called on Popup item when SComponent representation in Object Browser is selected.
2224 void QAD_Desktop::onOpenWith()
2226 Engines::Component_var comp;
2227 QString ComponentSelected;
2229 SALOMEDS::SObject_var SO;
2230 SALOMEDS::SComponent_var SCO;
2231 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2232 SALOMEDS::GenericAttribute_var anAttr;
2233 SALOMEDS::AttributeName_var aName;
2235 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2236 if ( Sel->IObjectCount() == 1 ) {
2237 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
2238 SO = aStudy->FindObjectID( IO->getEntry() );
2239 SCO = SO->GetFatherComponent();
2241 if (SCO->FindAttribute(anAttr, "AttributeName")) {
2242 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2243 name = aName->Value();
2244 SALOME_ModuleCatalog::Acomponent_var Comp = myCatalogue->GetComponent( mapComponentName[name] );
2245 if ( !Comp->_is_nil() ) {
2247 SALOME_ModuleCatalog::ListOfComponents_var list_type_composants =
2248 myCatalogue->GetTypedComponentList( Comp->component_type() );
2250 if ( list_type_composants->length() == 1 ) {
2251 ComponentSelected = name;
2252 } else if ( list_type_composants->length() > 1 ) {
2253 SALOMEGUI_OpenWith* aDlg = new SALOMEGUI_OpenWith( this );
2254 for (unsigned int ind = 0; ind < list_type_composants->length();ind++) {
2255 aDlg->addComponent( strdup(list_type_composants[ind]) );
2258 int retVal = aDlg->exec();
2259 ComponentSelected = aDlg->getComponent();
2261 if ( retVal == QDialog::Rejected || ComponentSelected.isEmpty()) {
2265 MESSAGE( "No component with type : " << Comp->component_type() << " exists" );
2270 MESSAGE( "This component not exists in the catalog" );
2274 QApplication::setOverrideCursor( Qt::waitCursor );
2275 Sel->ClearIObjects();
2277 // if (loadComponentData(ComponentSelected)) {
2278 onComboActiveComponent(ComponentSelected);
2279 // int nbItem = myCombo->count();
2281 // for (int i = 0; i < nbItem; i++) {
2282 // if (myCombo->text(i).compare(ComponentSelected)==0) {
2287 // myCombo->setCurrentItem(Index);
2288 // myActiveStudy->updateObjBrowser(true);
2292 QApplication::restoreOverrideCursor();
2295 typedef bool OneDim1(QAD_Desktop*);
2296 typedef bool OneDim2(QAD_Desktop*, char*);
2299 Called to define settings of component.
2301 void QAD_Desktop::setSettings()
2303 if (!myActiveComp.isEmpty()) {
2304 OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings");
2308 OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
2313 QString Component =mapComponentName[myActiveComp];
2314 OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF;
2315 (*f1)(this, (char*)Component.latin1());
2321 Called to load Component : xml resources and GUI librairy.
2323 bool QAD_Desktop::loadComponent(QString Component)
2326 QString resDir("/"); //NRI : Pb under Windows
2328 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
2331 if (!resMgr->loadResources( Component, msg ))
2333 //NRI QCString errMsg;
2334 // errMsg.sprintf( "Do not load all resources for module %sGUI.\n" ,
2335 // Component.latin1() );
2337 QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
2342 /* Parse xml file */
2343 myXmlHandler = new QAD_XmlHandler();
2344 myXmlHandler->setMainWindow(this);
2345 if (!myXmlHandler->setComponent(resMgr->resources( Component ))) return false;
2347 QString language = resMgr->language( Component );
2349 QString ComponentXml = Component + "_" + language + ".xml";
2350 //ComponentXml = resMgr->resources(Component + "GUI") ;
2351 //ComponentXml = QAD_Tools::addSlash(ComponentXml) ;
2352 ComponentXml = QAD_Tools::addSlash( resMgr->findFile( ComponentXml, Component ) ) + ComponentXml;
2353 QFile file( ComponentXml );
2355 if ( !file.exists() || !file.open( IO_ReadOnly ) ) {
2357 errMsg.sprintf( "Cannot open xml file: %s\n.",
2358 (file.name()).latin1() );
2360 QMessageBox::critical( this, tr("ERR_ERROR"), errMsg, tr ("BUT_OK") );
2365 QXmlInputSource source( file );
2366 QXmlSimpleReader reader;
2367 reader.setContentHandler( myXmlHandler );
2368 reader.setErrorHandler( myXmlHandler );
2369 bool ok = reader.parse( source );
2373 QMessageBox::critical( this,
2374 tr( "INF_PARSE_ERROR" ),
2375 tr( myXmlHandler->errorProtocol() ) );
2379 myMenusList=myXmlHandler->myMenusList;
2380 myActiveMenus=myMenusList.at(0);
2381 myOperatorMenus->showMenuBar(0);
2382 myActiveMenus->showAllToolBars();
2384 /* Components toolbars */
2387 nbToolbars = myActiveMenus->getToolBarList().count();
2388 /* Open Shared Library */
2389 mySharedLibrary = OSD_SharedLibrary();
2392 QString ComponentLib;
2394 QFileInfo fileInfo ;
2395 QString fileString ;
2398 if ( libs = getenv("LD_LIBRARY_PATH")) {
2399 // MESSAGE ( " LD_LIBRARY_PATH : " << libs );
2400 QStringList dirList = QStringList::split( SEPARATOR, libs, false ); // skip empty entries
2401 for ( int i = dirList.count()-1; i >= 0; i-- ) {
2404 fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.dll" ;
2406 fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.so" ;
2409 fileInfo.setFile(fileString) ;
2410 if (fileInfo.exists()) {
2411 // MESSAGE ( " GUI library = " << fileString );
2412 ComponentLib = fileInfo.fileName() ;
2419 if (!_islibso) // component GUI could be in PyQt, use generic library
2421 MESSAGE("GUI library not found, trying generic library for PyQt GUI");
2423 if (dir = getenv("KERNEL_ROOT_DIR"))
2425 dir = QAD_Tools::addSlash(dir) ;
2427 dir = QAD_Tools::addSlash(dir) ;
2428 dir = dir + "salome" ;
2429 dir = QAD_Tools::addSlash(dir) ;
2431 dir = dir + "libSalomePyQtcmodule.dll" ;
2433 dir = dir + "libSalomePyQtcmodule.so" ;
2435 MESSAGE ( " GUI library = " << dir );
2436 fileInfo.setFile(dir) ;
2437 if (fileInfo.exists())
2439 ComponentLib = fileInfo.fileName() ;
2445 QMessageBox::critical( this,
2447 tr("ERR_LIBGUI" ).arg(Component) );
2452 mySharedLibrary.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString());
2453 ok = mySharedLibrary.DlOpen(OSD_RTLD_LAZY);
2456 QMessageBox::critical( this,
2458 tr( mySharedLibrary.DlError() ) );
2463 OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings");
2467 OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
2472 OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF;
2473 (*f1)(this, (char*)Component.latin1());
2478 /* COMPONENT INTERFACE */
2479 SALOME_ModuleCatalog::Acomponent_ptr aComponent =
2480 myCatalogue->GetComponent(Component.latin1());
2482 if (CORBA::is_nil (aComponent)) {
2483 MESSAGE( "Catalog Error : Component not found in the catalog" )
2487 myActiveStudy->setMessage(QString("Component : ") +
2488 aComponent->componentusername() + " created " );
2489 myActiveStudy->setMessage(QString("Type : ") +
2490 QString::number(aComponent->component_type()));
2491 myActiveStudy->setMessage(QString("Constraint : ") +
2492 aComponent->constraint() );
2494 /* obtain interfaces list of the component */
2495 SALOME_ModuleCatalog::ListOfInterfaces_var _list =
2496 new SALOME_ModuleCatalog::ListOfInterfaces;
2497 _list = aComponent->GetInterfaceList();
2499 if (_list->length() != 0 ) {
2501 for (unsigned int ind = 0; ind < _list->length();ind++)
2502 myActiveStudy->setMessage( QString("Interface name : ") +
2506 /* obtain services list of the component */
2507 SALOME_ModuleCatalog::ListOfServices_var list_services_component =
2508 new SALOME_ModuleCatalog::ListOfServices;
2509 list_services_component = aComponent->GetServiceList(_list[0]);
2511 if (list_services_component->length() != 0 ) {
2513 for (unsigned int ind = 0; ind < list_services_component->length();ind++)
2514 myActiveStudy->setMessage( QString("Service name : ") +
2515 list_services_component[ind] );
2517 // Get a service of the component
2518 SALOME_ModuleCatalog::Service_var service = new SALOME_ModuleCatalog::Service;
2519 service = aComponent->GetService(_list[0],list_services_component[0]) ;
2520 myActiveStudy->setMessage( QString("Service name: ") + service->ServiceName);
2521 for (unsigned int ind1 = 0; ind1 <service->ServiceinParameter.length();ind1++) {
2522 myActiveStudy->setMessage( QString("Type of the in Parameter of this service : ") +
2523 (const char *) service->ServiceinParameter[ind1].Parametertype);
2524 myActiveStudy->setMessage( QString("Name of the in Parameter of this service : ") +
2525 (const char *) service->ServiceinParameter[ind1].Parametername);
2527 for (unsigned int ind1 = 0; ind1 <service->ServiceoutParameter.length();ind1++) {
2528 myActiveStudy->setMessage( QString("Type of the out Parameter of this service : ") +
2529 (const char *) service->ServiceoutParameter[ind1].Parametertype);
2530 myActiveStudy->setMessage( QString("Name of the out Parameter of this service : ") +
2531 (const char *) service->ServiceoutParameter[ind1].Parametername);
2538 typedef bool OneDim(int, QAD_Desktop*);
2539 typedef void (*PTR_FACTORY_FUNCTION)( CORBA::ORB_var &orb, QWidget *parent, const char *name ) ;
2543 void QAD_Desktop::onDispatch()
2545 const QObject* obj = sender();
2547 QList<QAD_ListMenuIdAction> MenuList = myActiveMenus->getMenuList();
2548 QAD_ListMenuIdAction* aMenu;
2550 for(aMenu=MenuList.first();aMenu!=NULL;aMenu=MenuList.next()) {
2551 if (aMenu->getAction()==obj) {
2552 id = aMenu->getId();
2561 void QAD_Desktop::onDispatchTools(int id)
2563 /* Open Shared Library */
2564 OSD_SharedLibrary ToolsLibrary = OSD_SharedLibrary();
2568 QFileInfo fileInfo ;
2572 bool libToolsGUI = true;
2573 if( QAD_XmlHandler::_bibmap[ id ].isEmpty() )
2576 if ( dir = getenv("SALOME_SITE_DIR")) {
2577 dir = QAD_Tools::addSlash(dir) ;
2579 dir = QAD_Tools::addSlash(dir) ;
2580 dir = dir + "salome" ;
2581 dir = QAD_Tools::addSlash(dir) ;
2583 dir = dir + "libToolsGUI.dll" ;
2585 dir = dir + "libToolsGUI.so" ;
2587 MESSAGE ( " GUI library = " << dir );
2588 fileInfo.setFile(dir) ;
2589 if (fileInfo.exists()) {
2590 ToolsLib = fileInfo.fileName() ;
2595 if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
2596 dir = QAD_Tools::addSlash(dir) ;
2598 dir = QAD_Tools::addSlash(dir) ;
2599 dir = dir + "salome" ;
2600 dir = QAD_Tools::addSlash(dir) ;
2602 dir = dir + "libToolsGUI.dll" ;
2604 dir = dir + "libToolsGUI.so" ;
2606 MESSAGE ( " GUI library = " << dir );
2607 fileInfo.setFile(dir) ;
2608 if (fileInfo.exists()) {
2609 ToolsLib = fileInfo.fileName() ;
2614 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
2615 dir = QAD_Tools::addSlash(dir) ;
2617 dir = QAD_Tools::addSlash(dir) ;
2618 dir = dir + "salome" ;
2619 dir = QAD_Tools::addSlash(dir) ;
2621 dir = dir + "libToolsGUI.dll" ;
2623 dir = dir + "libToolsGUI.so" ;
2625 MESSAGE ( " GUI library = " << dir );
2626 fileInfo.setFile(dir) ;
2627 if (fileInfo.exists()) {
2628 ToolsLib = fileInfo.fileName() ;
2634 libToolsGUI = false;
2635 SCRUTE( QAD_XmlHandler::_bibmap[ id ] ) ;
2636 if ( dir = getenv("SALOME_SITE_DIR")) {
2637 dir = QAD_Tools::addSlash(dir) ;
2639 dir = QAD_Tools::addSlash(dir) ;
2640 dir = dir + "salome" ;
2641 dir = QAD_Tools::addSlash(dir) ;
2642 dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ;
2643 MESSAGE ( " GUI library = " << dir );
2644 fileInfo.setFile(dir) ;
2645 if (fileInfo.exists()) {
2646 ToolsLib = fileInfo.fileName() ;
2651 if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) {
2652 dir = QAD_Tools::addSlash(dir) ;
2654 dir = QAD_Tools::addSlash(dir) ;
2655 dir = dir + "salome" ;
2656 dir = QAD_Tools::addSlash(dir) ;
2657 dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ;
2658 MESSAGE ( " GUI library = " << dir );
2659 fileInfo.setFile(dir) ;
2660 if (fileInfo.exists()) {
2661 ToolsLib = fileInfo.fileName() ;
2666 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
2667 dir = QAD_Tools::addSlash(dir) ;
2669 dir = QAD_Tools::addSlash(dir) ;
2670 dir = dir + "salome" ;
2671 dir = QAD_Tools::addSlash(dir) ;
2672 dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ;
2673 MESSAGE ( " GUI library = " << dir );
2674 fileInfo.setFile(dir) ;
2675 if (fileInfo.exists()) {
2676 ToolsLib = fileInfo.fileName() ;
2682 ToolsLibrary.SetName(TCollection_AsciiString((char*)ToolsLib.latin1()).ToCString());
2683 bool ok = ToolsLibrary.DlOpen(OSD_RTLD_LAZY);
2685 if ( libToolsGUI ) {
2686 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
2687 OneDim (*f1) = NULL;
2688 f1 = (bool (*) (int, QAD_Desktop*)) osdF;
2691 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
2692 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
2693 CORBA::ORB_var &orb = init(0 , 0 ) ;
2694 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
2695 PTR_FACTORY_FUNCTION f1 = NULL;
2696 f1 = (PTR_FACTORY_FUNCTION) osdF;
2697 f1(orb,0,"Registry");
2700 QMessageBox::critical( this,
2702 tr( ToolsLibrary.DlError() ) );
2708 void QAD_Desktop::onDispatch(int id)
2710 if (!myActiveComp.isEmpty()) {
2711 OSD_Function osdF = mySharedLibrary.DlSymb("OnGUIEvent");
2712 OneDim (*f1) = NULL;
2713 if ( osdF != NULL ) {
2714 f1 = (bool (*) (int, QAD_Desktop*)) osdF;
2721 Returns the component's catalogue
2723 SALOME_ModuleCatalog::ModuleCatalog_var QAD_Desktop::getCatalogue()
2730 void QAD_Desktop::onComboActiveComponent( const QString & component ){
2731 onComboActiveComponent(component,true);
2733 void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoadData)
2735 if (myActiveStudy != 0) {
2736 if (myActiveComp.compare(component)!=0) {
2737 if (!myXmlHandler->myIdList.IsEmpty()) clearMenus();
2738 if ( myCombo->currentText() != component )
2739 myCombo->setCurrentText( component );
2740 //NRI if (component.compare(QString("Salome"))!= 0) {
2741 if (component.compare( getComponentUserName( "KERNEL" ) )!= 0) {
2742 // QApplication::setOverrideCursor( Qt::waitCursor );
2743 myActiveComp = component;
2745 SALOME_Selection* oldSel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2747 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
2748 if ( aButton->textLabel().compare(component)==0)
2749 aButton->setOn(true);
2751 aButton->setOn(false);
2754 myActiveStudy->Selection( component );
2755 if ( !loadComponent(mapComponentName[component]) ) {
2756 myCombo->setCurrentItem (0);
2757 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
2758 aButton->setOn(false);
2763 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2764 SALOME_ListIteratorOfListIO It( oldSel->StoredIObjects() );
2765 for(;It.More();It.Next()) {
2766 int res = Sel->AddIObject( It.Value() );
2769 myActiveStudy->highlight( It.Value(), false );
2771 myActiveStudy->highlight( It.Value(), true );
2775 // Open new component's data in active study if any
2776 if(isLoadData) loadComponentData(mapComponentName[component]);
2779 myActiveStudy->updateObjBrowser(true);
2781 // QApplication::restoreOverrideCursor();
2783 } else { // component == "Salome"
2785 //NRI myActiveStudy->Selection( "Salome" );
2786 myActiveStudy->Selection( getComponentUserName( "KERNEL" ) );
2787 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2788 Sel->ClearIObjects();
2789 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
2790 aButton->setOn(false);
2794 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
2795 if ( aButton->textLabel().compare(component)==0)
2796 aButton->setOn(true);
2800 QMessageBox::critical( 0,
2802 tr( "WRN_LOAD_COMPONENT" ) );
2803 myCombo->setCurrentItem (0);
2804 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
2805 aButton->setOn(false);
2812 void QAD_Desktop::activateComponent(const QString& theName, bool isLoadData){
2813 int nbItem = myCombo->count();
2816 for (int i = 0; i < nbItem; i++) {
2817 if (myCombo->text(i).compare(theName)==0) {
2822 myCombo->setCurrentItem (Index);
2823 onComboActiveComponent(theName,isLoadData);
2826 void QAD_Desktop::onButtonActiveComponent( )
2828 QToolButton* obj = (QToolButton*)sender();
2829 activateComponent(obj->textLabel());
2833 Clears All Resources of current component
2835 void QAD_Desktop::clearMenus()
2837 onActiveStudyChanged();
2840 myMenusList.clear();
2842 int length = myXmlHandler->myIdList.Length();
2843 for (int k=length; k>0; k--) {
2845 if ( menuBar()->findItem(myXmlHandler->myIdList.Value(k), &parent) )
2846 parent->removeItem( myXmlHandler->myIdList.Value(k) );
2851 if (myActiveMenus) {
2852 int nbtoolbars = myActiveMenus->getToolBarList().count();
2853 for (int k=0; k<nbtoolbars; k++) {
2854 myActiveMenus->getToolBarList().at(k)->hide();
2855 myActiveMenus->getToolBarList().at(k)->clear();
2857 myActiveMenus->clearToolBar();
2860 QList<QAD_ListPopupMenu> PopupList = myActiveMenus->getPopupMenuList();
2861 QAD_ListPopupMenu* aPopup;
2862 for(aPopup=PopupList.first();aPopup!=NULL;aPopup=PopupList.next()){
2863 aPopup->getPopup()->clear();
2866 myActiveMenus->clearPopupMenu();
2872 typedef bool TwoDim1(QKeyEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
2874 Exports Key Events in active component ( GUI Librairy )
2876 void QAD_Desktop::onKeyPress( QKeyEvent* pe )
2878 // MESSAGE ( "QAD_Desktop::onKeyPress" )
2879 if (!myActiveComp.isEmpty()) {
2880 OSD_Function osdF = mySharedLibrary.DlSymb("OnKeyPress");
2881 if ( osdF != NULL ) {
2882 TwoDim1 (*f1) = (bool (*) (QKeyEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
2883 (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
2888 typedef bool TwoDim(QMouseEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
2890 Exports Mouse Press Events in active component ( GUI Librairy )
2892 bool QAD_Desktop::onMousePress( QMouseEvent* pe )
2894 // MESSAGE ( "QAD_Desktop::onMousePress" )
2895 if (!myActiveComp.isEmpty()) {
2896 OSD_Function osdF = mySharedLibrary.DlSymb("OnMousePress");
2897 if ( osdF != NULL ) {
2898 TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
2899 return (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
2906 Exports Mouse Move Events in active component ( GUI Librairy )
2908 void QAD_Desktop::onMouseMove( QMouseEvent* pe )
2910 if (!myActiveComp.isEmpty()) {
2911 OSD_Function osdF = mySharedLibrary.DlSymb("OnMouseMove");
2912 if ( osdF != NULL ) {
2913 TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
2914 (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
2920 Returns name of active component
2922 const QString& QAD_Desktop::getActiveComponent() const
2924 return myActiveComp;
2928 typedef bool defineP( QString & theContext, QString & theParent, QString & theObject);
2930 void QAD_Desktop::definePopup(QString & theContext,
2931 QString & theParent,
2932 QString & theObject )
2934 if (!myActiveComp.isEmpty()) {
2935 OSD_Function osdF = mySharedLibrary.DlSymb("definePopup");
2936 if ( osdF != NULL ) {
2937 defineP (*f1) = (bool (*) (QString &, QString &, QString &)) osdF;
2938 (*f1)(theContext, theParent, theObject);
2946 void QAD_Desktop::createPopup(QPopupMenu* popupFather, QPopupMenu* popup,
2947 QString text, int popupID, bool separator)
2949 QMenuItem* item = popup->findItem(popupID);
2951 QPopupMenu* popupChild = item->popup();
2953 QPopupMenu* newPopup = new QPopupMenu;
2954 int count = popupChild->count();
2955 // add items at the top of <popupFather>
2956 for (int i = count - 1; i >= 0; i--) {
2957 int j = popupChild->idAt(i);
2958 QString text = popupChild->text(j);
2959 createPopup( newPopup, popupChild, text, j);
2961 popupFather->insertItem(popup->text(popupID),
2962 newPopup, popupID, 0);
2964 if ( !text.isNull() ) {
2965 popupFather->insertItem(popup->text(popupID),
2967 SLOT( onDispatch(int) ), 0, popupID, 0);// try adding item at the top
2968 } /*else if ( separator )
2969 popupFather->insertTearOffHandle(-1, 0);*/
2971 popupFather->insertSeparator(0);
2979 void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext,
2980 const QString & theParent, const QString & theObject )
2982 if ( !myActiveComp.isEmpty() &&
2983 getOperatorMenus()->createPopupMenu(theContext,theParent,theObject) != NULL ) {
2984 QPopupMenu* aPopup = getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup();
2985 int count = aPopup->count();
2987 //for (int i = 0; i < count; i++) {
2988 for (int i = count - 1; i >= 0; i--) {
2989 int id = aPopup->idAt(i);
2990 QString text = aPopup->text(id);
2991 //QString mes("Inserting popup menu item loaded from XML: ");
2993 //MESSAGE ( mes.latin1() )
2995 popup->insertItem(aPopup->text(id),
2997 SLOT( onDispatch(int) ), 0, id, 0);// try adding item at the top
2999 createPopup( popup, aPopup, text, id);
3002 //QString mes("Popup does not exist for given (Context = ");
3003 //mes += theContext;
3004 //mes += ", Parent = ";
3006 //mes += ", Object = ";
3008 //MESSAGE (mes.latin1())
3013 // Should be moved to SALOMEGUI_Application::onCreatePopup()...
3014 if ( myActiveComp.isEmpty() ) {
3015 popup->removeItem(QAD_Display_Popup_ID);
3016 popup->removeItem(QAD_DisplayOnly_Popup_ID);
3017 popup->removeItem(QAD_Erase_Popup_ID);
3018 int id = popup->idAt(popup->count()-1); // last item
3019 if (id < 0 && id != -1) popup->removeItem(id); // separator
3021 if ( popup && theParent.compare("ObjectBrowser")==0 ) {
3022 if ( popup->count()>0 ) {
3023 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()), 0, -1, 2);
3024 popup->insertSeparator (3);
3027 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()) );
3034 typedef bool activeStudyChanged(QAD_Desktop*);
3036 void QAD_Desktop::onActiveStudyChanged()
3038 if (!myActiveComp.isEmpty()) {
3039 OSD_Function osdF = mySharedLibrary.DlSymb("activeStudyChanged");
3040 if ( osdF != NULL ) {
3041 activeStudyChanged (*f1) = (bool (*) (QAD_Desktop*)) osdF;
3047 typedef bool customP(QAD_Desktop*, QPopupMenu*, const QString & theContext,
3048 const QString & theParent, const QString & theObject);
3050 Custom popup ( GUI Library )
3052 void QAD_Desktop::customPopup(QPopupMenu* popup, const QString & theContext,
3053 const QString & theParent, const QString & theObject)
3055 if (!myActiveComp.isEmpty()) {
3056 OSD_Function osdF = mySharedLibrary.DlSymb("customPopup");
3057 if ( osdF != NULL ) {
3058 customP (*f1) = (bool (*) (QAD_Desktop*, QPopupMenu*, const QString &,
3059 const QString &, const QString &)) osdF;
3060 (*f1)(this, popup, theContext, theParent, theObject);
3065 void QAD_Desktop::onObjectBrowser()
3067 bool checkDiff = false;
3069 bool state = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn").compare("true") == 0;
3071 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() != state )
3075 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() ) {
3077 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "true");
3080 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "false");
3084 if ( myStdActions.at( PrefObjectBrowserValueId )->isOn() ) {
3086 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "true");
3089 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "false");
3093 if ( myStdActions.at( PrefObjectBrowserIAPPId )->isOn() ) {
3095 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "true");
3098 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "false");
3101 /* To sort created object in chrono order or reverse chrono order */
3102 bool showCHRONO_SORT ;
3103 if ( myStdActions.at( PrefObjectBrowserCHRONO_SORTId )->isOn() ) {
3104 showCHRONO_SORT = true;
3105 QAD_CONFIG->addSetting( "ObjectBrowser:CHRONO_SORT", "true");
3107 showCHRONO_SORT = false;
3108 QAD_CONFIG->addSetting( "ObjectBrowser:CHRONO_SORT", "false");
3111 if ( myActiveApp ) {
3112 QList<QAD_Study>& studies = myActiveApp->getStudies();
3113 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3114 int nbSf = study->getStudyFramesCount();
3115 for ( int i = 0; i < nbSf; i++ ) {
3116 QAD_StudyFrame* sf = study->getStudyFrame(i);
3117 sf->getLeftFrame()->getObjectBrowser()->setShowInfoColumns( showEntry );
3118 sf->getLeftFrame()->getObjectBrowser()->setShowValueColumn( showValue );
3119 sf->getLeftFrame()->getObjectBrowser()->setEnableChronoSort( showCHRONO_SORT );
3120 // sf->getLeftFrame()->getObjectBrowser()->setShowIAPP( showIAPP ); // this is done by below updateObjBrowser() call
3122 study->updateObjBrowser(true);
3127 void QAD_Desktop::onViewerTrihedron()
3129 QString Size = QAD_CONFIG->getSetting("Viewer:TrihedronSize");
3132 SALOMEGUI_TrihedronSizeDlg *Dlg = new SALOMEGUI_TrihedronSizeDlg(this);
3133 if (!Size.isEmpty())
3134 Dlg->setTrihedronSize(Size.toInt());
3135 int r = Dlg->exec();
3136 dim = Dlg->getTrihedronSize();
3139 if (r == QDialog::Accepted) {
3140 QAD_CONFIG->addSetting("Viewer:TrihedronSize", dim);
3143 QList<QAD_Study>& studies = myActiveApp->getStudies();
3144 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3145 int nbSf = study->getStudyFramesCount();
3146 for ( int i = 0; i < nbSf; i++ ) {
3147 study->getStudyFrame(i)->getRightFrame()->getViewFrame()->SetTrihedronSize((int)dim);
3154 void QAD_Desktop::onDirList()
3156 // getting dir list from settings
3157 QStringList dirList = QStringList::split(';', QAD_CONFIG->getSetting("FileDlg:QuickDirList"), false);
3158 QAD_DirListDlg* dlg = new QAD_DirListDlg(this);
3159 dlg->setPathList(dirList);
3160 if ( dlg->exec() == QDialog::Accepted) {
3161 dlg->getPathList(dirList);
3162 QAD_CONFIG->addSetting("FileDlg:QuickDirList", dirList.join(";"));
3167 void QAD_Desktop::onConsoleFontAction()
3169 // getting font from settings
3170 QString fntSet = QAD_CONFIG->getSetting("Viewer:ConsoleFont");
3171 QFont font = QAD_Tools::stringToFont( fntSet );
3173 font = QFontDialog::getFont( &bOk, font, this );
3175 fntSet = QAD_Tools::fontToString( font );
3176 QAD_CONFIG->addSetting("Viewer:ConsoleFont", fntSet );
3179 QList<QAD_Study>& studies = myActiveApp->getStudies();
3180 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3181 int nbSf = study->getStudyFramesCount();
3182 for ( int i = 0; i < nbSf; i++ ) {
3183 study->getStudyFrame(i)->getRightFrame()->getPyEditor()->setFont( font );
3184 study->getStudyFrame(i)->getRightFrame()->getMessage()->setFont( font );
3191 void QAD_Desktop::onSavePref()
3193 QAD_CONFIG->createConfigFile(true);
3196 //VRV: T2.5 - add default viewer
3197 void QAD_Desktop::onDefaultViewer(QActionP * theAction)
3199 int type = VIEW_TYPE_MAX;
3202 if (myStdActions.at(DefaultViewerOCCId) == theAction)
3204 else if (myStdActions.at(DefaultViewerVTKId) == theAction)
3206 else if (myStdActions.at(DefaultGraphSupervisorId) == theAction)
3207 type = VIEW_GRAPHSUPERV;
3208 else if (myStdActions.at(DefaultPlot2dId) == theAction)
3210 if ( type != VIEW_TYPE_MAX )
3211 QAD_CONFIG->addSetting( "Viewer:DefaultViewer", QString::number( type ) );
3213 //VRV: T2.5 - add default viewer
3215 void QAD_Desktop::onViewerOCC()
3217 QString BackgroundColorRed = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorRed");
3218 QString BackgroundColorGreen = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorGreen");
3219 QString BackgroundColorBlue = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorBlue");
3222 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3223 color = QColor(BackgroundColorRed.toInt(),
3224 BackgroundColorGreen.toInt(),
3225 BackgroundColorBlue.toInt());
3227 color = QColor(35, 136, 145);
3229 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3232 if ( myActiveApp ) {
3233 QList<QAD_Study>& studies = myActiveApp->getStudies();
3234 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3235 int nbSf = study->getStudyFramesCount();
3236 for ( int i = 0; i < nbSf; i++ ) {
3237 QAD_StudyFrame* sf = study->getStudyFrame(i);
3238 if ( sf->getTypeView() == VIEW_OCC ) {
3239 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3244 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", c.red() );
3245 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", c.green() );
3246 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", c.blue() );
3250 void QAD_Desktop::onGraphSupervisor()
3252 QString BackgroundColorRed = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed");
3253 QString BackgroundColorGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen");
3254 QString BackgroundColorBlue = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue");
3257 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3258 color = QColor(BackgroundColorRed.toInt(),
3259 BackgroundColorGreen.toInt(),
3260 BackgroundColorBlue.toInt());
3262 color = QColor(35, 136, 145);
3264 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3267 if ( myActiveApp ) {
3268 QList<QAD_Study>& studies = myActiveApp->getStudies();
3269 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3270 int nbSf = study->getStudyFramesCount();
3271 for ( int i = 0; i < nbSf; i++ ) {
3272 QAD_StudyFrame* sf = study->getStudyFrame(i);
3273 if ( sf->getTypeView() == VIEW_GRAPHSUPERV ) {
3274 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3280 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorRed", c.red() );
3281 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorGreen", c.green() );
3282 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorBlue", c.blue() );
3286 void QAD_Desktop::onViewerVTK()
3288 QString BackgroundColorRed = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
3289 QString BackgroundColorGreen = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
3290 QString BackgroundColorBlue = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
3293 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3294 color = QColor(BackgroundColorRed.toInt(),
3295 BackgroundColorGreen.toInt(),
3296 BackgroundColorBlue.toInt());
3298 color = QColor(0, 0, 0);
3300 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3303 if ( myActiveApp ) {
3304 QList<QAD_Study>& studies = myActiveApp->getStudies();
3305 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3306 int nbSf = study->getStudyFramesCount();
3307 for ( int i = 0; i < nbSf; i++ ) {
3308 QAD_StudyFrame* sf = study->getStudyFrame(i);
3309 if ( sf->getTypeView() == VIEW_VTK ) {
3310 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3316 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", c.red() );
3317 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", c.green() );
3318 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", c.blue() );
3322 void QAD_Desktop::onPlot2d()
3325 if ( QAD_CONFIG->hasSetting( "Plot2d:Background" ) ) {
3326 QString bgString = QAD_CONFIG->getSetting( "Plot2d:Background" );
3327 QStringList bgData = QStringList::split( ":", bgString, true );
3328 int bgRed = 0, bgGreen = 0, bgBlue = 0;
3329 if ( bgData.count() > 0 ) bgRed = bgData[ 0 ].toInt();
3330 if ( bgData.count() > 1 ) bgGreen = bgData[ 1 ].toInt();
3331 if ( bgData.count() > 2 ) bgBlue = bgData[ 2 ].toInt();
3332 color = QColor( bgRed, bgGreen, bgBlue );
3335 color = QColor(0, 0, 0);
3338 color = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3340 if ( color.isValid() ) {
3341 if ( myActiveApp ) {
3342 QList<QAD_Study>& studies = myActiveApp->getStudies();
3343 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3344 int nbSf = study->getStudyFramesCount();
3345 for ( int i = 0; i < nbSf; i++ ) {
3346 QAD_StudyFrame* sf = study->getStudyFrame(i);
3347 if ( sf->getTypeView() == VIEW_PLOT2D ) {
3348 sf->getRightFrame()->getViewFrame()->setBackgroundColor( color );
3354 bgData.append( QString::number( color.red() ) );
3355 bgData.append( QString::number( color.green() ) );
3356 bgData.append( QString::number( color.blue() ) );
3357 QAD_CONFIG->addSetting( "Plot2d:Background", bgData.join( ":" ) );
3362 void QAD_Desktop::helpAbout()
3364 SALOMEGUI_AboutDlg* About = new SALOMEGUI_AboutDlg( QAD_Application::getDesktop(), tr("MEN_ABOUT"));
3370 void QAD_Desktop::helpSearch()
3375 void QAD_Desktop::helpContents()
3377 if (myActiveComp == "")
3378 myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
3382 if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
3383 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" );
3384 if ( QFileInfo( root + "index.html" ).exists() ) {
3385 helpContext( root + "index.html", "" );
3388 root = QAD_Tools::addSlash( root + "html" );
3389 if ( QFileInfo( root + "index.html" ).exists() ) {
3390 helpContext( root + "index.html", "" );
3393 root = QAD_Tools::addSlash( root + "html" );
3394 if ( QFileInfo( root + "index.html" ).exists() ) {
3395 helpContext( root + "index.html", "" );
3401 //NRI getHelpWindow()->contents();
3402 getHelpWindow()->show();
3403 getHelpWindow()->raise();
3404 getHelpWindow()->setActiveWindow();
3408 void QAD_Desktop::helpContext(const QString& source, const QString& context)
3410 getHelpWindow()->context(source, context);
3411 getHelpWindow()->show();
3412 getHelpWindow()->raise();
3413 getHelpWindow()->setActiveWindow();
3416 /* Preferences/MultiFile Save */
3417 void QAD_Desktop::onMultiFileSave()
3419 if ( myStdActions.at( PrefMultiFileSave )->isOn() )
3420 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "true");
3422 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "false");
3425 /* Preferences/ASCII Save */
3426 void QAD_Desktop::onASCIISave()
3428 if ( myStdActions.at( PrefASCIISave )->isOn() )
3429 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "true");
3431 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "false");
3434 /*********************************************************************
3435 ** Class: AppSelectionDlg
3436 ** Descr: Dialog for the selection of the application when several
3437 ** applications exist in the desktop and new study creation
3438 ** is activated by user.
3440 **********************************************************************/
3442 \class Desktop_AppSelectionDlg QAD_Desktop.h
3443 \brief Dialog for the selection of the application when several
3444 applications exist in the desktop and new study creation
3445 is activated by user.
3450 Desktop_AppSelectionDlg::Desktop_AppSelectionDlg( QAD_Desktop* desktop,
3451 QList<QAD_Application>& apps ) :
3452 QDialog( desktop, 0, true ),
3456 QAD_ASSERT_DEBUG_ONLY ( desktop );
3457 setCaption( tr("INF_DESK_DOC_CREATE") );
3458 if ( desktop->icon() )
3459 setIcon( *desktop->icon() );
3461 QBoxLayout* mainLayout = new QVBoxLayout( this, 5 );
3463 /* Create selection buttons */
3464 QVButtonGroup* buttonGrp = new QVButtonGroup ( this );
3465 buttonGrp->setExclusive ( true );
3466 QBoxLayout* vLayout = new QVBoxLayout( mainLayout, 5 );
3467 vLayout->addWidget ( buttonGrp );
3469 /* Create selection button for available app */
3471 for ( QAD_Application* app = myApps.first(); app; app = myApps.next(), id++ )
3473 /* add radio button for application */
3474 buttonGrp->insert( new QRadioButton( app->getStudyDescription() +
3475 " (*." + app->getStudyExtension() + ")", buttonGrp ), id );
3478 /* make the first application selected */
3479 buttonGrp->setButton( 0 );
3481 /* listen to the selection */
3482 QAD_ASSERT ( connect ( buttonGrp, SIGNAL(clicked(int)), this, SLOT(onAppSelected(int)) ));
3484 /* Create OK/Cancel buttons
3486 QBoxLayout* hLayout = new QHBoxLayout( mainLayout, 5 );
3487 QPushButton* buttonOK = new QPushButton( tr("BUT_OK"), this );
3488 QPushButton* buttonCancel = new QPushButton( tr("BUT_CANCEL"), this );
3489 QPushButton* buttonHelp = new QPushButton( tr("BUT_HELP"), this );
3490 buttonOK->setDefault( true );
3492 hLayout->addStretch();
3493 hLayout->addWidget( buttonOK );
3494 hLayout->addWidget( buttonCancel );
3495 hLayout->addWidget( buttonHelp );
3497 /* connect buttons */
3498 QAD_ASSERT ( connect( buttonOK, SIGNAL(clicked()), this, SLOT(accept())) );
3499 QAD_ASSERT ( connect( buttonCancel, SIGNAL(clicked()), this, SLOT(reject())) );
3500 QAD_ASSERT ( connect( buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())) );
3502 /* disable resizing */
3503 setFixedSize( 0, 0 );
3504 setSizePolicy( QSizePolicy ( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
3507 Desktop_AppSelectionDlg::~Desktop_AppSelectionDlg()
3511 QAD_Application* Desktop_AppSelectionDlg::selectedApp() const
3513 return myApps.at( myAppId );
3516 void Desktop_AppSelectionDlg::resizeEvent( QResizeEvent* e )
3518 QAD_Tools::centerWidget( this, parentWidget() );
3524 void Desktop_AppSelectionDlg::onAppSelected( int id )
3529 void Desktop_AppSelectionDlg::onHelp()