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
38 #define DEFAULT_BROWSER "mozilla"
43 #include "QAD_Tools.h"
44 #include "QAD_Desktop.h"
45 #include "QAD_LeftFrame.h"
46 #include "QAD_RightFrame.h"
47 #include "QAD_Operation.h"
48 #include "QAD_XmlHandler.h"
49 #include "QAD_MessageBox.h"
50 #include "QAD_Application.h"
51 #include "QAD_Settings.h"
52 #include "QAD_Config.h"
53 #include "QAD_ObjectBrowser.h"
54 #include "QAD_Resource.h"
55 #include "QAD_FileDlg.h"
56 //NRI#include "QAD_HelpWindow.h"
57 #include "QAD_DirListDlg.h"
58 #include "QAD_WaitCursor.h"
59 #include "SALOMEGUI_OpenWith.h"
60 #include "SALOMEGUI_StudyPropertiesDlg.h"
61 #include "SALOMEGUI_TrihedronSizeDlg.h"
62 #include "SALOMEGUI_ExternalBrowserDlg.h"
63 #include "SALOMEGUI_LoadStudiesDlg.h"
64 #include "SALOME_Selection.h"
65 #include "SALOME_InteractiveObject.hxx"
66 #include "SALOME_ListIteratorOfListIO.hxx"
67 #include "SALOMEGUI_AboutDlg.h"
68 #include "SALOMEGUI_ViewChoiceDlg.h"
69 #include "utilities.h"
71 #include "SALOMEGUI_CloseDlg.h"
72 #include "SALOMEGUI_ActivateComponentDlg.h"
77 #include <qmessagebox.h>
78 #include <qcolordialog.h>
79 #include <qradiobutton.h>
80 #include <qapplication.h>
81 #include <qvbuttongroup.h>
83 #include <qmessagebox.h>
86 #include <qpopupmenu.h>
87 #include <qlistview.h>
91 #include <qfontdialog.h>
92 #include <qlineedit.h>
93 #include <qdatetime.h>
101 // Open CASCADE Includes
102 #include <OSD_LoadMode.hxx>
103 #include <OSD_Function.hxx>
104 #include <TCollection_AsciiString.hxx>
106 static const char* SEPARATOR = ":";
113 QAD_ResourceMgr* QAD_Desktop::resourceMgr = 0;
114 QPalette* QAD_Desktop::palette = 0;
118 Creates the resource manager [ static ]
120 QAD_ResourceMgr* QAD_Desktop::createResourceManager()
123 resourceMgr = new QAD_ResourceMgr;
128 Returns the resource manager [ static ]
130 QAD_ResourceMgr* QAD_Desktop::getResourceManager()
137 Loads the palette from settings [ static ]
139 QPalette* QAD_Desktop::createPalette()
142 palette = new QPalette();
148 Returns the palette [ static ]
150 QPalette* QAD_Desktop::getPalette()
156 Gets window ratio width/heght [ static ]
158 static double myWindowRatio = 1;
159 static double getWindowRatio()
161 return myWindowRatio;
165 Sets window ratio width/heght [ static ]
167 static void setWindowRatio(double aRatio)
169 myWindowRatio = aRatio;
175 QAD_Desktop::QAD_Desktop(SALOME_NamingService* name_service) :
176 QMainWindow(0, 0, WType_TopLevel | WDestructiveClose),
182 //NRImyHelpWindow(0),
183 myDefaultTitle( tr("DESK_DEFAULTTITLE") ),
186 /* Force reading of user config file */
187 QAD_CONFIG->readConfigFile();
189 /* menubar and status bar */
190 myStatusBar = statusBar();
191 myMainMenu = menuBar();
193 myNameService = name_service;
195 /* default background icon */
196 QPixmap backgroundicon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
197 tr("ICON_DESK_BACKGROUNDICON") ));
198 //myToolBarAction.setAutoDelete( true );
200 /* default icon and title */
201 QPixmap icon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
202 tr("ICON_DESK_DEFAULTICON") ));
203 if ( !icon.isNull() ) {
204 myDefaultIcon = icon;
205 setIcon( myDefaultIcon );
207 setCaption( myDefaultTitle );
209 /* set size as 1/2 of the screen and center it */
210 QWidget* d = QApplication::desktop();
211 resize( 2*d->width()/3, 2*d->height()/3 );
212 QAD_Tools::centerWidget( this, d );
214 /* workspace will manage child frames */
215 QHBox* border = new QHBox ( this );
216 border->setFrameStyle ( QFrame::Panel | QFrame::Sunken );
217 setCentralWidget( border );
218 myWorkspace = new QWorkspaceP( border );
220 QPalette pal = QAD_Application::getPalette();
222 QColorGroup cgA = pal.active();
223 QColorGroup cgI = pal.inactive();
224 QColorGroup cgD = pal.disabled();
225 cgA.setColor( QColorGroup::Background, QColor(192, 192, 192));
226 cgI.setColor( QColorGroup::Background, QColor(192, 192, 192));
227 cgD.setColor( QColorGroup::Background, QColor(192, 192, 192));
228 pal.setActive ( cgA );
229 pal.setInactive( cgI );
230 pal.setDisabled( cgD );
231 myWorkspace->setPalette( pal );
232 if ( !backgroundicon.isNull() ) {
233 MESSAGE("!!!DESKTOP background icon found!!!");
234 myWorkspace->setPaletteBackgroundPixmap(backgroundicon);
237 /* define standard file commands */
240 /* define operator menus for xml */
241 myOperatorMenus = new QAD_OperatorMenus(this);
242 myXmlHandler = new QAD_XmlHandler();
245 CORBA::Object_var objVarN = myNameService->Resolve("/Kernel/ModulCatalog");
246 myCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
248 SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants =
249 myCatalogue->GetComponentIconeList();
252 QToolBar* tbComponent = new QToolBar( tr("MEN_DESK_COMPONENTTOOLBAR"), this );
253 tbComponent->setCloseMode( QDockWindow::Undocked );
254 addToolBar(tbComponent, tr("MEN_DESK_COMPONENTTOOLBAR"), Bottom, TRUE );
255 setDockEnabled( tbComponent, DockLeft, false );
256 setDockEnabled( tbComponent, DockRight, false );
258 myCombo = new QComboBox( FALSE, tbComponent, "comboBox" );
259 myCombo->setFocusPolicy( NoFocus );
261 tbComponent->addSeparator();
263 // PG : add ResourceManager to get function findFile !!
264 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
266 for (unsigned int ind = 0; ind < list_composants->length();ind++) {
269 /* find component icon */
270 QString iconfile = strdup(list_composants[ind].moduleicone) ;
271 QString modulename = strdup(list_composants[ind].modulename) ;
272 QString moduleusername = strdup(list_composants[ind].moduleusername) ;
274 // MESSAGE ( " MODULE = " << modulename )
275 // MESSAGE ( " MODULE icon = " << iconfile )
276 // MESSAGE ( " MODULE username = " << moduleusername )
278 if ( mapComponentName.contains( moduleusername ) ) {
279 QMessageBox::warning( this, tr("WRN_WARNING"), QString( moduleusername + " is already associated with " + mapComponentName[moduleusername] + ".\nPlease, change the component username of " + modulename) , tr ("BUT_OK") );
282 mapComponentName.insert( moduleusername, modulename );
284 resDir = resMgr->findFile(iconfile,modulename) ;
287 MESSAGE ( "resDir" << resDir )
288 //resDir = QAD_Tools::addSlash(resDir) ;
289 //QPixmap Icone(resDir+iconfile) ;
290 QPixmap Icone( QAD_Tools::addSlash( resDir ) + iconfile );
291 QToolButton * toolb =
292 new QToolButton( QIconSet( Icone ), moduleusername, QString::null, this,
293 SLOT( onButtonActiveComponent () ),tbComponent );
294 toolb->setToggleButton( true );
295 myComponentButton.append(toolb);
299 QString errMsg = tr("INF_ICON_RESOURCES").arg(iconfile).arg(modulename) +
301 //QMessageBox::warning( this, tr("WRN_WARNING"), errMsg, tr ("BUT_OK") );
304 if ( !QString(list_composants[ind].modulename).isEmpty() )
305 myCombo->insertItem( strdup(list_composants[ind].moduleusername) );
309 myCombo->adjustSize();
310 connect( myCombo, SIGNAL(activated(const QString&)),
311 this, SLOT( onComboActiveComponent(const QString&) ) );
313 /* new LifeCycleCORBA client, for Engines */
314 myEnginesLifeCycle = new SALOME_LifeCycleCORBA(name_service);
316 /* VSR 13/01/03 : installing global event filter for the application */
317 qApp->installEventFilter( this );
319 /* init pseudo random numbers generator */
320 QTime cTime = QTime::currentTime();
321 int secs = cTime.second() + 1;
322 for ( int s = 0; s < secs; s++ ) random();
328 QAD_Desktop::~QAD_Desktop ()
330 qApp->removeEventFilter( this );
334 myObjBrowserPopup.clear();
335 //VRV: T2.5 - add default viewer
336 myDefaultViewer.clear();
337 //VRV: T2.5 - add default viewer
338 myViewerPopup.clear();
340 myNewViewPopup.clear();
342 myToolsPopup.clear();
344 myStdActions.clear();
346 myToolBarsPopup.clear();
347 myToolBarAction.clear();
350 //NRI if (myHelpWindow)
351 // myHelpWindow->close();
353 QAD_Application::desktop = 0;
356 const int IdCut = 1001;
357 const int IdCopy = 1002;
358 const int IdPaste = 1003;
359 const int IdSelectAll = 1004;
361 #include <qkeysequence.h>
362 #define ACCEL_KEY(k) "\t" + QString(QKeySequence( Qt::CTRL | Qt::Key_ ## k ))
364 #define ACCEL_KEY(k) "\t" + QString("Ctrl+" #k)
366 #include <qclipboard.h>
368 Global event filter for qapplication (VSR 13/01/03)
370 bool QAD_Desktop::eventFilter( QObject* o, QEvent* e )
372 if (e->type() == 2000 ) {
373 QMessageBox::information (this, tr ( "Help Information" ), tr ( "Can't run choosen browser.\nRunning default browser (Mozilla). "));
376 else if (e->type() == 2001 ) {
377 QMessageBox::critical(this, tr ( "Help Error" ), tr ( "Can't run the default browser.") );
380 else if ( e->type() == QEvent::ContextMenu ) {
381 QContextMenuEvent* ce = (QContextMenuEvent*)e;
382 if ( o->inherits("QRenameEdit") ) {
385 else if ( o->inherits("QLineEdit") ) {
386 QLineEdit* le = (QLineEdit*)o;
387 if ( le->parentWidget() ) {
388 if ( ( le->parentWidget()->inherits("QSpinBox") ||
389 le->parentWidget()->inherits("QSpinWidget") ||
390 le->parentWidget()->inherits("QAD_SpinBoxDbl") ) &&
392 QPopupMenu* popup = new QPopupMenu( 0, "qt_edit_menu" );
393 popup->insertItem( tr( "EDIT_CUT_CMD" ) + ACCEL_KEY( X ), IdCut );
394 popup->insertItem( tr( "EDIT_COPY_CMD" ) + ACCEL_KEY( C ), IdCopy );
395 popup->insertItem( tr( "EDIT_PASTE_CMD" ) + ACCEL_KEY( V ), IdPaste );
396 popup->insertSeparator();
397 #if defined(Q_WS_X11)
398 popup->insertItem( tr( "EDIT_SELECTALL_CMD" ), IdSelectAll );
400 popup->insertItem( tr( "EDIT_SELECTALL_CMD" ) + ACCEL_KEY( A ), IdSelectAll );
402 bool enableCut = !le->isReadOnly() && le->hasSelectedText();
403 popup->setItemEnabled( IdCut, enableCut );
404 popup->setItemEnabled( IdCopy, le->hasSelectedText() );
405 bool enablePaste = !le->isReadOnly() && !QApplication::clipboard()->text().isEmpty();
406 popup->setItemEnabled( IdPaste, enablePaste );
407 bool allSelected = (le->selectedText() == le->text() );
408 popup->setItemEnabled( IdSelectAll, (bool)(le->text().length()) && !allSelected );
410 QPoint pos = ce->reason() == QContextMenuEvent::Mouse ? ce->globalPos() :
411 le->mapToGlobal( QPoint(ce->pos().x(), 0) ) + QPoint( le->width() / 2, le->height() / 2 );
413 int r = popup->exec( pos );
435 return QMainWindow::eventFilter( o, e );
439 Creates and initializes the standard file operations
440 such as 'New/Open/Save/SaveAs/Close' and 'Help'.
442 void QAD_Desktop::createActions()
445 /* Used for string compare */
446 const QString& aTrueQString = "true" ;
448 /* create 'standard' toolbar */
449 if ( !myStdToolBar ) {
450 myStdToolBar = new QToolBar ( tr("MEN_DESK_VIEW_STDTOOLBAR"), this );
451 myStdToolBar->setCloseMode( QDockWindow::Undocked );
454 if ( !myMainMenu->count() ) {
455 /* Create main menu bar */
456 myMainMenu->insertItem ( tr("MEN_DESK_FILE"), &myFilePopup, 1 ); /* add popup FILE */
457 myMainMenu->insertItem ( tr("MEN_DESK_VIEW"), &myViewPopup, 2 ); /* add popup VIEW */
458 myMainMenu->insertItem ( tr("MEN_DESK_TOOLS"), &myToolsPopup, 5 ); /* add popup TOOLS */
459 myMainMenu->insertItem ( tr("MEN_DESK_PREF"), &myPrefPopup, 4 ); /* add popup PREF */
460 myMainMenu->insertItem ( tr("MEN_DESK_WINDOW"), &myWindowPopup, 6 );/* add popup WINDOW */
461 myMainMenu->insertItem ( tr("MEN_DESK_HELP"), &myHelpPopup, 7 ); /* add popup HELP */
463 /* Applications will insert their items after 'File' 'Edit' and 'View'
464 ( 'Edit' will be inserted later )
469 /* insert logo picture to menu bar */
470 QHBox* aLogoFrm = new QHBox(this);
471 aLogoFrm->setFrameStyle( QFrame::Plain | QFrame::NoFrame );
472 QPixmap aLogoPixmap ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT",
473 tr("ICON_DESK_LOGO") ));
474 QLabel* aLogoLab = new QLabel(aLogoFrm);
475 aLogoLab->setPixmap(aLogoPixmap);
476 aLogoLab->setAlignment(AlignCenter);
477 aLogoLab->setScaledContents(false);
478 myMainMenu->insertItem(aLogoFrm);
480 if ( myStdActions.isEmpty() ) {
481 /* Define standard actions. They should be inserted
482 into the list in order of their IDs.
487 QAD_ResourceMgr* rmgr = QAD_Desktop::getResourceManager();
488 QActionP* fileNewAction = new QActionP ( tr("TOT_DESK_FILE_NEW"),
489 rmgr->loadPixmap( "QAD", tr("ICON_FILE_NEW") ) ,
490 tr("MEN_DESK_FILE_NEW"), CTRL+Key_N, this );
491 fileNewAction->setStatusTip ( tr("PRP_DESK_FILE_NEW") );
492 fileNewAction->setEnabled ( true );
493 QAD_ASSERT ( connect( fileNewAction, SIGNAL( activated() ), this, SLOT( onNewStudy() )));
494 fileNewAction->addTo( myStdToolBar );
495 fileNewAction->addTo( &myFilePopup );
496 myStdActions.insert ( FileNewId, fileNewAction );
499 QActionP* fileOpenAction = new QActionP( tr("TOT_DESK_FILE_OPEN"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_OPEN") ),
500 tr("MEN_DESK_FILE_OPEN"), CTRL+Key_O, this );
501 fileOpenAction->setStatusTip ( tr("PRP_DESK_FILE_OPEN") );
502 fileOpenAction->setEnabled ( true );
503 QAD_ASSERT ( connect( fileOpenAction, SIGNAL( activated() ), this, SLOT( onOpenStudy() )));
504 fileOpenAction->addTo( myStdToolBar );
505 fileOpenAction->addTo( &myFilePopup );
506 myStdActions.insert ( FileOpenId, fileOpenAction );
509 QActionP* fileLoadAction = new QActionP( tr("TOT_DESK_FILE_LOAD"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_LOAD") ),
510 tr("MEN_DESK_FILE_LOAD"), CTRL+Key_L, this );
511 fileLoadAction->setStatusTip ( tr("PRP_DESK_FILE_LOAD") );
512 fileLoadAction->setEnabled ( true );
513 QAD_ASSERT ( connect( fileLoadAction, SIGNAL( activated() ), this, SLOT( onLoadStudy() )));
514 fileLoadAction->addTo( &myFilePopup );
515 myStdActions.insert ( FileLoadId, fileLoadAction );
518 QActionP* fileCloseAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_FILE_CLOSE") ),
519 tr("MEN_DESK_FILE_CLOSE"), CTRL+Key_W, this );
520 fileCloseAction->setStatusTip ( tr("PRP_DESK_FILE_CLOSE") );
521 QAD_ASSERT ( connect( fileCloseAction, SIGNAL( activated() ), this, SLOT( onCloseStudy() )));
522 fileCloseAction->addTo( &myFilePopup );
523 myStdActions.insert ( FileCloseId, fileCloseAction );
526 myFilePopup.insertSeparator();
529 QActionP* fileSaveAction = new QActionP( tr("TOT_DESK_FILE_SAVE"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_SAVE") ),
530 tr("MEN_DESK_FILE_SAVE"), CTRL+Key_S, this );
531 fileSaveAction->setStatusTip ( tr("PRP_DESK_FILE_SAVE") );
532 QAD_ASSERT ( connect( fileSaveAction, SIGNAL( activated() ), this, SLOT( onSaveStudy() )));
533 fileSaveAction->addTo( myStdToolBar );
534 fileSaveAction->addTo( &myFilePopup );
535 myStdActions.insert ( FileSaveId, fileSaveAction );
538 QActionP* fileSaveAsAction = new QActionP( "", tr("MEN_DESK_FILE_SAVEAS"), 0, this );
539 fileSaveAsAction->setStatusTip ( tr("PRP_DESK_FILE_SAVEAS") );
540 QAD_ASSERT ( connect( fileSaveAsAction, SIGNAL( activated() ),
541 this, SLOT( onSaveAsStudy() )));
542 fileSaveAsAction->addTo( &myFilePopup );
543 myStdActions.insert ( FileSaveAsId, fileSaveAsAction );
547 myFilePopup.insertSeparator();
550 QActionP* filePropsAction = new QActionP( "", QPixmap(), tr("MEN_DESK_FILE_PROPERTIES"), 0, this );
551 filePropsAction->setStatusTip ( tr("PRP_DESK_FILE_PROPERTIES") );
552 filePropsAction->setEnabled(false);
553 QAD_ASSERT ( connect( filePropsAction, SIGNAL( activated() ), this, SLOT( onStudyProperties() )));
554 filePropsAction->addTo( &myFilePopup );
555 myStdActions.insert ( FilePropsId, filePropsAction );
558 int id = myFilePopup.insertSeparator();
559 /* keep the position from which an application will insert its items
560 to menu 'File' at the time of customization of the desktop */
562 myFilePos = myFilePopup.indexOf( id ) + 1;
564 /* exit application */
565 QActionP* exitAction = new QActionP( "", tr("MEN_DESK_FILE_EXIT"),
567 exitAction->setStatusTip ( tr("PRP_DESK_FILE_EXIT") );
568 QAD_ASSERT ( connect( exitAction, SIGNAL( activated() ),
569 this, SLOT( onExit() )));
570 exitAction->addTo( &myFilePopup );
571 myStdActions.insert ( FileExitId, exitAction );
573 /* 'Edit' actions : provided by application only */
577 /* toolbars popup menu */
578 myViewPopup.insertItem( tr("MEN_DESK_VIEW_TOOLBARS"), &myToolBarsPopup );
579 QAD_ASSERT( connect ( &myViewPopup, SIGNAL(aboutToShow()),
580 this, SLOT(onToolBarPopupAboutToShow()) ));
583 QActionP* viewStatusBarAction = new QActionP( "",
584 tr("MEN_DESK_VIEW_STATUSBAR"),
586 viewStatusBarAction->setStatusTip ( tr("PRP_DESK_VIEW_STATUSBAR") );
587 viewStatusBarAction->setOn( true );
588 QAD_ASSERT(connect( viewStatusBarAction, SIGNAL(activated()), this, SLOT(onViewStatusBar() )));
589 viewStatusBarAction->addTo( &myViewPopup );
590 myStdActions.insert( ViewStatusBarId, viewStatusBarAction );
592 // myViewPopup.insertItem( tr("MEN_DESK_SELECTION_MODE"), &mySelectionModePopup );
594 QActionP* SelectionPointAction = new QActionP( "", tr("MEN_DESK_SELECTION_POINT"), 0, this, 0, true );
595 QAD_ASSERT(connect( SelectionPointAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
596 SelectionPointAction->addTo( &mySelectionModePopup );
597 myStdActions.insert( SelectionPointId, SelectionPointAction );
599 QActionP* SelectionEdgeAction = new QActionP( "", tr("MEN_DESK_SELECTION_EDGE"), 0, this, 0, true );
600 QAD_ASSERT(connect( SelectionEdgeAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
601 SelectionEdgeAction->addTo( &mySelectionModePopup );
602 myStdActions.insert( SelectionEdgeId, SelectionEdgeAction );
604 QActionP* SelectionCellAction = new QActionP( "", tr("MEN_DESK_SELECTION_CELL"), 0, this, 0, true );
605 QAD_ASSERT(connect( SelectionCellAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
606 SelectionCellAction->addTo( &mySelectionModePopup );
607 myStdActions.insert( SelectionCellId, SelectionCellAction );
609 QActionP* SelectionActorAction = new QActionP( "", tr("MEN_DESK_SELECTION_ACTOR"), 0, this, 0, true );
610 QAD_ASSERT(connect( SelectionActorAction, SIGNAL(activated()), this, SLOT(onSelectionMode() )));
611 SelectionActorAction->addTo( &mySelectionModePopup );
612 myStdActions.insert( SelectionActorId, SelectionActorAction );
613 SelectionActorAction->setOn(true);
615 myViewPos = myViewPopup.count();
618 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
621 if(!resMgr->loadResources( "ToolsGUI", msg ))
623 //NRI QCString errMsg;
624 // errMsg.sprintf( "Do not load all resources for module ToolsGUI.\n" );
625 QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
629 myOperatorMenus = new QAD_OperatorMenus(this);
630 myXmlHandler = new QAD_XmlHandler();
631 ASSERT(myXmlHandler) ;
632 myXmlHandler->setMainWindow(this);
633 if ( myXmlHandler->setComponent( resMgr->resources( "ToolsGUI" ) ) ) {
634 QString language = resMgr->language( "ToolsGUI" );
635 QString ToolsXml = QString( "Tools_" ) + language + QString( ".xml" );
637 //ToolsXml = resMgr->resources("ToolsGUI") ;
638 //ToolsXml = QAD_Tools::addSlash(ToolsXml) ;
639 //ToolsXml = ToolsXml + "Tools_" + language + ".xml" ;
640 ToolsXml = QAD_Tools::addSlash( resMgr->findFile( ToolsXml, "ToolsGUI" ) ) + ToolsXml;
642 QFile file( QAD_Tools::unix2win( ToolsXml ) );
643 if ( file.exists() && file.open( IO_ReadOnly ) ) {
645 QXmlInputSource source( file );
646 QXmlSimpleReader reader;
647 reader.setContentHandler( myXmlHandler );
648 reader.setErrorHandler( myXmlHandler );
649 bool ok = reader.parse( source );
652 QMessageBox::critical( 0,
653 tr( "INF_PARSE_ERROR" ),
654 tr( myXmlHandler->errorProtocol() ) );
656 myMenusList=myXmlHandler->myMenusList;
657 myActiveMenus=myMenusList.at(0);
658 myOperatorMenus->showMenuBar(0);
659 myActiveMenus->showAllToolBars();
665 if ( myToolsPopup.count() == 0 ) {
666 myMainMenu->removeItem(5);
670 /* Viewer BackgroundColor */
671 myPrefPopup.insertItem( tr("MEN_DESK_PREF_VIEWER"), &myViewerPopup );
673 QActionP* viewerOCCAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this );
674 QAD_ASSERT(connect( viewerOCCAction, SIGNAL(activated()), this, SLOT(onViewerOCC() )));
675 viewerOCCAction->addTo( &myViewerPopup );
676 myStdActions.insert( PrefViewerOCCId, viewerOCCAction );
678 QActionP* viewerVTKAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this );
679 QAD_ASSERT(connect( viewerVTKAction, SIGNAL(activated()), this, SLOT(onViewerVTK() )));
680 viewerVTKAction->addTo( &myViewerPopup );
681 myStdActions.insert( PrefViewerVTKId, viewerVTKAction );
683 QActionP* graphSupervisorAction = new QActionP( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this );
684 QAD_ASSERT(connect( graphSupervisorAction, SIGNAL(activated()), this, SLOT(onGraphSupervisor() )));
685 graphSupervisorAction->addTo( &myViewerPopup );
686 myStdActions.insert( PrefGraphSupervisorId, graphSupervisorAction );
688 QActionP* viewerPlot2dAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this );
689 QAD_ASSERT(connect( viewerPlot2dAction, SIGNAL(activated()), this, SLOT(onPlot2d() )));
690 viewerPlot2dAction->addTo( &myViewerPopup );
691 myStdActions.insert( PrefViewerPlot2dId, viewerPlot2dAction );
693 //VRV: T2.5 - add default viewer
694 QString viewerValue = QAD_CONFIG->getSetting( "Viewer:DefaultViewer" );
696 int aViewerValue = viewerValue.toInt( &ok, 10 );
697 if (!ok || aViewerValue < VIEW_OCC || aViewerValue >= VIEW_TYPE_MAX)
698 aViewerValue = VIEW_VTK;
700 myPrefPopup.insertItem( tr("MEN_DESK_PREF_DEFAULT_VIEWER"), &myDefaultViewer );
701 QActionPGroup* myQAG = new QActionPGroup ( this);
702 QActionP* viewerOCCAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this );
703 viewerOCCAction1->setToggleAction ( true);
704 viewerOCCAction1->setOn ( aViewerValue == VIEW_OCC );
705 myQAG->insert( viewerOCCAction1 );
706 myStdActions.insert( DefaultViewerOCCId, viewerOCCAction1 );
708 QActionP* viewerVTKAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this );
709 viewerVTKAction1->setToggleAction ( true);
710 viewerVTKAction1->setOn ( aViewerValue == VIEW_VTK );
711 myQAG->insert( viewerVTKAction1 );
712 myStdActions.insert( DefaultViewerVTKId, viewerVTKAction1 );
714 /* Remove Supervisor viewer from setting the background */
715 // QActionP* graphSupervisorAction1 = new QActionP( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this );
716 // graphSupervisorAction1->setToggleAction ( true);
717 // graphSupervisorAction1->setOn ( aViewerValue == VIEW_GRAPHSUPERV );
718 // myQAG->insert( graphSupervisorAction1 );
719 // myStdActions.insert( DefaultGraphSupervisorId, graphSupervisorAction1 );
721 QActionP* viewerPlot2dAction1 = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this );
722 viewerPlot2dAction1->setToggleAction ( true);
723 viewerPlot2dAction1->setOn ( aViewerValue == VIEW_PLOT2D );
724 myQAG->insert( viewerPlot2dAction1 );
725 myStdActions.insert( DefaultPlot2dId, viewerPlot2dAction1 );
727 myQAG->addTo( &myDefaultViewer );
728 QAD_ASSERT(connect( myQAG, SIGNAL(selected(QActionP * )), this, SLOT(onDefaultViewer(QActionP *) )));
729 //VRV: T2.5 - add default viewer
731 QActionP* viewerTrihedronAction = new QActionP( "", tr("MEN_DESK_PREF_VIEWER_TRIHEDRON"), 0, this );
732 QAD_ASSERT(connect( viewerTrihedronAction, SIGNAL(activated()), this, SLOT(onViewerTrihedron() )));
733 viewerTrihedronAction->addTo( &myPrefPopup );
734 myStdActions.insert( PrefViewerTrihedronId, viewerTrihedronAction );
736 QActionP* consoleFontAction = new QActionP( "", tr("MEN_DESK_PREF_CONSOLE_FONT"), 0, this );
737 QAD_ASSERT(connect( consoleFontAction, SIGNAL(activated()), this, SLOT(onConsoleFontAction() )));
738 consoleFontAction->addTo( &myPrefPopup );
739 myStdActions.insert( PrefConsoleFontId, consoleFontAction );
742 QActionP* multiFileSaveAction = new QActionP( "", tr("MEN_DESK_PREF_MULTI_FILE_SAVE"), 0, this, 0, true );
743 QAD_ASSERT(connect( multiFileSaveAction, SIGNAL(activated()), this, SLOT(onMultiFileSave() )));
744 multiFileSaveAction->setToggleAction( true );
745 QString MultiSave = QAD_CONFIG->getSetting("Desktop:MultiFileSave");
746 multiFileSaveAction->setOn( MultiSave.compare( aTrueQString ) == 0 );
747 multiFileSaveAction->addTo( &myPrefPopup );
748 myStdActions.insert( PrefMultiFileSave, multiFileSaveAction );
751 QActionP* ASCIISaveAction = new QActionP( "", tr("MEN_DESK_PREF_ASCII_SAVE"), 0, this, 0, true );
752 QAD_ASSERT(connect( ASCIISaveAction, SIGNAL(activated()), this, SLOT(onASCIISave() )));
753 ASCIISaveAction->setToggleAction( true );
754 QString ASCIISave = QAD_CONFIG->getSetting("Desktop:ASCIISave");
755 ASCIISaveAction->setOn( ASCIISave.compare( aTrueQString ) == 0 );
756 ASCIISaveAction->addTo( &myPrefPopup );
757 myStdActions.insert( PrefASCIISave, ASCIISaveAction );
759 myPrefPopup.insertSeparator();
761 /* External Browser */
762 QActionP* externalBrowserAction = new QActionP( "", tr("MEN_DESK_PREF_EXTERNAL_BROWSER"), 0, this );
763 QAD_ASSERT(connect( externalBrowserAction, SIGNAL(activated()), this, SLOT(onExternalBrowser() )));
764 externalBrowserAction->addTo( &myPrefPopup );
765 myStdActions.insert( PrefExternalBrowserId, externalBrowserAction );
767 myPrefPopup.insertSeparator();
769 myPrefPopup.insertItem( tr("MEN_DESK_PREF_OBJECTBROWSER"), &myObjBrowserPopup );
771 QActionP* objectBrowserEntryAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_ENTRY"), 0, this, 0, true );
772 QAD_ASSERT(connect( objectBrowserEntryAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
773 objectBrowserEntryAction->setToggleAction(true);
774 QString AddColumn = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn");
776 if ( AddColumn.compare( aTrueQString ) == 0 )
777 objectBrowserEntryAction->setOn(true);
779 objectBrowserEntryAction->setOn(false);
781 objectBrowserEntryAction->addTo( &myObjBrowserPopup );
782 myStdActions.insert( PrefObjectBrowserEntryId, objectBrowserEntryAction );
784 QActionP* objectBrowserValueAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_VALUE"), 0, this, 0, true );
785 QAD_ASSERT(connect( objectBrowserValueAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
786 objectBrowserValueAction->setToggleAction(true);
787 QString ValueColumn = QAD_CONFIG->getSetting("ObjectBrowser:ValueColumn");
789 if ( ValueColumn.compare( aTrueQString ) == 0 )
790 objectBrowserValueAction->setOn(true);
792 objectBrowserValueAction->setOn(false);
794 objectBrowserValueAction->addTo( &myObjBrowserPopup );
795 myStdActions.insert( PrefObjectBrowserValueId, objectBrowserValueAction );
797 QActionP* objectBrowserIAPPAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_IAPP"), 0, this, 0, true );
798 QAD_ASSERT(connect( objectBrowserIAPPAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
799 objectBrowserIAPPAction->setToggleAction(true);
800 QString showIAPP = QAD_CONFIG->getSetting("ObjectBrowser:IAPP");
802 if ( showIAPP.compare( aTrueQString ) == 0 )
803 objectBrowserIAPPAction->setOn(true);
805 objectBrowserIAPPAction->setOn(false);
807 objectBrowserIAPPAction->addTo( &myObjBrowserPopup );
808 myStdActions.insert( PrefObjectBrowserIAPPId, objectBrowserIAPPAction );
810 /* Chronological sorting of shapes on the entry creation */
811 QActionP* objectBrowserCHRONO_SORTAction = new QActionP( "", tr("MEN_DESK_PREF_OBJECTBROWSER_CHRONO_SORT"), 0, this, 0, true );
812 QAD_ASSERT(connect( objectBrowserCHRONO_SORTAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() )));
813 objectBrowserCHRONO_SORTAction->setToggleAction(true);
814 QString showSORT = QAD_CONFIG->getSetting("ObjectBrowser:CHRONO_SORT");
816 if ( showSORT.compare( aTrueQString ) == 0 )
817 objectBrowserCHRONO_SORTAction->setOn(true) ;
819 objectBrowserCHRONO_SORTAction->setOn(false) ;
821 objectBrowserCHRONO_SORTAction->addTo( &myObjBrowserPopup );
822 myStdActions.insert( PrefObjectBrowserCHRONO_SORTId, objectBrowserCHRONO_SORTAction ) ;
824 myPrefPopup.insertSeparator();
826 QActionP* dirAction = new QActionP( "", tr("MEN_DESK_PREF_DIRICTORIES"), ALT+Key_D, this );
827 QAD_ASSERT(connect( dirAction, SIGNAL(activated()), this, SLOT(onDirList() )));
828 dirAction->addTo( &myPrefPopup );
829 myStdActions.insert( PrefDirsId, dirAction );
831 myPrefPopup.insertSeparator();
833 QActionP* saveAction = new QActionP( "", tr("MEN_DESK_PREF_SAVE"), 0, this );
834 QAD_ASSERT(connect( saveAction, SIGNAL(activated()), this, SLOT(onSavePref() )));
835 saveAction->addTo( &myPrefPopup );
836 myStdActions.insert( PrefSaveId, saveAction );
838 /* 'Window' actions */
841 myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId );
843 QActionP* viewOCCAction = new QActionP( "", tr("MEN_DESK_VIEW_OCC"), ALT+Key_O, this );
844 QAD_ASSERT(connect( viewOCCAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
845 viewOCCAction->addTo( &myNewViewPopup );
846 myStdActions.insert( ViewOCCId, viewOCCAction );
848 QActionP* viewVTKAction = new QActionP( "", tr("MEN_DESK_VIEW_VTK"), ALT+Key_K, this );
849 QAD_ASSERT(connect( viewVTKAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
850 viewVTKAction->addTo( &myNewViewPopup );
851 myStdActions.insert( ViewVTKId, viewVTKAction );
853 QActionP* viewPlot2dAction = new QActionP( "", tr("MEN_DESK_VIEW_PLOT2D"), ALT+Key_P, this );
854 QAD_ASSERT(connect( viewPlot2dAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() )));
855 viewPlot2dAction->addTo( &myNewViewPopup );
856 myStdActions.insert( ViewPlot2dId, viewPlot2dAction );
858 // QActionP* windowNew3dAction = new QActionP( "",/* rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_NEW3D") ), */
859 /*tr("MEN_DESK_WINDOW_NEW3D"), 0, this );
860 windowNew3dAction->addTo( &myWindowPopup );
861 QAD_ASSERT( connect( windowNew3dAction, SIGNAL(activated()), this ,
862 SLOT( onNewWindow3d() )));
863 myStdActions.insert( WindowNew3dId, windowNew3dAction );
869 QActionP* windowCascadeAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_CASCADE") ),
870 tr("MEN_DESK_WINDOW_CASCADE"), 0, this );
871 windowCascadeAction->setStatusTip ( tr("PRP_DESK_WINDOW_CASCADE") );
872 QAD_ASSERT( connect( windowCascadeAction, SIGNAL(activated()), this,
873 SLOT( onCascade() )));
874 myStdActions.insert( WindowCascadeId, windowCascadeAction );
877 QActionP* windowTileAction = new QActionP( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_TILE") ),
878 tr("MEN_DESK_WINDOW_TILE"), 0, this );
879 windowTileAction->setStatusTip ( tr("PRP_DESK_WINDOW_TILE") );
880 QAD_ASSERT( connect( windowTileAction, SIGNAL(activated()), myWorkspace, SLOT( tile() )));
881 myStdActions.insert( WindowTileId, windowTileAction );
883 QAD_ASSERT( connect ( &myWindowPopup, SIGNAL(aboutToShow()),
884 this, SLOT(onWindowPopupAboutToShow()) ));
888 QActionP* helpContentsAction = new QActionP( "", tr("MEN_DESK_HELP_CONTENTS"), Key_F1, this );
889 helpContentsAction->setStatusTip ( tr("PRP_DESK_HELP_CONTENTS") );
890 QAD_ASSERT(connect( helpContentsAction, SIGNAL(activated()),
891 this, SLOT( onHelpContents() )));
892 helpContentsAction->addTo( &myHelpPopup );
893 myStdActions.insert( HelpContentsId , helpContentsAction );
895 id = myHelpPopup.insertSeparator();
898 // NRI : Temporary commented
900 // QActionP* helpContentsActionGUI = new QActionP( "", tr("MEN_DESK_HELP_GUICONTENTS"), 0, this );
901 // helpContentsActionGUI->setStatusTip ( tr("PRP_DESK_HELP_GUICONTENTS") );
902 // QAD_ASSERT(connect( helpContentsActionGUI, SIGNAL(activated()),
903 // this, SLOT( onHelpContentsGUI() )));
904 // helpContentsActionGUI->addTo( &myHelpPopup );
905 // myStdActions.insert( HelpContentsId , helpContentsActionGUI );
908 QActionP* helpContentsActionTUI = new QActionP( "", tr("MEN_DESK_HELP_TUICONTENTS"), 0, this );
909 helpContentsActionTUI->setStatusTip ( tr("PRP_DESK_HELP_TUICONTENTS") );
910 QAD_ASSERT(connect( helpContentsActionTUI, SIGNAL(activated()),
911 this, SLOT( onHelpContentsTUI() )));
912 helpContentsActionTUI->addTo( &myHelpPopup );
913 myStdActions.insert( HelpContentsId , helpContentsActionTUI );
916 // QActionP* helpSearchAction = new QActionP( "", tr("MEN_DESK_HELP_SEARCH"), 0, this );
917 // helpSearchAction->setStatusTip ( tr("PRP_DESK_HELP_SEARCH") );
918 // QAD_ASSERT( connect( helpSearchAction, SIGNAL(activated()), this, SLOT( onHelpSearch() )));
919 // helpSearchAction->addTo( &myHelpPopup );
920 // myStdActions.insert( HelpSearchId, helpSearchAction );
923 // QActionP* helpWhatsThisAction = new QActionP( "", tr("MEN_DESK_HELP_WHATSTHIS"), SHIFT+Key_F1, this );
924 // helpWhatsThisAction->setStatusTip ( tr("PRP_DESK_HELP_WHATSTHIS" ));
925 // QAD_ASSERT( connect( helpWhatsThisAction, SIGNAL(activated()), this, SLOT( whatsThis() )));
926 // helpWhatsThisAction->addTo( &myHelpPopup );
927 // myStdActions.insert( HelpWhatsThisId, helpWhatsThisAction );
928 // (void)QWhatsThis::whatsThisButton( myStdToolBar );
930 id = myHelpPopup.insertSeparator();
931 myHelpPos = myHelpPopup.indexOf( id );
934 QActionP* helpAboutAction = new QActionP( "", tr("MEN_DESK_HELP_ABOUT"), 0, this );
935 helpAboutAction->setStatusTip ( tr("PRP_DESK_HELP_ABOUT") );
936 QAD_ASSERT( connect( helpAboutAction, SIGNAL(activated()), this, SLOT( onHelpAbout() )));
937 helpAboutAction->addTo( &myHelpPopup );
938 myStdActions.insert(HelpAboutId, helpAboutAction );
944 Adds the given application into the list of supported applications
946 void QAD_Desktop::addApplication(QAD_Application* app)
948 /* add only if is not already in the list */
949 if ( myApps.findRef( app ) == -1 )
951 myApps.append( app );
953 /* set activation/deactivation listener */
954 QAD_ASSERT ( connect( app, SIGNAL(appActivated(QAD_Application*)),
955 this, SLOT(onActivateApp(QAD_Application*))) );
957 QAD_ASSERT ( connect( app, SIGNAL(appDeactivated(QAD_Application*)),
958 this, SLOT(onDeactivateApp(QAD_Application*))) );
963 Displays the control panel of the application.
964 This function is called when the desktop is shown first time.
966 void QAD_Desktop::showDesktop()
972 Closes Desktop. If <forceClose> is true query for exit will be skipped.
974 void QAD_Desktop::closeDesktop( bool forceClose )
977 myQueryClose = false;
982 Puts the message to the status bar
984 void QAD_Desktop::putInfo ( const QString& msg )
987 //NRI : bug 1209. message is now displayed during 3000 ms
988 myStatusBar->message ( msg, 3000 );
992 Puts the message to the status bar for ms milli-seconds
994 void QAD_Desktop::putInfo ( const QString& msg, int ms )
997 myStatusBar->message ( msg, ms );
1001 Returns the standard toolbar
1003 QMenuBar* QAD_Desktop::getMainMenuBar() const
1009 Returns the standard toolbar
1011 QToolBar* QAD_Desktop::getStdToolBar() const
1013 return myStdToolBar;
1017 Updates desktop panel (menu, toolbar and status bar) according to current state of
1018 the application. Calls update() for the active application.
1019 The command { UD_ADD_APP or UD_REMOVE_APP ) specifies the desktop components
1020 will be changed according to new active application.
1021 This function is called after activating new study, closing current study etc.
1023 void QAD_Desktop::updateDesktop( UpdateCommand cmd )
1026 updateToolBars( cmd );
1027 updateStatusBar( cmd );
1032 Updates the desktop caption
1034 void QAD_Desktop::updateCaption( UpdateCommand cmd )
1036 if ( cmd == ActivateApp )
1037 { /* application's icon and title */
1038 setIcon( myActiveApp->getApplicationIcon() );
1039 setCaption( myActiveApp->getApplicationName() );
1042 { /* default icon and title */
1043 setIcon( myDefaultIcon );
1044 qApp->processEvents();
1045 setCaption( myDefaultTitle );
1050 Updates status bar when a new application becomes current
1052 void QAD_Desktop::updateStatusBar( UpdateCommand cmd )
1056 bool activate = ( cmd == ActivateApp );
1057 myActiveApp->updateStatusBar ( myStatusBar, activate );
1062 Updates toolbars according to current active application.
1063 This function is called from updateDesktop().
1065 void QAD_Desktop::updateToolBars( UpdateCommand cmd )
1069 bool activate = ( cmd == ActivateApp );
1070 myActiveApp->updateToolBars ( activate );
1075 Updates main menu bar of the application when application is activated
1077 This function is called by updateDesktop()
1079 void QAD_Desktop::updateMenu( UpdateCommand cmd )
1083 bool activate = ( cmd == ActivateApp );
1084 myActiveApp->updateFilePopup( &myFilePopup, activate, myFilePos );
1085 myActiveApp->updateEditPopup( &myEditPopup, activate, myEditPos );
1086 myActiveApp->updateViewPopup( &myViewPopup, activate, myViewPos );
1087 myActiveApp->updateHelpPopup( &myHelpPopup, activate, myHelpPos );
1088 myActiveApp->updateMainMenu( myMainMenu, activate, myMainMenuPos );
1091 Since 'Edit' popup is completely customized by applications
1092 desktop doesn't show it in main menubar without the active
1093 application and we insert/remove this popup from the menubar
1094 when activating/deactivating applications.
1096 We can't have 'Edit' popup be customized by an application
1097 via UpdateMainMenu() method because applications may insert
1098 its items to the menubar only AFTER 'View' item ( this fact
1099 is respected by myMainMenuPos ) and the possibility of an
1100 application to add its items into any arbitrary positions of
1101 the main menubar requires a bit sophisticated implementation,
1102 so we decided to avoid it, sorry :-(.
1104 #if defined( DEBUG )
1106 /* applications MUST clear 'Edit' after themselves */
1107 QAD_ASSERT_DEBUG_ONLY( !myEditPopup.count() );
1110 if ( activate ) /* insert after 'File' item */
1111 myMainMenu->insertItem( tr("MEN_DESK_EDIT"), &myEditPopup, 3, 1 );
1113 myMainMenu->removeItem( 3 );
1118 Returns icon file name used by the application
1120 const QPixmap& QAD_Desktop::getDefaultIcon() const
1122 static QPixmap defaultPixmap( QAD_Desktop::getResourceManager()->loadPixmap( "QAD",
1123 tr("ICON_DESK_DEFAULTICON") ));
1124 return defaultPixmap;
1128 Returns name of the application used as the title of desktop panel
1130 const QString& QAD_Desktop::getDefaultTitle() const
1132 static QString defaultTitle ( tr("DESK_DEFAULTTITLE") );
1133 return defaultTitle;
1137 Returns default name of new studies
1139 const QString& QAD_Desktop::getDefaultStudyName() const
1141 static QString defaultStudyName( tr("DESK_DEFAULTDOC") );
1142 return defaultStudyName;
1146 Returns next name for new study
1148 QString QAD_Desktop::getNewStudyName()
1151 number.sprintf( "%d", ++myCntUntitled );
1152 return ( getDefaultStudyName() + number );
1156 Searches QAD_Study corresponding to <study>, returns NULL if fails
1158 QAD_Study* QAD_Desktop::findStudy( SALOMEDS::Study_ptr theStudy )
1160 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1161 QList<QAD_Study> studies;
1162 studies.setAutoDelete( false );
1163 studies = app->getStudies();
1164 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
1165 if ( study->getStudyDocument()->_is_equivalent( theStudy ) )
1173 Returns current active application
1175 QAD_Application* QAD_Desktop::getActiveApp() const
1181 Returns current active study
1183 QAD_Study* QAD_Desktop::getActiveStudy() const
1185 return myActiveStudy;
1191 QWorkspaceP* QAD_Desktop::getMainFrame() const
1197 Find or load Engine, given a container name and an engine name
1199 Engines::Component_var QAD_Desktop::getEngine(const char *containerName,
1200 const char *componentName)
1202 Engines::Component_var eng =
1203 myEnginesLifeCycle->FindOrLoad_Component(containerName,
1208 QString QAD_Desktop::getComponentName(const char *componentUserName)
1210 if ( mapComponentName.contains(componentUserName) )
1211 return mapComponentName[ componentUserName ] ;
1216 QString QAD_Desktop::getComponentUserName(const char *componentName)
1218 QMap<QString,QString>::Iterator it;
1219 for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it )
1220 if (it.data() == componentName )
1226 // gets application Help Window (and creates if necessary)
1228 // QAD_HelpWindow* QAD_Desktop::getHelpWindow()
1230 // if (!myHelpWindow) {
1231 // myHelpWindow = new QAD_HelpWindow();
1233 // QMap<QString,QString>::Iterator it;
1234 // for( it = mapComponentName.begin(); it != mapComponentName.end(); ++it ) {
1238 // // look for index.html and set homeDir
1239 // // 1. $(MODULE_ROOT_DIR)/doc/index.html
1240 // // 2. $(MODULE_ROOT_DIR)/doc/html/index.html
1241 // // 3. $(MODULE_ROOT_DIR)/doc/html/html/index.html
1243 // if (dir = getenv( QString( it.data() + "_ROOT_DIR")) ) {
1244 // root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" );
1245 // if ( QFileInfo( root + "index.html" ).exists() ) {
1246 // helpContext( root + "index.html", "" );
1249 // root = QAD_Tools::addSlash( root + "html" );
1250 // if ( QFileInfo( root + "index.html" ).exists() ) {
1251 // helpContext( root + "index.html", "" );
1254 // root = QAD_Tools::addSlash( root + "html" );
1255 // if ( QFileInfo( root + "index.html" ).exists() ) {
1256 // helpContext( root + "index.html", "" );
1263 // connect(myHelpWindow, SIGNAL(helpWindowClosed()), this, SLOT(onHelpWindowClosed()));
1265 // return myHelpWindow;
1269 Called when desktop is closing
1271 void QAD_Desktop::closeEvent ( QCloseEvent* e )
1273 bool doClose = true;
1274 if ( myQueryClose ) {
1275 doClose = QAD_MessageBox::info2 ( this, tr("INF_DESK_EXIT"),
1276 tr("QUE_DESK_EXIT"), tr ("BUT_OK"),
1277 tr ("BUT_CANCEL"), QAD_YES,
1278 QAD_NO, QAD_NO ) == QAD_YES;
1282 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1283 QList<QAD_Study>& studies = app->getStudies();
1284 for(QAD_Study* study = studies.first(); study != 0; study = studies.next()) {
1285 if(myQueryClose && study->getStudyDocument()->IsModified()) {
1286 SALOMEGUI_CloseDlg aDlg( this );
1287 switch ( aDlg.exec() ) {
1289 if ( !onSaveStudy( study ) ) {
1290 putInfo( tr("INF_CANCELLED") );
1301 putInfo( tr("INF_CANCELLED") );
1309 myQueryClose = true;
1310 doClose ? e->accept() : e->ignore();
1314 Called when desktop is resized
1316 void QAD_Desktop::resizeEvent( QResizeEvent* e )
1318 QMainWindow::resizeEvent( e );
1319 myWorkspace->setGeometry( 1,1, centralWidget()->width()-2,
1320 centralWidget()->height()-2 );
1325 Terminates the application.
1327 void QAD_Desktop::onExit()
1332 /************************************************************************
1334 *************************************************************************/
1338 If several application are supported it displays dialog window
1339 to choose type of study.
1341 void QAD_Desktop::createStudy(){
1344 void QAD_Desktop::onNewStudy()
1346 unsigned numApps = myApps.count();
1349 onNewStudy ( myApps.at(0) );
1350 else { /* select the type of application for new study */
1351 Desktop_AppSelectionDlg selDlg( this, myApps );
1352 if ( selDlg.exec() == QDialog::Accepted ) {
1353 onNewStudy ( selDlg.selectedApp() );
1356 } else { /* no applications available in desktop */
1357 QAD_MessageBox::error1( this,
1359 tr("ERR_APP_NOAPP"),
1365 Creates new study for the given application.
1366 Calls the respective function of the application class.
1368 void QAD_Desktop::onNewStudy( QAD_Application* app )
1372 /* create new study of the specific app */
1373 putInfo ( tr ("INF_DOC_CREATING") );
1374 QAD_Study* newStudy = app->newStudy();
1377 /* can't create new study */
1378 QAD_MessageBox::error1( this, tr("ERR_ERROR"),
1379 tr("ERR_DOC_CANTCREATE"),
1382 putInfo ( tr("INF_READY") );
1386 Loads the existing study.
1388 void QAD_Desktop::onLoadStudy()
1390 QString name, studyname, ext;
1392 SALOMEGUI_LoadStudiesDlg* aDlg = new SALOMEGUI_LoadStudiesDlg( this, "Load Study", TRUE);
1394 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1395 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1396 ASSERT(! CORBA::is_nil(myStudyMgr));
1397 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1398 for (unsigned int ind = 0; ind < List->length();ind++) {
1399 studyname = List[ind];
1400 aDlg->ListComponent->insertItem( studyname );
1403 int retVal = aDlg->exec();
1404 studyname = aDlg->ListComponent->currentText();
1406 if (retVal == QDialog::Rejected)
1409 if ( studyname.isNull() || studyname.isEmpty() )
1413 name.replace( QRegExp(":"), "/" );
1416 Try to associate an application to the opened study.
1417 Assumed that the association study<->application is unique.
1419 bool appFound = false;
1420 putInfo ( tr("INF_DOC_OPENING") + " " + name );
1421 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
1423 /* application found */
1424 if ( app->isStudyOpened( name ) )
1426 /* already opened: prompt for reopen */
1427 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1428 tr("QUE_DOC_ALREADYOPEN").arg( name ),
1429 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1430 QAD_NO ) == QAD_NO )
1432 putInfo ( tr("INF_READY") );
1435 /* now the study is closed to be re-opened */
1436 //don't ask user to remove study permanently
1437 if (app->getStudyByName ( name ) != NULL)
1438 onCloseStudy ( app->getStudyByName ( name ), false );
1439 else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )) != NULL)
1440 onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )), false );
1444 /* open the study */
1445 QAD_Study* openStudy = app->loadStudy( studyname );
1447 QAD_MessageBox::error1( this,
1449 tr("ERR_DOC_CANTOPEN") + "\n" + name,
1456 QAD_MessageBox::error1( this,
1458 tr("ERR_DOC_UNKNOWNTYPE"),
1461 putInfo ( tr("INF_READY") );
1466 QAD_Study* QAD_Desktop::loadStudy(QString theStudyName) {
1467 QString studyname("");
1469 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1470 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1471 ASSERT(! CORBA::is_nil(myStudyMgr));
1473 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1474 for (unsigned int ind = 0; ind < List->length();ind++) {
1475 if (theStudyName == QString(List[ind])) {
1476 studyname = theStudyName;
1480 if (studyname == "") {
1483 bool appFound = false;
1484 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) {
1486 QAD_Study* openStudy = app->loadStudy( studyname );
1488 // if (myActiveApp == 0)
1489 //myActiveApp = app;
1499 Opens the existing study.
1500 Displays select file dialog and calls corresponding function of
1502 (application is defined according to extension of selected file).
1504 void QAD_Desktop::onOpenStudy()
1508 /* Select a file to open */
1509 name = selectFileName ( true );
1510 if ( name.isNull() || name.isEmpty() )
1513 // Workaround for non-existent files
1515 if (!fi.exists() || !fi.isFile()) {
1516 QAD_MessageBox::error1 ( this, tr("ERR_ERROR"),
1517 tr("ERR_DOC_CANTOPEN") +": " + name,
1522 CORBA::Object_var obj = myNameService->Resolve("/myStudyManager");
1523 SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
1524 ASSERT(! CORBA::is_nil(myStudyMgr));
1525 SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies();
1526 for (unsigned int ind = 0; ind < List->length();ind++) {
1527 QString NameExistingStudy(List[ind]);
1528 QString NameOpeningStudy = QAD_Tools::getFileNameFromPath( name, false );
1530 if ( NameExistingStudy.compare( NameOpeningStudy ) == 0 ) {
1531 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1532 tr("QUE_DOC_ALREADYEXIST").arg( name ),
1533 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1534 QAD_NO ) == QAD_NO )
1536 putInfo ( tr("INF_READY") );
1548 Try to associate an application to the opened study.
1549 Assumed that the association study<->application is unique.
1551 bool appFound = false;
1552 putInfo ( tr("INF_DOC_OPENING") + " " + name );
1553 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
1555 QString ext = QAD_Tools::getFileExtensionFromPath ( name );
1556 if ( app->getStudyExtension() == ext )
1558 /* application found */
1559 if ( app->isStudyOpened( name ) )
1561 /* already opened: prompt for reopen */
1562 if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"),
1563 tr("QUE_DOC_ALREADYOPEN").arg( name ),
1564 tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO,
1565 QAD_NO ) == QAD_NO )
1567 putInfo ( tr("INF_READY") );
1570 /* now the study is closed to be re-opened */
1571 //don't ask user to remove study permanently
1572 if (app->getStudyByName ( name ) != NULL)
1573 onCloseStudy ( app->getStudyByName ( name ), false );
1574 else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )) != NULL)
1575 onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )), false );
1579 /* open the study */
1580 QAD_Study* openStudy = app->openStudy( name );
1582 QAD_MessageBox::error1( this,
1584 tr("ERR_DOC_CANTOPEN") + "\n" + name,
1586 } else if (myActiveComp != "") {
1587 QApplication::setOverrideCursor( Qt::waitCursor );
1588 loadComponentData(mapComponentName[myActiveComp]);
1589 openStudy->updateObjBrowser(true);
1590 QApplication::restoreOverrideCursor();
1598 QAD_MessageBox::error1( this,
1600 tr("ERR_DOC_UNKNOWNTYPE"),
1603 putInfo ( tr("INF_READY") );
1606 bool QAD_Desktop::loadComponentData( const QString& compName )
1608 // Open component's data in active study if any
1609 MESSAGE("loadComponentData(): Opening " << compName << " component data ")
1610 if (!myActiveStudy) {
1611 MESSAGE("loadComponentData(): No active study exists")
1615 Engines::Component_var comp ;
1616 if ( compName.compare("SUPERV") == 0 ) {
1617 comp = getEngine( "SuperVisionContainer", compName) ;
1620 /* comp = ( compName.compare("Data1") != 0 ) ? getEngine( "FactoryServer", compName) :
1621 getEngine( "FactoryServerPy", compName);
1623 comp = getEngine( "FactoryServer", compName);
1624 if ( comp->_is_nil() )
1625 comp = getEngine( "FactoryServerPy", compName);
1628 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
1629 SALOMEDS::SComponent_var SCO = SALOMEDS::SComponent::_narrow(aStudy->FindObject( getComponentUserName(compName) ));
1631 if (!SCO->_is_nil()) {
1632 if (!CORBA::is_nil(comp)) {
1633 SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
1634 if (!CORBA::is_nil(driver)) {
1635 SALOMEDS::StudyBuilder_var B = aStudy->NewBuilder();
1636 if (!CORBA::is_nil(B)) {
1637 QAD_Operation* op = new QAD_Operation( myActiveStudy );
1639 B->LoadWith(SCO,driver);
1645 MESSAGE("loadComponentData(): Driver is null");
1649 MESSAGE("loadComponentData(): Engine is null");
1653 MESSAGE("loadComponentData(): SComponent is null");
1661 Saves the active study
1663 bool QAD_Desktop::onSaveStudy()
1665 return onSaveStudy ( myActiveStudy );
1669 Saves the given study
1671 bool QAD_Desktop::onSaveStudy( QAD_Study* study )
1673 if ( !study ) return true;
1675 if ( !study->isSaved() )
1676 return onSaveAsStudy ( study );
1678 /* saving study... */
1679 QAD_Application* app = study->getApp();
1680 QAD_ASSERT_DEBUG_ONLY ( app );
1681 putInfo ( tr("INF_DOC_SAVING") + study->getTitle() );
1682 if ( !app->saveStudy( study ) )
1684 putInfo( tr("INF_CANCELLED") );
1689 putInfo ( tr("INF_DOC_SAVED").arg( "" ) );
1694 Saves the active study under a new name
1696 bool QAD_Desktop::onSaveAsStudy()
1698 return onSaveAsStudy( myActiveStudy );
1702 Saves the given study under a new name
1704 bool QAD_Desktop::onSaveAsStudy( QAD_Study* study )
1706 if ( !study ) return true;
1708 /* Save study in a format supported by its application
1710 QAD_Application* app = study->getApp();
1711 QAD_ASSERT_DEBUG_ONLY ( app );
1713 /* Select a file where to save
1715 QString name = selectFileName ( false );
1716 if ( name.isNull() || name.isEmpty() )
1718 putInfo( tr("INF_CANCELLED") );
1724 putInfo ( tr("INF_DOC_SAVING") + name );
1725 if ( !app->saveAsStudy( study, name ) ) {
1726 /* can't save the file */
1727 QAD_MessageBox::error1( this,
1729 tr("ERR_DOC_CANTWRITE") + "\n" + name,
1732 return false; /* cannot save */
1734 putInfo ( tr("INF_DOC_SAVED").arg( name ) );
1735 return true; /* saved ok */
1739 Closes the active study
1741 bool QAD_Desktop::onCloseStudy()
1743 bool close = this->onCloseStudy ( myActiveStudy, true );
1744 if ( close && !myXmlHandler->myIdList.IsEmpty() ) {
1747 myCombo->setCurrentItem (0);
1748 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
1749 aButton->setOn(false);
1756 Closes the given study and ask user to remove study
1757 from the study manager permanently
1759 bool QAD_Desktop::onCloseStudy( QAD_Study* study )
1761 return onCloseStudy( study, true );
1765 Closes the given study and ask user to remove study
1766 from the study manager permanently if ask is equal true
1768 bool QAD_Desktop::onCloseStudy( QAD_Study* study, bool ask )
1770 bool removePerm = false;
1774 SALOMEGUI_CloseDlg aDlg( this );
1775 int res = aDlg.exec();
1780 //if ( study->isModified() )
1781 if ( !onSaveStudy( study ) ) {
1782 putInfo( tr("INF_CANCELLED") );
1795 putInfo( tr("INF_CANCELLED") );
1799 /* close active component */
1800 if (!myXmlHandler->myIdList.IsEmpty())
1804 myCombo->setCurrentItem (0);
1805 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() )
1806 aButton->setOn(false);
1807 qApp->processEvents();
1809 /* close the study */
1810 return study->getApp()->closeStudy( study, removePerm );
1813 // Displays study properties dialog box
1814 void QAD_Desktop::onStudyProperties()
1816 if (myActiveStudy) {
1818 QAD_Operation* op = new QAD_Operation( myActiveStudy );
1821 SALOMEGUI_StudyPropertiesDlg aDlg(this);
1822 int res = aDlg.exec();
1824 if ( res == QDialog::Accepted && aDlg.isChanged() )
1829 // T2.12 - add the word "locked" to study frame captions if <myActiveStudy> study is locked
1830 myActiveStudy->updateCaptions();
1836 locate all windows in cascade mode
1839 void QAD_Desktop::onCascade()
1841 myWorkspace->cascade();
1842 int w = myWorkspace->width();
1843 int h = myWorkspace->height();
1844 QWidgetList wList = myWorkspace->windowList();
1845 QWidgetListIt it(wList);
1847 for(;it.current(); ++it)
1848 it.current()->resize((int)(0.8*w), (int)(0.8*h));
1852 // called when help window closed
1854 // void QAD_Desktop::onHelpWindowClosed()
1856 // myHelpWindow = 0;
1860 Called when 'view status bar' option
1863 void QAD_Desktop::onViewStatusBar()
1865 bool show = myStdActions.at( ViewStatusBarId )->isOn();
1866 if ( show == myStatusBar->isVisible() )
1869 myStatusBar->show();
1871 myStatusBar->hide();
1875 Called when View/Toolbars popup menu is about to show
1877 void QAD_Desktop::onToolBarPopupAboutToShow()
1879 myToolBarAction.clear();
1880 myToolBarsPopup.clear();
1881 QPtrList<QDockWindow> wlist = dockWindows();
1882 for ( QDockWindow* w = wlist.first(); w; w = wlist.next() ) {
1883 if ( w->inherits( "QToolBar" ) ) {
1884 QToolBar* tb = ( QToolBar* )w;
1885 if ( appropriate( tb ) ) {
1886 ToggleAction* a = new ToggleAction( tb->label(), tb->label(), 0, this, 0, true );
1887 a->setStatusTip ( tr("PRP_DESK_VIEW_TOOLBAR") );
1888 a->setOn( tb->isVisible() );
1889 QAD_ASSERT( connect( a, SIGNAL( toggledOn() ), tb, SLOT( show() ) ) );
1890 QAD_ASSERT( connect( a, SIGNAL( toggledOff() ), tb, SLOT( hide() ) ) );
1891 a->addTo( &myToolBarsPopup );
1892 myToolBarAction.append( a );
1899 Called on 'View\Selection Mode'
1901 void QAD_Desktop::onSelectionMode()
1903 const QActionP* obj = (QActionP*) sender();
1905 int SelectionMode = 4;
1907 if ( obj == myStdActions.at(SelectionActorId) ) {
1909 if ( obj->isOn() ) {
1910 myStdActions.at(SelectionCellId)->setOn(false);
1911 myStdActions.at(SelectionEdgeId)->setOn(false);
1912 myStdActions.at(SelectionPointId)->setOn(false);
1914 myStdActions.at(SelectionActorId)->setOn(true);
1916 } else if ( obj == myStdActions.at(SelectionCellId) ) {
1918 if ( obj->isOn() ) {
1919 myStdActions.at(SelectionActorId)->setOn(false);
1920 myStdActions.at(SelectionEdgeId)->setOn(false);
1921 myStdActions.at(SelectionPointId)->setOn(false);
1923 myStdActions.at(SelectionActorId)->setOn(true);
1925 } else if ( obj == myStdActions.at(SelectionEdgeId) ) {
1927 if ( obj->isOn() ) {
1928 myStdActions.at(SelectionActorId)->setOn(false);
1929 myStdActions.at(SelectionCellId)->setOn(false);
1930 myStdActions.at(SelectionPointId)->setOn(false);
1932 myStdActions.at(SelectionActorId)->setOn(true);
1934 } else if ( obj == myStdActions.at(SelectionPointId) ) {
1936 if ( obj->isOn() ) {
1937 myStdActions.at(SelectionEdgeId)->setOn(false);
1938 myStdActions.at(SelectionCellId)->setOn(false);
1939 myStdActions.at(SelectionActorId)->setOn(false);
1941 myStdActions.at(SelectionActorId)->setOn(true);
1944 QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame();
1945 sf->getRightFrame()->getViewFrame()->SetSelectionMode( SelectionMode );
1947 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() );
1948 Sel->SetSelectionMode( SelectionMode );
1952 Called on 'View\Selection Mode'
1954 void QAD_Desktop::SetSelectionMode(int mode, bool activeCompOnly)
1959 myStdActions.at(SelectionEdgeId)->setOn(false);
1960 myStdActions.at(SelectionCellId)->setOn(false);
1961 myStdActions.at(SelectionActorId)->setOn(false);
1962 myStdActions.at(SelectionPointId)->setOn(true);
1967 myStdActions.at(SelectionActorId)->setOn(false);
1968 myStdActions.at(SelectionCellId)->setOn(false);
1969 myStdActions.at(SelectionPointId)->setOn(false);
1970 myStdActions.at(SelectionEdgeId)->setOn(true);
1975 myStdActions.at(SelectionActorId)->setOn(false);
1976 myStdActions.at(SelectionEdgeId)->setOn(false);
1977 myStdActions.at(SelectionPointId)->setOn(false);
1978 myStdActions.at(SelectionCellId)->setOn(true);
1983 myStdActions.at(SelectionCellId)->setOn(false);
1984 myStdActions.at(SelectionEdgeId)->setOn(false);
1985 myStdActions.at(SelectionPointId)->setOn(false);
1986 myStdActions.at(SelectionActorId)->setOn(true);
1991 QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame();
1992 if ( sf->getTypeView() == VIEW_VTK ) {
1993 sf->getRightFrame()->getViewFrame()->SetSelectionMode( mode );
1994 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() );
1995 Sel->SetSelectionMode( mode, activeCompOnly );
2001 Called on 'Window\NewWindow3d'
2003 void QAD_Desktop::onNewWindow3d()
2007 //VRV: T2.5 - add default viewer
2008 QApplication::restoreOverrideCursor();
2009 SALOMEGUI_ViewChoiceDlg *choice = new SALOMEGUI_ViewChoiceDlg(this, "", TRUE);
2010 int r = choice->exec();
2013 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(choice->getSelectedViewer()));
2015 //VRV: T2.5 - add default viewer
2017 const QActionP* obj = (QActionP*) sender();
2018 if ( obj == myStdActions.at(ViewOCCId) ) {
2019 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(0));
2020 } else if ( obj == myStdActions.at(ViewVTKId) ) {
2021 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(1));
2022 } else if ( obj == myStdActions.at(ViewPlot2dId) ) {
2023 myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(3));
2028 // Helps to execute command
2029 class RunBrowser: public QThread {
2032 RunBrowser(QString theApp, QString theParams, QString theHelpFile):
2033 myApp(theApp), myParams(theParams), myHelpFile(theHelpFile), myStatus(0) {};
2039 if ( !myApp.isEmpty())
2041 aCommand.sprintf("%s %s %s",myApp.latin1(),myParams.latin1(),myHelpFile.latin1());
2042 myStatus = system(aCommand);
2045 QCustomEvent* ce2000 = new QCustomEvent (2000);
2046 postEvent (qApp, ce2000);
2050 if( myStatus != 0 || myApp.isEmpty())
2053 aCommand.sprintf("%s %s %s", QString(DEFAULT_BROWSER).latin1(),myParams.latin1(), myHelpFile.latin1());
2054 myStatus = system(aCommand);
2057 QCustomEvent* ce2001 = new QCustomEvent (2001);
2058 postEvent (qApp, ce2001);
2072 Called on 'help\contents'
2074 void QAD_Desktop::onHelpContents()
2075 { if (myActiveComp == "")
2076 myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
2081 if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
2082 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + QAD_Tools::addSlash("doc") + "html" );
2083 if ( QFileInfo( root + "index.html" ).exists() ) {
2086 QMessageBox::warning( this, tr("WRN_WARNING"),
2087 QString( "%1index.html doesn't exist." ).arg(root), tr ("BUT_OK") );
2092 QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath();
2094 QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2095 QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2097 RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2102 Called on 'help\GUI Reference'
2104 void QAD_Desktop::onHelpContentsGUI()
2111 // if ( (dir = getenv("KERNEL_ROOT_DIR")) ) {
2112 // root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc" );
2113 // root = QAD_Tools::addSlash( root + "guihtml" );
2114 // root = QAD_Tools::addSlash( root + "guihtml" );
2115 // if ( QFileInfo( root + "salomedoc.html" ).exists() ) {
2119 // if ( root.isEmpty() ) {
2120 // if ( QFileInfo( "/usr/local/doc/guihtml/salomedoc.html" ).exists() ) {
2121 // homeDir = "/usr/local/doc/guihtml/";
2124 // if ( root.isEmpty() )
2127 // QString helpFile = QFileInfo( homeDir + "salomedoc.html" ).absFilePath();
2129 // QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2130 // QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2132 // RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2138 Called on 'help\TUI Reference'
2140 void QAD_Desktop::onHelpContentsTUI()
2142 if (myActiveComp == "")
2143 myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
2148 if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
2149 root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + QAD_Tools::addSlash("doc") + "html" );
2150 if ( QFileInfo( root + "index.html" ).exists() ) {
2153 QMessageBox::warning( this, tr("WRN_WARNING"),
2154 QString( "%1index.html doesn't exist." ).arg(root), tr ("BUT_OK") );
2159 QString helpFile = QFileInfo( homeDir + "index.html" ).absFilePath();
2161 QString anApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
2162 QString aParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
2164 RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
2169 // Called on 'help\search'
2171 // void QAD_Desktop::onHelpSearch()
2174 // myActiveApp->helpSearch();
2180 Called on 'help\about'
2182 void QAD_Desktop::onHelpAbout()
2185 myActiveApp->helpAbout();
2192 Activates the application and its active study
2194 void QAD_Desktop::onActivateApp( QAD_Application* activeApp )
2196 bool appChanged = ( activeApp != myActiveApp );
2199 updateDesktop( DeactivateApp );
2203 myActiveApp = activeApp;
2204 myActiveStudy = myActiveApp->getActiveStudy();
2214 updateDesktop( ActivateApp );
2215 updateCaption( (activeApp != NULL) ? ActivateApp : DeactivateApp );
2221 Called when the last study is removed from
2222 the application 'app'.
2224 void QAD_Desktop::onDeactivateApp(QAD_Application* app)
2226 if ( app && app == myActiveApp )
2231 Enables/disables standard actions
2233 void QAD_Desktop::updateActions()
2235 myStdActions.at( FileCloseId )->setEnabled ( myActiveStudy != NULL );
2236 myStdActions.at( FileSaveId )->setEnabled ( myActiveStudy != NULL );
2237 myStdActions.at( FileSaveAsId )->setEnabled ( myActiveStudy != NULL );
2238 myStdActions.at( FilePropsId )->setEnabled( myActiveStudy != NULL );
2239 // myStdActions.at( HelpContentsId )->setEnabled ( myActiveApp != NULL );
2240 // myStdActions.at( HelpSearchId )->setEnabled ( myActiveApp != NULL );
2241 // myStdActions.at( HelpWhatsThisId )->setEnabled ( myActiveApp != NULL );
2242 // myStdActions.at( HelpAboutId )->setEnabled ( myActiveApp != NULL );
2244 // myToolsPopup.setEnabled ( myActiveStudy != NULL );
2245 // myPrefPopup.setEnabled ( myActiveStudy != NULL );
2247 mySelectionModePopup.setEnabled ( myActiveStudy != NULL );
2250 myStdActions.at( ViewOCCId )->setEnabled( myActiveStudy != NULL );
2251 myStdActions.at( ViewVTKId )->setEnabled( myActiveStudy != NULL );
2252 myStdActions.at( ViewPlot2dId )->setEnabled( myActiveStudy != NULL );
2257 Called when 'Window' popup is about to show
2259 void QAD_Desktop::onWindowPopupAboutToShow()
2261 /* add cascade/tile items */
2262 myWindowPopup.clear();
2265 //myStdActions.at( WindowNew3dId )->addTo( &myWindowPopup );
2266 myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId );
2267 //myStdActions.at( WindowNew3dId )->setEnabled( true );
2268 myWindowPopup.setItemEnabled( WindowNew3dId, true );
2270 myStdActions.at( WindowCascadeId )->addTo( &myWindowPopup );
2271 myStdActions.at( WindowCascadeId )->setEnabled( true );
2272 myStdActions.at( WindowTileId )->addTo( &myWindowPopup );
2273 myStdActions.at( WindowTileId )->setEnabled( true );
2275 /* add names of opened studies */
2276 QWidgetList windows = myWorkspace->windowList();
2277 if ( windows.isEmpty() )
2279 //NRI : SAL2214 myStdActions.at( WindowNew3dId )->setEnabled( false );
2280 myWindowPopup.setItemEnabled( WindowNew3dId, false );
2282 myStdActions.at( WindowCascadeId )->setEnabled( false );
2283 myStdActions.at( WindowTileId )->setEnabled( false );
2287 myWindowPopup.insertSeparator();
2288 for ( int i = 0; i < int(windows.count()); ++i )
2290 int id = myWindowPopup.insertItem( windows.at(i)->caption(),
2291 this, SLOT( onWindowsPopupActivated( int ) ) );
2292 myWindowPopup.setItemParameter( id, i );
2293 myWindowPopup.setItemChecked( id, myWorkspace->activeWindow() == windows.at(i) );
2295 QAD_ASSERT( connect( &myWindowPopup, SIGNAL(highlighted( int )), this,
2296 SLOT(onWindowsPopupStatusText( int )) ));
2301 Called when the item with 'id' of 'Windows' popup
2304 void QAD_Desktop::onWindowsPopupStatusText( int id )
2306 int cascadeId = myWindowPopup.idAt( 0 );
2307 int tileId = myWindowPopup.idAt( 1 );
2308 if ( id == cascadeId || id == tileId )
2310 putInfo( tr("PRP_DESK_WINDOW_ACTIVATE") );
2314 Called when user wants to activate a child window with 'wid'
2317 void QAD_Desktop::onWindowsPopupActivated( int wid )
2319 QWidget* w = myWorkspace->windowList().at( wid );
2320 if ( w ) w->setFocus();
2324 Selects a file name when opening or saving files.
2325 The basic implementation just uses the standard
2327 Please redefine if another behaviour is required.
2329 QString QAD_Desktop::selectFileName ( bool open )
2331 QAD_FileDlg* fd = new QAD_FileDlg( this, open, true, true );
2335 QStringList filters;
2338 // All the file types of the supported applications
2340 for ( QAD_Application* app = myApps.first(); app; app = myApps.next() )
2342 filters += app->getStudyDescription() + " " + tr("DESK_FILES") + " " +
2343 "(*." + app->getStudyExtension() + ")";
2347 QAD_ASSERT_DEBUG_ONLY ( myActiveStudy );
2348 if (myActiveStudy) {
2349 // get file name of active study
2350 name = QAD_Tools::getFileNameFromPath ( myActiveStudy->getTitle() );
2351 // get path to the active study file
2352 dir = QAD_Tools::getDirFromPath ( myActiveStudy->getPath(), false );
2354 QAD_ASSERT_DEBUG_ONLY ( !name.isNull() );
2355 // the file types supported by the active application
2356 filters += myActiveApp->getStudyDescription() + " " + tr("DESK_FILES") + " " +
2357 "(*." + myActiveApp->getStudyExtension() + ")" ;
2359 if (!dir.isEmpty()) {
2360 // when saving document ("Save As" command) - to get dir from active study filename
2361 // for new documents - to use last opened directory
2364 fd->setSelection( name );
2365 fd->setFilters( filters );
2368 QString filename = fd->selectedFile();
2370 qApp->processEvents();
2375 Closes all the studies of 'app'. Returns
2376 'true' if thay are closed OK, 'false' at least
2377 one can't be closed or user cancel the closure.
2379 bool QAD_Desktop::closeAllStudies( QAD_Application* app )
2381 QList<QAD_Study>& studies = app->getStudies();
2382 while ( !studies.isEmpty() )
2384 //don't ask user to remove study permanently
2385 if ( !onCloseStudy( studies.at(0), false ) )
2386 return false; /* user cancelled closing */
2392 Called on Popup item when SComponent representation in Object Browser is selected.
2394 void QAD_Desktop::onOpenWith()
2396 Engines::Component_var comp;
2397 QString ComponentSelected;
2399 SALOMEDS::SObject_var SO;
2400 SALOMEDS::SComponent_var SCO;
2401 SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
2402 SALOMEDS::GenericAttribute_var anAttr;
2403 SALOMEDS::AttributeName_var aName;
2405 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2406 if ( Sel->IObjectCount() == 1 ) {
2407 Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
2408 SO = aStudy->FindObjectID( IO->getEntry() );
2409 SCO = SO->GetFatherComponent();
2411 if (SCO->FindAttribute(anAttr, "AttributeName")) {
2412 aName = SALOMEDS::AttributeName::_narrow(anAttr);
2413 name = aName->Value();
2414 SALOME_ModuleCatalog::Acomponent_var Comp = myCatalogue->GetComponent( mapComponentName[name] );
2415 if ( !Comp->_is_nil() ) {
2417 SALOME_ModuleCatalog::ListOfComponents_var list_type_composants =
2418 myCatalogue->GetTypedComponentList( Comp->component_type() );
2420 if ( list_type_composants->length() == 1 ) {
2421 ComponentSelected = name;
2422 } else if ( list_type_composants->length() > 1 ) {
2423 SALOMEGUI_OpenWith* aDlg = new SALOMEGUI_OpenWith( this );
2424 for (unsigned int ind = 0; ind < list_type_composants->length();ind++) {
2425 aDlg->addComponent( strdup(list_type_composants[ind]) );
2428 int retVal = aDlg->exec();
2429 ComponentSelected = aDlg->getComponent();
2431 if ( retVal == QDialog::Rejected || ComponentSelected.isEmpty()) {
2435 MESSAGE( "No component with type : " << Comp->component_type() << " exists" );
2440 MESSAGE( "This component not exists in the catalog" );
2444 QApplication::setOverrideCursor( Qt::waitCursor );
2445 Sel->ClearIObjects();
2447 // if (loadComponentData(ComponentSelected)) {
2448 onComboActiveComponent(ComponentSelected);
2449 // int nbItem = myCombo->count();
2451 // for (int i = 0; i < nbItem; i++) {
2452 // if (myCombo->text(i).compare(ComponentSelected)==0) {
2457 // myCombo->setCurrentItem(Index);
2458 // myActiveStudy->updateObjBrowser(true);
2462 QApplication::restoreOverrideCursor();
2465 typedef bool OneDim1(QAD_Desktop*);
2466 typedef bool OneDim2(QAD_Desktop*, char*);
2469 Called to define settings of component.
2471 void QAD_Desktop::setSettings()
2473 if (!myActiveComp.isEmpty()) {
2474 OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings");
2478 OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
2483 QString Component =mapComponentName[myActiveComp];
2484 OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF;
2485 (*f1)(this, (char*)Component.latin1());
2491 Called to load Component : xml resources and GUI librairy.
2493 bool QAD_Desktop::loadComponent(QString Component)
2496 QString resDir("/"); //NRI : Pb under Windows
2498 QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
2501 if (!resMgr->loadResources( Component, msg ))
2503 //NRI QCString errMsg;
2504 // errMsg.sprintf( "Do not load all resources for module %sGUI.\n" ,
2505 // Component.latin1() );
2507 QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") );
2512 /* Parse xml file */
2513 myXmlHandler = new QAD_XmlHandler();
2514 myXmlHandler->setMainWindow(this);
2515 if (!myXmlHandler->setComponent(resMgr->resources( Component ))) return false;
2517 QString language = resMgr->language( Component );
2519 QString ComponentXml = Component + "_" + language + ".xml";
2520 //ComponentXml = resMgr->resources(Component + "GUI") ;
2521 //ComponentXml = QAD_Tools::addSlash(ComponentXml) ;
2522 ComponentXml = QAD_Tools::addSlash( resMgr->findFile( ComponentXml, Component ) ) + ComponentXml;
2523 QFile file( ComponentXml );
2525 if ( !file.exists() || !file.open( IO_ReadOnly ) ) {
2527 errMsg.sprintf( "Cannot open xml file: %s\n.",
2528 (file.name()).latin1() );
2530 QMessageBox::critical( this, tr("ERR_ERROR"), errMsg, tr ("BUT_OK") );
2535 QXmlInputSource source( file );
2536 QXmlSimpleReader reader;
2537 reader.setContentHandler( myXmlHandler );
2538 reader.setErrorHandler( myXmlHandler );
2539 bool ok = reader.parse( source );
2543 QMessageBox::critical( this,
2544 tr( "INF_PARSE_ERROR" ),
2545 tr( myXmlHandler->errorProtocol() ) );
2549 myMenusList=myXmlHandler->myMenusList;
2550 myActiveMenus=myMenusList.at(0);
2551 myOperatorMenus->showMenuBar(0);
2552 myActiveMenus->showAllToolBars();
2554 /* Components toolbars */
2557 nbToolbars = myActiveMenus->getToolBarList().count();
2558 /* Open Shared Library */
2559 mySharedLibrary = OSD_SharedLibrary();
2562 QString ComponentLib;
2564 QFileInfo fileInfo ;
2565 QString fileString ;
2568 if ( libs = getenv("LD_LIBRARY_PATH")) {
2569 // MESSAGE ( " LD_LIBRARY_PATH : " << libs );
2570 QStringList dirList = QStringList::split( SEPARATOR, libs, false ); // skip empty entries
2571 for ( int i = dirList.count()-1; i >= 0; i-- ) {
2574 fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.dll" ;
2576 fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.so" ;
2579 fileInfo.setFile(fileString) ;
2580 if (fileInfo.exists()) {
2581 // MESSAGE ( " GUI library = " << fileString );
2582 ComponentLib = fileInfo.fileName() ;
2589 if (!_islibso) // component GUI could be in PyQt, use generic library
2591 MESSAGE("GUI library not found, trying generic library for PyQt GUI");
2593 if (dir = getenv("KERNEL_ROOT_DIR"))
2595 dir = QAD_Tools::addSlash(dir) ;
2597 dir = QAD_Tools::addSlash(dir) ;
2598 dir = dir + "salome" ;
2599 dir = QAD_Tools::addSlash(dir) ;
2601 dir = dir + "libSalomePyQtcmodule.dll" ;
2603 dir = dir + "libSalomePyQtcmodule.so" ;
2605 MESSAGE ( " GUI library = " << dir );
2606 fileInfo.setFile(dir) ;
2607 if (fileInfo.exists())
2609 ComponentLib = fileInfo.fileName() ;
2615 QMessageBox::critical( this,
2617 tr("ERR_LIBGUI" ).arg(Component) );
2622 mySharedLibrary.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString());
2623 ok = mySharedLibrary.DlOpen(OSD_RTLD_LAZY);
2626 QMessageBox::critical( this,
2628 tr( mySharedLibrary.DlError() ) );
2633 OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings");
2637 OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
2642 OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF;
2643 (*f1)(this, (char*)Component.latin1());
2648 /* COMPONENT INTERFACE */
2649 SALOME_ModuleCatalog::Acomponent_ptr aComponent =
2650 myCatalogue->GetComponent(Component.latin1());
2652 if (CORBA::is_nil (aComponent)) {
2653 MESSAGE( "Catalog Error : Component not found in the catalog" )
2657 myActiveStudy->setMessage(QString("Component : ") +
2658 aComponent->componentusername() + " created " );
2659 myActiveStudy->setMessage(QString("Type : ") +
2660 QString::number(aComponent->component_type()));
2661 myActiveStudy->setMessage(QString("Constraint : ") +
2662 aComponent->constraint() );
2664 /* obtain interfaces list of the component */
2665 SALOME_ModuleCatalog::ListOfInterfaces_var _list =
2666 new SALOME_ModuleCatalog::ListOfInterfaces;
2667 _list = aComponent->GetInterfaceList();
2669 if (_list->length() != 0 ) {
2671 for (unsigned int ind = 0; ind < _list->length();ind++)
2672 myActiveStudy->setMessage( QString("Interface name : ") +
2676 /* obtain services list of the component */
2677 SALOME_ModuleCatalog::ListOfServices_var list_services_component =
2678 new SALOME_ModuleCatalog::ListOfServices;
2679 list_services_component = aComponent->GetServiceList(_list[0]);
2681 if (list_services_component->length() != 0 ) {
2683 for (unsigned int ind = 0; ind < list_services_component->length();ind++)
2684 myActiveStudy->setMessage( QString("Service name : ") +
2685 list_services_component[ind] );
2687 // Get a service of the component
2688 SALOME_ModuleCatalog::Service_var service = new SALOME_ModuleCatalog::Service;
2689 service = aComponent->GetService(_list[0],list_services_component[0]) ;
2690 myActiveStudy->setMessage( QString("Service name: ") + service->ServiceName);
2691 for (unsigned int ind1 = 0; ind1 <service->ServiceinParameter.length();ind1++) {
2692 myActiveStudy->setMessage( QString("Type of the in Parameter of this service : ") +
2693 (const char *) service->ServiceinParameter[ind1].Parametertype);
2694 myActiveStudy->setMessage( QString("Name of the in Parameter of this service : ") +
2695 (const char *) service->ServiceinParameter[ind1].Parametername);
2697 for (unsigned int ind1 = 0; ind1 <service->ServiceoutParameter.length();ind1++) {
2698 myActiveStudy->setMessage( QString("Type of the out Parameter of this service : ") +
2699 (const char *) service->ServiceoutParameter[ind1].Parametertype);
2700 myActiveStudy->setMessage( QString("Name of the out Parameter of this service : ") +
2701 (const char *) service->ServiceoutParameter[ind1].Parametername);
2708 typedef bool OneDim(int, QAD_Desktop*);
2709 typedef void (*PTR_FACTORY_FUNCTION)( CORBA::ORB_var &orb, QWidget *parent, const char *name ) ;
2713 void QAD_Desktop::onDispatch()
2715 const QObject* obj = sender();
2717 QList<QAD_ListMenuIdAction> MenuList = myActiveMenus->getMenuList();
2718 QAD_ListMenuIdAction* aMenu;
2720 for(aMenu=MenuList.first();aMenu!=NULL;aMenu=MenuList.next()) {
2721 if (aMenu->getAction()==obj) {
2722 id = aMenu->getId();
2731 void QAD_Desktop::onDispatchTools(int id)
2733 /* Open Shared Library */
2734 OSD_SharedLibrary ToolsLibrary = OSD_SharedLibrary();
2738 QFileInfo fileInfo ;
2742 bool libToolsGUI = true;
2743 if( QAD_XmlHandler::_bibmap[ id ].isEmpty() )
2745 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
2746 dir = QAD_Tools::addSlash(dir) ;
2748 dir = QAD_Tools::addSlash(dir) ;
2749 dir = dir + "salome" ;
2750 dir = QAD_Tools::addSlash(dir) ;
2752 dir = dir + "libToolsGUI.dll" ;
2754 dir = dir + "libToolsGUI.so" ;
2756 MESSAGE ( " GUI library = " << dir );
2757 fileInfo.setFile(dir) ;
2758 if (fileInfo.exists()) {
2759 ToolsLib = fileInfo.fileName() ;
2765 libToolsGUI = false;
2766 SCRUTE( QAD_XmlHandler::_bibmap[ id ] ) ;
2767 if ( (dir = getenv("KERNEL_ROOT_DIR")) && !found ) {
2768 dir = QAD_Tools::addSlash(dir) ;
2770 dir = QAD_Tools::addSlash(dir) ;
2771 dir = dir + "salome" ;
2772 dir = QAD_Tools::addSlash(dir) ;
2773 dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ;
2774 MESSAGE ( " GUI library = " << dir );
2775 fileInfo.setFile(dir) ;
2776 if (fileInfo.exists()) {
2777 ToolsLib = fileInfo.fileName() ;
2783 ToolsLibrary.SetName(TCollection_AsciiString((char*)ToolsLib.latin1()).ToCString());
2784 bool ok = ToolsLibrary.DlOpen(OSD_RTLD_LAZY);
2786 if ( libToolsGUI ) {
2787 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
2788 OneDim (*f1) = NULL;
2789 f1 = (bool (*) (int, QAD_Desktop*)) osdF;
2792 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
2793 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
2794 CORBA::ORB_var &orb = init(0 , 0 ) ;
2795 OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent");
2796 PTR_FACTORY_FUNCTION f1 = NULL;
2797 f1 = (PTR_FACTORY_FUNCTION) osdF;
2798 f1(orb,0,"Registry");
2801 QMessageBox::critical( this,
2803 tr( ToolsLibrary.DlError() ) );
2809 void QAD_Desktop::onDispatch(int id)
2811 if (!myActiveComp.isEmpty()) {
2812 OSD_Function osdF = mySharedLibrary.DlSymb("OnGUIEvent");
2813 OneDim (*f1) = NULL;
2814 if ( osdF != NULL ) {
2815 f1 = (bool (*) (int, QAD_Desktop*)) osdF;
2822 Returns the component's catalogue
2824 SALOME_ModuleCatalog::ModuleCatalog_var QAD_Desktop::getCatalogue()
2831 void QAD_Desktop::onComboActiveComponent( const QString & component ){
2832 onComboActiveComponent(component,true);
2834 void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoadData)
2836 if (myActiveStudy != 0) {
2837 if (myActiveComp.compare(component)!=0) {
2838 if (!myXmlHandler->myIdList.IsEmpty()) clearMenus();
2839 if ( myCombo->currentText() != component )
2840 myCombo->setCurrentText( component );
2841 //NRI if (component.compare(QString("Salome"))!= 0) {
2842 if (component.compare( getComponentUserName( "KERNEL" ) )!= 0) {
2843 // QApplication::setOverrideCursor( Qt::waitCursor );
2844 myActiveComp = component;
2846 SALOME_Selection* oldSel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2848 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
2849 if ( aButton->textLabel().compare(component)==0)
2850 aButton->setOn(true);
2852 aButton->setOn(false);
2855 myActiveStudy->Selection( component );
2856 if ( !loadComponent(mapComponentName[component]) ) {
2857 myCombo->setCurrentItem (0);
2858 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
2859 aButton->setOn(false);
2864 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2865 SALOME_ListIteratorOfListIO It( oldSel->StoredIObjects() );
2866 for(;It.More();It.Next()) {
2867 int res = Sel->AddIObject( It.Value() );
2870 myActiveStudy->highlight( It.Value(), false );
2872 myActiveStudy->highlight( It.Value(), true );
2876 // Open new component's data in active study if any
2877 if(isLoadData) loadComponentData(mapComponentName[component]);
2880 myActiveStudy->updateObjBrowser(true);
2882 // QApplication::restoreOverrideCursor();
2884 } else { // component == "Salome"
2886 //NRI myActiveStudy->Selection( "Salome" );
2887 myActiveStudy->Selection( getComponentUserName( "KERNEL" ) );
2888 SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2889 Sel->ClearIObjects();
2890 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
2891 aButton->setOn(false);
2895 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
2896 if ( aButton->textLabel().compare(component)==0)
2897 aButton->setOn(true);
2900 } else if (component.compare(QString("Salome"))!= 0) {
2902 SALOMEGUI_ActivateComponentDlg aDlg( this );
2903 int res = aDlg.exec();
2909 onComboActiveComponent(component,true);
2913 onComboActiveComponent(component,true);
2917 onComboActiveComponent(component,true);;
2921 putInfo( tr("INF_CANCELLED") );
2922 myCombo->setCurrentItem (0);
2923 for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) {
2924 aButton->setOn(false);
2933 void QAD_Desktop::activateComponent(const QString& theName, bool isLoadData){
2934 int nbItem = myCombo->count();
2937 for (int i = 0; i < nbItem; i++) {
2938 if (myCombo->text(i).compare(theName)==0) {
2943 myCombo->setCurrentItem (Index);
2944 onComboActiveComponent(theName,isLoadData);
2947 void QAD_Desktop::onButtonActiveComponent( )
2949 QToolButton* obj = (QToolButton*)sender();
2950 activateComponent(obj->textLabel());
2954 Clears All Resources of current component
2956 void QAD_Desktop::clearMenus()
2958 onActiveStudyChanged();
2961 myMenusList.clear();
2963 int length = myXmlHandler->myIdList.Length();
2964 for (int k=length; k>0; k--) {
2966 if ( menuBar()->findItem(myXmlHandler->myIdList.Value(k), &parent) )
2967 parent->removeItem( myXmlHandler->myIdList.Value(k) );
2972 if (myActiveMenus) {
2973 int nbtoolbars = myActiveMenus->getToolBarList().count();
2974 for (int k=0; k<nbtoolbars; k++) {
2975 myActiveMenus->getToolBarList().at(k)->hide();
2976 myActiveMenus->getToolBarList().at(k)->clear();
2978 myActiveMenus->clearToolBar();
2981 QList<QAD_ListPopupMenu> PopupList = myActiveMenus->getPopupMenuList();
2982 QAD_ListPopupMenu* aPopup;
2983 for(aPopup=PopupList.first();aPopup!=NULL;aPopup=PopupList.next()){
2984 aPopup->getPopup()->clear();
2987 myActiveMenus->clearPopupMenu();
2993 typedef bool TwoDim1(QKeyEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
2995 Exports Key Events in active component ( GUI Librairy )
2997 void QAD_Desktop::onKeyPress( QKeyEvent* pe )
2999 // MESSAGE ( "QAD_Desktop::onKeyPress" )
3000 if (!myActiveComp.isEmpty()) {
3001 OSD_Function osdF = mySharedLibrary.DlSymb("OnKeyPress");
3002 if ( osdF != NULL ) {
3003 TwoDim1 (*f1) = (bool (*) (QKeyEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
3004 (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
3009 typedef bool TwoDim(QMouseEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
3011 Exports Mouse Press Events in active component ( GUI Librairy )
3013 bool QAD_Desktop::onMousePress( QMouseEvent* pe )
3015 // MESSAGE ( "QAD_Desktop::onMousePress" )
3016 if (!myActiveComp.isEmpty()) {
3017 OSD_Function osdF = mySharedLibrary.DlSymb("OnMousePress");
3018 if ( osdF != NULL ) {
3019 TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
3020 return (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
3027 Exports Mouse Move Events in active component ( GUI Librairy )
3029 void QAD_Desktop::onMouseMove( QMouseEvent* pe )
3031 if (!myActiveComp.isEmpty()) {
3032 OSD_Function osdF = mySharedLibrary.DlSymb("OnMouseMove");
3033 if ( osdF != NULL ) {
3034 TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
3035 (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
3041 Returns name of active component
3043 const QString& QAD_Desktop::getActiveComponent() const
3045 return myActiveComp;
3049 typedef bool defineP( QString & theContext, QString & theParent, QString & theObject);
3051 void QAD_Desktop::definePopup(QString & theContext,
3052 QString & theParent,
3053 QString & theObject )
3055 if (!myActiveComp.isEmpty()) {
3056 OSD_Function osdF = mySharedLibrary.DlSymb("definePopup");
3057 if ( osdF != NULL ) {
3058 defineP (*f1) = (bool (*) (QString &, QString &, QString &)) osdF;
3059 (*f1)(theContext, theParent, theObject);
3067 void QAD_Desktop::createPopup(QPopupMenu* popupFather, QPopupMenu* popup,
3068 QString text, int popupID, bool separator)
3070 QMenuItem* item = popup->findItem(popupID);
3072 QPopupMenu* popupChild = item->popup();
3074 QPopupMenu* newPopup = new QPopupMenu;
3075 int count = popupChild->count();
3076 // add items at the top of <popupFather>
3077 for (int i = count - 1; i >= 0; i--) {
3078 int j = popupChild->idAt(i);
3079 QString text = popupChild->text(j);
3080 createPopup( newPopup, popupChild, text, j);
3082 popupFather->insertItem(popup->text(popupID),
3083 newPopup, popupID, 0);
3085 if ( !text.isNull() ) {
3086 popupFather->insertItem(popup->text(popupID),
3088 SLOT( onDispatch(int) ), 0, popupID, 0);// try adding item at the top
3089 } /*else if ( separator )
3090 popupFather->insertTearOffHandle(-1, 0);*/
3092 popupFather->insertSeparator(0);
3100 void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext,
3101 const QString & theParent, const QString & theObject )
3103 if ( !myActiveComp.isEmpty() &&
3104 getOperatorMenus()->createPopupMenu(theContext,theParent,theObject) != NULL ) {
3105 QPopupMenu* aPopup = getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup();
3106 int count = aPopup->count();
3108 //for (int i = 0; i < count; i++) {
3109 for (int i = count - 1; i >= 0; i--) {
3110 int id = aPopup->idAt(i);
3111 QString text = aPopup->text(id);
3112 //QString mes("Inserting popup menu item loaded from XML: ");
3114 //MESSAGE ( mes.latin1() )
3116 popup->insertItem(aPopup->text(id),
3118 SLOT( onDispatch(int) ), 0, id, 0);// try adding item at the top
3120 createPopup( popup, aPopup, text, id);
3123 //QString mes("Popup does not exist for given (Context = ");
3124 //mes += theContext;
3125 //mes += ", Parent = ";
3127 //mes += ", Object = ";
3129 //MESSAGE (mes.latin1())
3134 // Should be moved to SALOMEGUI_Application::onCreatePopup()...
3135 if ( myActiveComp.isEmpty() ) {
3136 popup->removeItem(QAD_Display_Popup_ID);
3137 popup->removeItem(QAD_DisplayOnly_Popup_ID);
3138 popup->removeItem(QAD_Erase_Popup_ID);
3139 int id = popup->idAt(popup->count()-1); // last item
3140 if (id < 0 && id != -1) popup->removeItem(id); // separator
3142 if ( popup && theParent.compare("ObjectBrowser")==0 ) {
3143 if ( popup->count()>0 ) {
3144 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()), 0, -1, 2);
3145 popup->insertSeparator (3);
3148 popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()) );
3155 typedef bool activeStudyChanged(QAD_Desktop*);
3157 void QAD_Desktop::onActiveStudyChanged()
3159 if (!myActiveComp.isEmpty()) {
3160 OSD_Function osdF = mySharedLibrary.DlSymb("activeStudyChanged");
3161 if ( osdF != NULL ) {
3162 activeStudyChanged (*f1) = (bool (*) (QAD_Desktop*)) osdF;
3168 typedef bool customP(QAD_Desktop*, QPopupMenu*, const QString & theContext,
3169 const QString & theParent, const QString & theObject);
3171 Custom popup ( GUI Library )
3173 void QAD_Desktop::customPopup(QPopupMenu* popup, const QString & theContext,
3174 const QString & theParent, const QString & theObject)
3176 if (!myActiveComp.isEmpty()) {
3177 OSD_Function osdF = mySharedLibrary.DlSymb("customPopup");
3178 if ( osdF != NULL ) {
3179 customP (*f1) = (bool (*) (QAD_Desktop*, QPopupMenu*, const QString &,
3180 const QString &, const QString &)) osdF;
3181 (*f1)(this, popup, theContext, theParent, theObject);
3186 void QAD_Desktop::onObjectBrowser()
3188 bool checkDiff = false;
3190 bool state = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn").compare("true") == 0;
3192 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() != state )
3196 if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() ) {
3198 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "true");
3201 QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "false");
3205 if ( myStdActions.at( PrefObjectBrowserValueId )->isOn() ) {
3207 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "true");
3210 QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "false");
3214 if ( myStdActions.at( PrefObjectBrowserIAPPId )->isOn() ) {
3216 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "true");
3219 QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "false");
3222 /* To sort created object in chrono order or reverse chrono order */
3223 bool showCHRONO_SORT ;
3224 if ( myStdActions.at( PrefObjectBrowserCHRONO_SORTId )->isOn() ) {
3225 showCHRONO_SORT = true;
3226 QAD_CONFIG->addSetting( "ObjectBrowser:CHRONO_SORT", "true");
3228 showCHRONO_SORT = false;
3229 QAD_CONFIG->addSetting( "ObjectBrowser:CHRONO_SORT", "false");
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 sf->getLeftFrame()->getObjectBrowser()->setShowInfoColumns( showEntry );
3239 sf->getLeftFrame()->getObjectBrowser()->setShowValueColumn( showValue );
3240 sf->getLeftFrame()->getObjectBrowser()->setEnableChronoSort( showCHRONO_SORT );
3241 // sf->getLeftFrame()->getObjectBrowser()->setShowIAPP( showIAPP ); // this is done by below updateObjBrowser() call
3243 study->updateObjBrowser(true);
3248 void QAD_Desktop::onViewerTrihedron()
3250 QString Size = QAD_CONFIG->getSetting("Viewer:TrihedronSize");
3253 SALOMEGUI_TrihedronSizeDlg *Dlg = new SALOMEGUI_TrihedronSizeDlg(this);
3254 if (!Size.isEmpty())
3255 Dlg->setTrihedronSize(Size.toInt());
3256 int r = Dlg->exec();
3257 dim = Dlg->getTrihedronSize();
3260 if (r == QDialog::Accepted) {
3261 QAD_CONFIG->addSetting("Viewer:TrihedronSize", dim);
3264 QList<QAD_Study>& studies = myActiveApp->getStudies();
3265 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3266 int nbSf = study->getStudyFramesCount();
3267 for ( int i = 0; i < nbSf; i++ ) {
3268 study->getStudyFrame(i)->getRightFrame()->getViewFrame()->SetTrihedronSize((int)dim);
3275 void QAD_Desktop::onExternalBrowser()
3278 QString theApp = QAD_CONFIG->getSetting("ExternalBrowser:Application");
3279 QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3281 SALOMEGUI_ExternalBrowserDlg *Dlg = new SALOMEGUI_ExternalBrowserDlg(this);
3283 if (!theApp.isEmpty())
3285 QString theParams = QAD_CONFIG->getSetting("ExternalBrowser:Parameters");
3286 Dlg->setSettings(theApp, theParams);
3288 int r = Dlg->exec();
3289 QString theAppFromDialog = Dlg->getApp();
3290 QString theParamsFromDialog = Dlg->getParams();
3293 if (r == QDialog::Accepted)
3295 QAD_CONFIG->addSetting("ExternalBrowser:Application", theAppFromDialog );
3296 QAD_CONFIG->addSetting("ExternalBrowser:Parameters", theParamsFromDialog );
3302 void QAD_Desktop::onDirList()
3304 // getting dir list from settings
3305 QStringList dirList = QStringList::split(';', QAD_CONFIG->getSetting("FileDlg:QuickDirList"), false);
3306 QAD_DirListDlg* dlg = new QAD_DirListDlg(this);
3307 dlg->setPathList(dirList);
3308 if ( dlg->exec() == QDialog::Accepted) {
3309 dlg->getPathList(dirList);
3310 QAD_CONFIG->addSetting("FileDlg:QuickDirList", dirList.join(";"));
3315 void QAD_Desktop::onConsoleFontAction()
3317 // getting font from settings
3318 QString fntSet = QAD_CONFIG->getSetting("Viewer:ConsoleFont");
3319 QFont font = QAD_Tools::stringToFont( fntSet );
3321 font = QFontDialog::getFont( &bOk, font, this );
3323 fntSet = QAD_Tools::fontToString( font );
3324 QAD_CONFIG->addSetting("Viewer:ConsoleFont", fntSet );
3327 QList<QAD_Study>& studies = myActiveApp->getStudies();
3328 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3329 int nbSf = study->getStudyFramesCount();
3330 for ( int i = 0; i < nbSf; i++ ) {
3331 study->getStudyFrame(i)->getRightFrame()->getPyEditor()->setFont( font );
3332 study->getStudyFrame(i)->getRightFrame()->getMessage()->setFont( font );
3339 void QAD_Desktop::onSavePref()
3341 QAD_CONFIG->createConfigFile(true);
3344 //VRV: T2.5 - add default viewer
3345 void QAD_Desktop::onDefaultViewer(QActionP * theAction)
3347 int type = VIEW_TYPE_MAX;
3350 if (myStdActions.at(DefaultViewerOCCId) == theAction)
3352 else if (myStdActions.at(DefaultViewerVTKId) == theAction)
3354 else if (myStdActions.at(DefaultGraphSupervisorId) == theAction)
3355 type = VIEW_GRAPHSUPERV;
3356 else if (myStdActions.at(DefaultPlot2dId) == theAction)
3358 if ( type != VIEW_TYPE_MAX )
3359 QAD_CONFIG->addSetting( "Viewer:DefaultViewer", QString::number( type ) );
3361 //VRV: T2.5 - add default viewer
3363 void QAD_Desktop::onViewerOCC()
3365 QString BackgroundColorRed = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorRed");
3366 QString BackgroundColorGreen = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorGreen");
3367 QString BackgroundColorBlue = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorBlue");
3370 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3371 color = QColor(BackgroundColorRed.toInt(),
3372 BackgroundColorGreen.toInt(),
3373 BackgroundColorBlue.toInt());
3375 color = QColor(35, 136, 145);
3377 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3380 if ( myActiveApp ) {
3381 QList<QAD_Study>& studies = myActiveApp->getStudies();
3382 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3383 int nbSf = study->getStudyFramesCount();
3384 for ( int i = 0; i < nbSf; i++ ) {
3385 QAD_StudyFrame* sf = study->getStudyFrame(i);
3386 if ( sf->getTypeView() == VIEW_OCC ) {
3387 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3392 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", c.red() );
3393 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", c.green() );
3394 QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", c.blue() );
3398 void QAD_Desktop::onGraphSupervisor()
3400 QString BackgroundColorRed = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed");
3401 QString BackgroundColorGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen");
3402 QString BackgroundColorBlue = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue");
3405 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3406 color = QColor(BackgroundColorRed.toInt(),
3407 BackgroundColorGreen.toInt(),
3408 BackgroundColorBlue.toInt());
3410 color = QColor(35, 136, 145);
3412 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3415 if ( myActiveApp ) {
3416 QList<QAD_Study>& studies = myActiveApp->getStudies();
3417 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3418 int nbSf = study->getStudyFramesCount();
3419 for ( int i = 0; i < nbSf; i++ ) {
3420 QAD_StudyFrame* sf = study->getStudyFrame(i);
3421 if ( sf->getTypeView() == VIEW_GRAPHSUPERV ) {
3422 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3428 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorRed", c.red() );
3429 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorGreen", c.green() );
3430 QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorBlue", c.blue() );
3434 void QAD_Desktop::onViewerVTK()
3436 QString BackgroundColorRed = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
3437 QString BackgroundColorGreen = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
3438 QString BackgroundColorBlue = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
3441 if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() )
3442 color = QColor(BackgroundColorRed.toInt(),
3443 BackgroundColorGreen.toInt(),
3444 BackgroundColorBlue.toInt());
3446 color = QColor(0, 0, 0);
3448 QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3451 if ( myActiveApp ) {
3452 QList<QAD_Study>& studies = myActiveApp->getStudies();
3453 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3454 int nbSf = study->getStudyFramesCount();
3455 for ( int i = 0; i < nbSf; i++ ) {
3456 QAD_StudyFrame* sf = study->getStudyFrame(i);
3457 if ( sf->getTypeView() == VIEW_VTK ) {
3458 sf->getRightFrame()->getViewFrame()->setBackgroundColor( c );
3464 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", c.red() );
3465 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", c.green() );
3466 QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", c.blue() );
3470 void QAD_Desktop::onPlot2d()
3473 if ( QAD_CONFIG->hasSetting( "Plot2d:Background" ) ) {
3474 QString bgString = QAD_CONFIG->getSetting( "Plot2d:Background" );
3475 QStringList bgData = QStringList::split( ":", bgString, true );
3476 int bgRed = 0, bgGreen = 0, bgBlue = 0;
3477 if ( bgData.count() > 0 ) bgRed = bgData[ 0 ].toInt();
3478 if ( bgData.count() > 1 ) bgGreen = bgData[ 1 ].toInt();
3479 if ( bgData.count() > 2 ) bgBlue = bgData[ 2 ].toInt();
3480 color = QColor( bgRed, bgGreen, bgBlue );
3483 color = QColor(0, 0, 0);
3486 color = QColorDialog::getColor( color, QAD_Application::getDesktop() );
3488 if ( color.isValid() ) {
3489 if ( myActiveApp ) {
3490 QList<QAD_Study>& studies = myActiveApp->getStudies();
3491 for ( QAD_Study* study = studies.first(); study; study = studies.next() ) {
3492 int nbSf = study->getStudyFramesCount();
3493 for ( int i = 0; i < nbSf; i++ ) {
3494 QAD_StudyFrame* sf = study->getStudyFrame(i);
3495 if ( sf->getTypeView() == VIEW_PLOT2D ) {
3496 sf->getRightFrame()->getViewFrame()->setBackgroundColor( color );
3502 bgData.append( QString::number( color.red() ) );
3503 bgData.append( QString::number( color.green() ) );
3504 bgData.append( QString::number( color.blue() ) );
3505 QAD_CONFIG->addSetting( "Plot2d:Background", bgData.join( ":" ) );
3510 void QAD_Desktop::helpAbout()
3512 SALOMEGUI_AboutDlg* About = new SALOMEGUI_AboutDlg( QAD_Application::getDesktop(), tr("MEN_ABOUT"));
3517 // /* Help Search */
3518 // void QAD_Desktop::helpSearch()
3522 // /* Help Contents */
3523 // void QAD_Desktop::helpContents()
3525 // if (myActiveComp == "")
3526 // myActiveComp = getComponentUserName( "KERNEL" ); //NRI "Salome";
3530 // if (dir = getenv( getComponentName( myActiveComp ) + "_ROOT_DIR")) {
3531 // root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + QAD_Tools::addSlash("share") + QAD_Tools::addSlash("salome") + "doc" );
3532 // if ( QFileInfo( root + "index.html" ).exists() ) {
3533 // helpContext( root + "index.html", "" );
3536 // root = QAD_Tools::addSlash( root + "html" );
3537 // if ( QFileInfo( root + "index.html" ).exists() ) {
3538 // helpContext( root + "index.html", "" );
3541 // root = QAD_Tools::addSlash( root + "html" );
3542 // if ( QFileInfo( root + "index.html" ).exists() ) {
3543 // helpContext( root + "index.html", "" );
3549 // // //NRI getHelpWindow()->contents();
3550 // // getHelpWindow()->show();
3551 // // getHelpWindow()->raise();
3552 // // getHelpWindow()->setActiveWindow();
3556 // void QAD_Desktop::helpContext(const QString& source, const QString& context)
3558 // // getHelpWindow()->context(source, context);
3559 // // getHelpWindow()->show();
3560 // // getHelpWindow()->raise();
3561 // // getHelpWindow()->setActiveWindow();
3564 /* Preferences/MultiFile Save */
3565 void QAD_Desktop::onMultiFileSave()
3567 if ( myStdActions.at( PrefMultiFileSave )->isOn() )
3568 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "true");
3570 QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "false");
3573 /* Preferences/ASCII Save */
3574 void QAD_Desktop::onASCIISave()
3576 if ( myStdActions.at( PrefASCIISave )->isOn() )
3577 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "true");
3579 QAD_CONFIG->addSetting( "Desktop:ASCIISave", "false");
3582 /*********************************************************************
3583 ** Class: AppSelectionDlg
3584 ** Descr: Dialog for the selection of the application when several
3585 ** applications exist in the desktop and new study creation
3586 ** is activated by user.
3588 **********************************************************************/
3590 \class Desktop_AppSelectionDlg QAD_Desktop.h
3591 \brief Dialog for the selection of the application when several
3592 applications exist in the desktop and new study creation
3593 is activated by user.
3598 Desktop_AppSelectionDlg::Desktop_AppSelectionDlg( QAD_Desktop* desktop,
3599 QList<QAD_Application>& apps ) :
3600 QDialog( desktop, 0, true ),
3604 QAD_ASSERT_DEBUG_ONLY ( desktop );
3605 setCaption( tr("INF_DESK_DOC_CREATE") );
3606 if ( desktop->icon() )
3607 setIcon( *desktop->icon() );
3609 QBoxLayout* mainLayout = new QVBoxLayout( this, 5 );
3611 /* Create selection buttons */
3612 QVButtonGroup* buttonGrp = new QVButtonGroup ( this );
3613 buttonGrp->setExclusive ( true );
3614 QBoxLayout* vLayout = new QVBoxLayout( mainLayout, 5 );
3615 vLayout->addWidget ( buttonGrp );
3617 /* Create selection button for available app */
3619 for ( QAD_Application* app = myApps.first(); app; app = myApps.next(), id++ )
3621 /* add radio button for application */
3622 buttonGrp->insert( new QRadioButton( app->getStudyDescription() +
3623 " (*." + app->getStudyExtension() + ")", buttonGrp ), id );
3626 /* make the first application selected */
3627 buttonGrp->setButton( 0 );
3629 /* listen to the selection */
3630 QAD_ASSERT ( connect ( buttonGrp, SIGNAL(clicked(int)), this, SLOT(onAppSelected(int)) ));
3632 /* Create OK/Cancel buttons
3634 QBoxLayout* hLayout = new QHBoxLayout( mainLayout, 5 );
3635 QPushButton* buttonOK = new QPushButton( tr("BUT_OK"), this );
3636 QPushButton* buttonCancel = new QPushButton( tr("BUT_CANCEL"), this );
3637 QPushButton* buttonHelp = new QPushButton( tr("BUT_HELP"), this );
3638 buttonOK->setDefault( true );
3640 hLayout->addStretch();
3641 hLayout->addWidget( buttonOK );
3642 hLayout->addWidget( buttonCancel );
3643 hLayout->addWidget( buttonHelp );
3645 /* connect buttons */
3646 QAD_ASSERT ( connect( buttonOK, SIGNAL(clicked()), this, SLOT(accept())) );
3647 QAD_ASSERT ( connect( buttonCancel, SIGNAL(clicked()), this, SLOT(reject())) );
3648 QAD_ASSERT ( connect( buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())) );
3650 /* disable resizing */
3651 setFixedSize( 0, 0 );
3652 setSizePolicy( QSizePolicy ( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
3655 Desktop_AppSelectionDlg::~Desktop_AppSelectionDlg()
3659 QAD_Application* Desktop_AppSelectionDlg::selectedApp() const
3661 return myApps.at( myAppId );
3664 void Desktop_AppSelectionDlg::resizeEvent( QResizeEvent* e )
3666 QAD_Tools::centerWidget( this, parentWidget() );
3672 void Desktop_AppSelectionDlg::onAppSelected( int id )
3677 void Desktop_AppSelectionDlg::onHelp()