1 // applicationwindow.cpp
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/17/2010 Added this text. :-)
13 // JLH 05/27/2010 Finished refactoring old Qt3 based action handling code to
14 // Qt4's much more sensible action handling
17 #include "applicationwindow.h"
20 #include "rs_actiondrawlinefree.h"
21 #include "rs_actionlibraryinsert.h"
22 #include "rs_actionprintpreview.h"
23 #include "rs_creation.h"
24 #include "rs_dialogfactory.h"
25 #include "rs_dimaligned.h"
26 #include "rs_dimlinear.h"
27 #include "rs_dimradial.h"
28 #include "rs_ellipse.h"
29 #include "rs_fileio.h"
31 #include "rs_insert.h"
33 #include "paintintf.h"
34 #include "rs_script.h"
35 #include "rs_scriptlist.h"
38 #include "rs_staticgraphicview.h"
39 #include "rs_system.h"
44 #include "rs_camdialog.h"
45 #include "rs_simulationcontrols.h"
48 #include "qg_colorbox.h"
49 #include "qg_filedialog.h"
50 #include "qg_pentoolbar.h"
51 #include "recentfiles.h"
52 #include "cadtoolbar.h"
53 #include "cadtoolbarmain.h"
54 #include "coordinatewidget.h"
55 #include "dlgimageoptions.h"
56 #include "mousewidget.h"
57 #include "selectionwidget.h"
59 #include "mdiwindow.h"
60 #include "qc_dialogfactory.h"
61 #include "createqtactions.h"
64 ApplicationWindow * ApplicationWindow::appWindow = NULL;
67 # define QC_APP_ICON "qcad.png"
70 # define QC_APP_ICON16 "qcad16.png"
73 extern QSplashScreen * splash;
76 * Constructor. Initializes the app.
78 ApplicationWindow::ApplicationWindow():
79 // Q3MainWindow(0, "", Qt::WDestructiveClose), QG_MainWindowInterface()
80 QMainWindow((QWidget *)NULL/*,this is not a Qt::WindowFlags --> Qt::WA_DeleteOnClose*/), QG_MainWindowInterface()
82 RS_DEBUG->print("ApplicationWindow::ApplicationWindow");
85 //no assistant = NULL;
88 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: setting icon");
89 // setIcon(qPixmapFromMimeSource(QC_APP_ICON));
90 // setWindowIcon(qPixmapFromMimeSource(QC_APP_ICON));
91 setWindowIcon(QIcon(":/res/" QC_APP_ICON));
93 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler");
94 actionHandler = new QG_ActionHandler(this);
95 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler: OK");
98 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating scripter");
99 scripter = new QS_Scripter(this, this);
100 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating scripter: OK");
103 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init view");
105 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init toolbar");
107 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init actions");
109 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init menu bar");
111 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init status bar");
114 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory");
115 dialogFactory = new QC_DialogFactory(this, optionWidget);
116 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory: OK");
117 RS_DEBUG->print("setting dialog factory object");
119 if (RS_DialogFactory::instance() == NULL)
120 RS_DEBUG->print("no RS_DialogFactory instance");
122 RS_DEBUG->print("got RS_DialogFactory instance");
124 RS_DialogFactory::instance()->setFactoryObject(dialogFactory);
125 RS_DEBUG->print("setting dialog factory object: OK");
127 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init settings");
130 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init MDI");
133 // Disable menu and toolbar items
134 emit windowsChanged(FALSE);
136 //FAIL statusBar()->showMessage(QC_APPNAME " Ready", 2000);
137 statusBar()->showMessage("Architektonas Ready", 2000);
138 //setFocusPolicy(WheelFocus);
144 ApplicationWindow::~ApplicationWindow()
146 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow");
148 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting scripter");
150 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting scripter: OK");
153 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting action handler");
154 delete actionHandler;
155 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting action handler: OK");
157 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory");
158 delete dialogFactory;
159 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory: OK");
161 //no RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: "
162 // "deleting assistant..");
163 // if (assistant!=NULL) {
166 // RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: "
167 // "deleting assistant: OK");
168 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: OK");
172 * Runs the start script if scripting is available.
174 void ApplicationWindow::slotRunStartScript()
176 slotRunScript("autostart.qs");
180 * Runs a script. The action that triggers this slot has to carry the
181 * name of the script file.
183 void ApplicationWindow::slotRunScript()
185 RS_DEBUG->print("ApplicationWindow::slotRunScript");
187 const QObject * s = sender();
191 QString script = ((QAction *)s)->text();
192 RS_DEBUG->print("ApplicationWindow::slotRunScript: %s", script.toLatin1().data());
193 slotRunScript(script);
198 * Runs the script with the given name.
200 void ApplicationWindow::slotRunScript(const QString & name)
203 RS_DEBUG->print("ApplicationWindow::slotRunScript");
205 if (scripter == NULL)
207 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotRunScript: scripter not initialized");
211 statusBar()->showMessage(tr("Running script '%1'").arg(name), 2000);
213 QStringList scriptList = RS_SYSTEM->getScriptList();
214 scriptList.append(RS_SYSTEM->getHomeDir() + "/.qcad/" + name);
216 for (QStringList::Iterator it = scriptList.begin(); it!=scriptList.end(); ++it)
218 RS_DEBUG->print("ApplicationWindow::slotRunScript: checking script '%s'", (*it).toLatin1().data();
221 if (fi.exists() && fi.fileName() == name)
223 RS_DEBUG->print("ApplicationWindow::slotRunScript: running '%s'", (*it).toLatin1().data());
224 scripter->runScript(*it, "main");
231 * Called from toolbar buttons that were added by scripts to
234 void ApplicationWindow::slotInsertBlock()
236 const QObject * s = sender();
240 QString block = ((QAction *)s)->text();
241 RS_DEBUG->print("ApplicationWindow::slotInsertBlock: %s", block.toLatin1().data());
242 slotInsertBlock(block);
247 * Called to insert blocks.
249 void ApplicationWindow::slotInsertBlock(const QString & name)
251 RS_DEBUG->print("ApplicationWindow::slotInsertBlock: '%s'", name.toLatin1().data());
253 statusBar()->showMessage(tr("Inserting block '%1'").arg(name), 2000);
255 GraphicView * graphicView = getGraphicView();
256 RS_Document * document = getDocument();
258 if (graphicView && document)
260 RS_ActionLibraryInsert * action = new RS_ActionLibraryInsert(*document, *graphicView);
261 action->setFile(name);
262 graphicView->setCurrentAction(action);
267 * Shows the main application window and a splash screen.
269 void ApplicationWindow::show()
271 #ifdef QSPLASHSCREEN_H
278 #ifdef QSPLASHSCREEN_H
282 qApp->processEvents();
283 splash->clearMessage();
284 # ifdef QC_DELAYED_SPLASH_SCREEN
285 QTimer::singleShot(1000 * 2, this, SLOT(finishSplashScreen()));
287 finishSplashScreen();
294 * Called when the splash screen has to terminate.
296 void ApplicationWindow::finishSplashScreen()
298 #ifdef QSPLASHSCREEN_H
301 splash->finish(this);
309 * Close Event. Called when the user tries to close the app.
311 void ApplicationWindow::closeEvent(QCloseEvent * /*ce*/)
313 RS_DEBUG->print("ApplicationWindow::closeEvent()");
315 RS_DEBUG->print("ApplicationWindow::closeEvent(): OK");
319 * Handles right-clicks for moving back to the last cad tool bar.
321 void ApplicationWindow::mouseReleaseEvent(QMouseEvent * e)
323 if (e->button() == Qt::RightButton && cadToolBar != NULL)
324 cadToolBar->showToolBarMain();
330 * Initializes the MDI workspace.
332 void ApplicationWindow::initMDI()
334 RS_DEBUG->print("ApplicationWindow::initMDI() begin");
336 /* Could use QVBoxLayout instead of Q3VBox, but do we even need to? */
337 // Q3VBox * vb = new Q3VBox(this);
338 // vb->setFrameStyle(Q3Frame::StyledPanel | Q3Frame::Sunken);
339 // workspace = new QMdiArea(vb);
340 workspace = new QMdiArea(this);
341 // workspace->setScrollBarsEnabled(true);
342 // setCentralWidget(vb);
343 setCentralWidget(workspace);//JLH:hmm. (Yes, it works! \o/)
344 RS_DEBUG->print("ApplicationWindow::initMDI(): workspace=%08X", workspace);
346 //#warning "Object::connect: No such signal QMdiArea::windowActivated(QWidget *)"
347 // connect(workspace, SIGNAL(windowActivated(QWidget *)), this, SLOT(slotWindowActivated(QWidget *)));
348 connect(workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this,
349 SLOT(slotWindowActivated(QMdiSubWindow *)));
351 RS_DEBUG->print("ApplicationWindow::initMDI() end");
355 * Initializes all QActions of the application.
356 * (Actually, it creates all application menus & toolbars. All actions are
357 * created in CreateQtActions() and simply referenced here.)
359 void ApplicationWindow::initActions()
361 RS_DEBUG->print("ApplicationWindow::initActions()");
362 CreateQtActions(this);
367 QMenu * menu = new QMenu(tr("&File"), this);
368 QToolBar * tb = fileToolBar;
369 tb->setWindowTitle("File");
370 // tb->setCloseMode(Q3DockWindow::Undocked);
372 menu->addAction(actionFileNew);
373 tb->addAction(actionFileNew);
374 connect(actionFileNew, SIGNAL(activated()), this, SLOT(slotFileNew()));
375 menu->addAction(actionFileOpen);
376 tb->addAction(actionFileOpen);
377 connect(actionFileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen()));
378 menu->addAction(actionFileSave);
379 tb->addAction(actionFileSave);
380 connect(actionFileSave, SIGNAL(activated()), this, SLOT(slotFileSave()));
381 connect(this, SIGNAL(windowsChanged(bool)), actionFileSave, SLOT(setEnabled(bool)));
382 menu->addAction(actionFileSaveAs);
383 connect(actionFileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs()));
384 connect(this, SIGNAL(windowsChanged(bool)), actionFileSaveAs, SLOT(setEnabled(bool)));
385 menu->addAction(actionFileExport);
386 connect(actionFileExport, SIGNAL(activated()), this, SLOT(slotFileExport()));
387 connect(this, SIGNAL(windowsChanged(bool)), actionFileExport, SLOT(setEnabled(bool)));
389 menu->addSeparator();
391 menu->addAction(actionFileClose);
392 connect(actionFileClose, SIGNAL(activated()), this, SLOT(slotFileClose()));
393 connect(this, SIGNAL(windowsChanged(bool)), actionFileClose, SLOT(setEnabled(bool)));
395 menu->addSeparator();
397 menu->addAction(actionFilePrint);
398 tb->addAction(actionFilePrint);
399 connect(actionFilePrint, SIGNAL(activated()), this, SLOT(slotFilePrint()));
400 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrint, SLOT(setEnabled(bool)));
401 menu->addAction(actionFilePrintPreview);
402 tb->addAction(actionFilePrintPreview);
403 connect(actionFilePrintPreview, SIGNAL(toggled(bool)), this, SLOT(slotFilePrintPreview(bool)));
404 connect(this, SIGNAL(printPreviewChanged(bool)), actionFilePrintPreview, SLOT(setOn(bool)));
405 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrintPreview, SLOT(setEnabled(bool)));
407 menu->addSeparator();
409 menu->addAction(actionFileQuit);
410 connect(actionFileQuit, SIGNAL(activated()), this, SLOT(slotFileQuit()));
412 menu->addSeparator();
414 menuBar()->addMenu(menu);
415 addToolBar(Qt::TopToolBarArea, tb);
421 menu = new QMenu(tr("&Edit"), this);
423 tb->setWindowTitle("Edit");
424 // tb->setCloseMode(Q3DockWindow::Undocked);
426 // action = actionFactory.createAction(RS2::ActionEditUndo, actionHandler);
427 menu->addAction(actionEditUndo);
428 tb->addAction(actionEditUndo);
429 connect(actionEditUndo, SIGNAL(activated()), actionHandler, SLOT(slotEditUndo()));
430 connect(this, SIGNAL(windowsChanged(bool)), actionEditUndo, SLOT(setEnabled(bool)));
431 // action = actionFactory.createAction(RS2::ActionEditRedo, actionHandler);
432 menu->addAction(actionEditRedo);
433 tb->addAction(actionEditRedo);
434 connect(actionEditRedo, SIGNAL(activated()), actionHandler, SLOT(slotEditRedo()));
435 connect(this, SIGNAL(windowsChanged(bool)), actionEditRedo, SLOT(setEnabled(bool)));
438 menu->addSeparator();
440 // action = actionFactory.createAction(RS2::ActionEditCut, actionHandler);
441 menu->addAction(actionEditCut);
442 tb->addAction(actionEditCut);
443 connect(actionEditCut, SIGNAL(activated()), actionHandler, SLOT(slotEditCut()));
444 connect(this, SIGNAL(windowsChanged(bool)), actionEditCut, SLOT(setEnabled(bool)));
445 // action = actionFactory.createAction(RS2::ActionEditCopy, actionHandler);
446 menu->addAction(actionEditCopy);
447 tb->addAction(actionEditCopy);
448 connect(actionEditCopy, SIGNAL(activated()), actionHandler, SLOT(slotEditCopy()));
449 connect(this, SIGNAL(windowsChanged(bool)), actionEditCopy, SLOT(setEnabled(bool)));
450 // action = actionFactory.createAction(RS2::ActionEditPaste, actionHandler);
451 menu->addAction(actionEditPaste);
452 tb->addAction(actionEditPaste);
453 connect(actionEditPaste, SIGNAL(activated()), actionHandler, SLOT(slotEditPaste()));
454 connect(this, SIGNAL(windowsChanged(bool)), actionEditPaste, SLOT(setEnabled(bool)));
456 menu->addSeparator();
458 menu->addAction(actionOptionsGeneral);
459 connect(actionOptionsGeneral, SIGNAL(activated()), this, SLOT(slotOptionsGeneral()));
460 menu->addAction(actionOptionsDrawing);
461 connect(actionOptionsDrawing, SIGNAL(activated()), actionHandler, SLOT(slotOptionsDrawing()));
462 connect(this, SIGNAL(windowsChanged(bool)), actionOptionsDrawing, SLOT(setEnabled(bool)));
464 menuBar()->addMenu(menu);
465 addToolBar(Qt::TopToolBarArea, tb);
469 //menu = new QPopupMenu(this);
470 //menuBar()->insertItem(tr("&Options"), menu);
472 // Viewing / Zooming actions:
474 // menu = new Q3PopupMenu(this);
475 menu = new QMenu(tr("&View"), this);
476 //obsolete: menu->setCheckable(true);
478 tb->setWindowTitle("View");
479 // tb->setCloseMode(Q3DockWindow::Undocked);
481 // action = actionFactory.createAction(RS2::ActionViewGrid, this);
482 menu->addAction(actionViewGrid);
483 tb->addAction(actionViewGrid);
484 actionViewGrid->setChecked(true);
485 connect(actionViewGrid, SIGNAL(toggled(bool)), this, SLOT(slotViewGrid(bool)));
486 connect(this, SIGNAL(gridChanged(bool)), actionViewGrid, SLOT(setOn(bool)));
487 connect(this, SIGNAL(windowsChanged(bool)), actionViewGrid, SLOT(setEnabled(bool)));
489 settings.beginGroup("Appearance");
490 bool draftMode = settings.value("DraftMode", false).toBool();
493 // action = actionFactory.createAction(RS2::ActionViewDraft, this);
494 menu->addAction(actionViewDraft);
495 tb->addAction(actionViewDraft);
496 actionViewDraft->setChecked(draftMode);
497 connect(actionViewDraft, SIGNAL(toggled(bool)), this, SLOT(slotViewDraft(bool)));
498 connect(this, SIGNAL(draftChanged(bool)), actionViewDraft, SLOT(setOn(bool)));
499 connect(this, SIGNAL(windowsChanged(bool)), actionViewDraft, SLOT(setEnabled(bool)));
502 action = actionFactory.createAction(RS2::ActionViewLayerList, this);
504 action->setChecked(true);
505 action = actionFactory.createAction(RS2::ActionViewBlockList, this);
507 action->setChecked(true);
508 action = actionFactory.createAction(RS2::ActionViewOptionToolbar, this);
510 action->setChecked(true);
511 action = actionFactory.createAction(RS2::ActionViewCommandLine, this);
513 action->setChecked(true);*/
515 // action = actionFactory.createAction(RS2::ActionZoomRedraw, actionHandler);
516 menu->addAction(actionZoomRedraw);
517 tb->addAction(actionZoomRedraw);
518 connect(actionZoomRedraw, SIGNAL(activated()), actionHandler, SLOT(slotZoomRedraw()));
519 connect(this, SIGNAL(windowsChanged(bool)), actionZoomRedraw, SLOT(setEnabled(bool)));
520 // action = actionFactory.createAction(RS2::ActionZoomIn, actionHandler);
521 menu->addAction(actionZoomIn);
522 tb->addAction(actionZoomIn);
523 connect(actionZoomIn, SIGNAL(activated()), actionHandler, SLOT(slotZoomIn()));
524 connect(this, SIGNAL(windowsChanged(bool)), actionZoomIn, SLOT(setEnabled(bool)));
525 // action = actionFactory.createAction(RS2::ActionZoomOut, actionHandler);
526 menu->addAction(actionZoomOut);
527 tb->addAction(actionZoomOut);
528 connect(actionZoomOut, SIGNAL(activated()), actionHandler, SLOT(slotZoomOut()));
529 connect(this, SIGNAL(windowsChanged(bool)), actionZoomOut, SLOT(setEnabled(bool)));
530 // action = actionFactory.createAction(RS2::ActionZoomAuto, actionHandler);
531 menu->addAction(actionZoomAuto);
532 tb->addAction(actionZoomAuto);
533 connect(actionZoomAuto, SIGNAL(activated()), actionHandler, SLOT(slotZoomAuto()));
534 connect(this, SIGNAL(windowsChanged(bool)), actionZoomAuto, SLOT(setEnabled(bool)));
535 // action = actionFactory.createAction(RS2::ActionZoomPrevious, actionHandler);
536 menu->addAction(actionZoomPrevious);
537 tb->addAction(actionZoomPrevious);
538 connect(actionZoomPrevious, SIGNAL(activated()), actionHandler, SLOT(slotZoomPrevious()));
539 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPrevious, SLOT(setEnabled(bool)));
540 // action = actionFactory.createAction(RS2::ActionZoomWindow, actionHandler);
541 menu->addAction(actionZoomWindow);
542 tb->addAction(actionZoomWindow);
543 connect(actionZoomWindow, SIGNAL(activated()), actionHandler, SLOT(slotZoomWindow()));
544 connect(this, SIGNAL(windowsChanged(bool)), actionZoomWindow, SLOT(setEnabled(bool)));
545 // action = actionFactory.createAction(RS2::ActionZoomPan, actionHandler);
546 menu->addAction(actionZoomPan);
547 tb->addAction(actionZoomPan);
548 connect(actionZoomPan, SIGNAL(activated()), actionHandler, SLOT(slotZoomPan()));
549 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPan, SLOT(setEnabled(bool)));
551 menu->addSeparator();
553 // action = actionFactory.createAction(RS2::ActionViewStatusBar, this);
554 menu->addAction(actionViewStatusbar);
555 actionViewStatusbar->setChecked(true);
556 connect(actionViewStatusbar, SIGNAL(toggled(bool)), this, SLOT(slotViewStatusBar(bool)));
559 menu->insertItem(tr("Vie&ws"), createDockWindowMenu(NoToolBars));
560 menu->insertItem(tr("Tool&bars"), createDockWindowMenu(OnlyToolBars));
562 //Actually, this isn't really needed... This crap is maintained by Qt...
563 //#warning "!!! More stuff to port to Qt4 !!!"
566 menu->addAction(actionFocusCommandLine);
567 connect(actionFocusCommandLine, SIGNAL(activated()), this, SLOT(slotFocusCommandLine()));
568 connect(this, SIGNAL(windowsChanged(bool)), actionFocusCommandLine, SLOT(setEnabled(bool)));
569 menuBar()->addMenu(menu);
570 //addToolBar(tb, tr("View"));
571 // addDockWindow(tb, tr("View"), Qt::DockTop);
572 addToolBar(Qt::TopToolBarArea, tb);
574 // Selecting actions:
576 menu = new QMenu(tr("&Select"), this);
577 // action = actionFactory.createAction(RS2::ActionDeselectAll, actionHandler);
578 menu->addAction(actionDeselectAll);
579 connect(actionDeselectAll, SIGNAL(activated()), actionHandler, SLOT(slotDeselectAll()));
580 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectAll, SLOT(setEnabled(bool)));
581 // action = actionFactory.createAction(RS2::ActionSelectAll, actionHandler);
582 menu->addAction(actionSelectAll);
583 connect(actionSelectAll, SIGNAL(activated()), actionHandler, SLOT(slotSelectAll()));
584 connect(this, SIGNAL(windowsChanged(bool)), actionSelectAll, SLOT(setEnabled(bool)));
585 // action = actionFactory.createAction(RS2::ActionSelectSingle, actionHandler);
586 menu->addAction(actionSelectSingle);
587 connect(actionSelectSingle, SIGNAL(activated()), actionHandler, SLOT(slotSelectSingle()));
588 connect(this, SIGNAL(windowsChanged(bool)), actionSelectSingle, SLOT(setEnabled(bool)));
589 // action = actionFactory.createAction(RS2::ActionSelectContour, actionHandler);
590 menu->addAction(actionSelectContour);
591 connect(actionSelectContour, SIGNAL(activated()), actionHandler, SLOT(slotSelectContour()));
592 connect(this, SIGNAL(windowsChanged(bool)), actionSelectContour, SLOT(setEnabled(bool)));
593 // action = actionFactory.createAction(RS2::ActionDeselectWindow, actionHandler);
594 menu->addAction(actionDeselectWindow);
595 connect(actionDeselectWindow, SIGNAL(activated()), actionHandler, SLOT(slotDeselectWindow()));
596 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectWindow, SLOT(setEnabled(bool)));
597 // action = actionFactory.createAction(RS2::ActionSelectWindow, actionHandler);
598 menu->addAction(actionSelectWindow);
599 connect(actionSelectWindow, SIGNAL(activated()), actionHandler, SLOT(slotSelectWindow()));
600 connect(this, SIGNAL(windowsChanged(bool)), actionSelectWindow, SLOT(setEnabled(bool)));
601 // action = actionFactory.createAction(RS2::ActionSelectInvert, actionHandler);
602 menu->addAction(actionSelectInvert);
603 connect(actionSelectInvert, SIGNAL(activated()), actionHandler, SLOT(slotSelectInvert()));
604 connect(this, SIGNAL(windowsChanged(bool)), actionSelectInvert, SLOT(setEnabled(bool)));
605 // action = actionFactory.createAction(RS2::ActionSelectIntersected, actionHandler);
606 menu->addAction(actionSelectIntersected);
607 connect(actionSelectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotSelectIntersected()));
608 connect(this, SIGNAL(windowsChanged(bool)), actionSelectIntersected, SLOT(setEnabled(bool)));
609 // action = actionFactory.createAction(RS2::ActionDeselectIntersected, actionHandler);
610 menu->addAction(actionDeselectIntersected);
611 connect(actionDeselectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotDeselectIntersected()));
612 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectIntersected, SLOT(setEnabled(bool)));
613 // action = actionFactory.createAction(RS2::ActionSelectLayer, actionHandler);
614 menu->addAction(actionSelectLayer);
615 connect(actionSelectLayer, SIGNAL(activated()), actionHandler, SLOT(slotSelectLayer()));
616 connect(this, SIGNAL(windowsChanged(bool)), actionSelectLayer, SLOT(setEnabled(bool)));
617 menuBar()->addMenu(menu);
621 menu = new QMenu(tr("&Draw"), this);
624 QMenu * subMenu = new QMenu(tr("&Point"), this);
625 // action = actionFactory.createAction(RS2::ActionDrawPoint, actionHandler);
626 subMenu->addAction(actionDrawPoint);
627 connect(actionDrawPoint, SIGNAL(activated()), actionHandler, SLOT(slotDrawPoint()));
628 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPoint, SLOT(setEnabled(bool)));
629 menu->addMenu(subMenu);
632 subMenu = new QMenu(tr("&Line"), this);
633 // action = actionFactory.createAction(RS2::ActionDrawLine, actionHandler);
634 subMenu->addAction(actionDrawLine);
635 connect(actionDrawLine, SIGNAL(activated()), actionHandler, SLOT(slotDrawLine()));
636 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLine, SLOT(setEnabled(bool)));
637 // action = actionFactory.createAction(RS2::ActionDrawLineAngle, actionHandler);
638 subMenu->addAction(actionDrawLineAngle);
639 connect(actionDrawLineAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineAngle()));
640 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineAngle, SLOT(setEnabled(bool)));
641 // action = actionFactory.createAction(RS2::ActionDrawLineHorizontal, actionHandler);
642 subMenu->addAction(actionDrawLineHorizontal);
643 connect(actionDrawLineHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineHorizontal()));
644 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineHorizontal, SLOT(setEnabled(bool)));
645 // action = actionFactory.createAction(RS2::ActionDrawLineVertical, actionHandler);
646 subMenu->addAction(actionDrawLineVertical);
647 connect(actionDrawLineVertical, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineVertical()));
648 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineVertical, SLOT(setEnabled(bool)));
649 // action = actionFactory.createAction(RS2::ActionDrawLineRectangle, actionHandler);
650 subMenu->addAction(actionDrawLineRectangle);
651 connect(actionDrawLineRectangle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRectangle()));
652 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRectangle, SLOT(setEnabled(bool)));
653 // action = actionFactory.createAction(RS2::ActionDrawLineParallel, actionHandler);
654 subMenu->addAction(actionDrawLineParallel);
655 connect(actionDrawLineParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallel()));
656 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallel, SLOT(setEnabled(bool)));
657 // action = actionFactory.createAction(RS2::ActionDrawLineParallelThrough, actionHandler);
658 subMenu->addAction(actionDrawLineParallelThrough);
659 connect(actionDrawLineParallelThrough, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallelThrough()));
660 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallelThrough, SLOT(setEnabled(bool)));
661 // action = actionFactory.createAction(RS2::ActionDrawLineBisector, actionHandler);
662 subMenu->addAction(actionDrawLineBisector);
663 connect(actionDrawLineBisector, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineBisector()));
664 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineBisector, SLOT(setEnabled(bool)));
665 // action = actionFactory.createAction(RS2::ActionDrawLineTangent1, actionHandler);
666 subMenu->addAction(actionDrawLineTangent1);
667 connect(actionDrawLineTangent1, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent1()));
668 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent1, SLOT(setEnabled(bool)));
669 // action = actionFactory.createAction(RS2::ActionDrawLineTangent2, actionHandler);
670 subMenu->addAction(actionDrawLineTangent2);
671 connect(actionDrawLineTangent2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent2()));
672 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent2, SLOT(setEnabled(bool)));
673 // action = actionFactory.createAction(RS2::ActionDrawLineOrthogonal, actionHandler);
674 subMenu->addAction(actionDrawLineOrthogonal);
675 connect(actionDrawLineOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineOrthogonal()));
676 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineOrthogonal, SLOT(setEnabled(bool)));
677 // action = actionFactory.createAction(RS2::ActionDrawLineRelAngle, actionHandler);
678 subMenu->addAction(actionDrawLineRelAngle);
679 connect(actionDrawLineRelAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRelAngle()));
680 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRelAngle, SLOT(setEnabled(bool)));
681 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon, actionHandler);
682 subMenu->addAction(actionDrawLinePolygon);
683 connect(actionDrawLinePolygon, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon()));
684 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon, SLOT(setEnabled(bool)));
685 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon2, actionHandler);
686 subMenu->addAction(actionDrawLinePolygon2);
687 connect(actionDrawLinePolygon2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon2()));
688 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon2, SLOT(setEnabled(bool)));
689 // action = actionFactory.createAction(RS2::ActionDrawLineFree, actionHandler);
690 subMenu->addAction(actionDrawLineFree);
691 connect(actionDrawLineFree, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineFree()));
692 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineFree, SLOT(setEnabled(bool)));
693 menu->addMenu(subMenu);
696 subMenu = new QMenu(tr("&Arc"), this);
697 subMenu->addAction(actionDrawArc);
698 connect(actionDrawArc, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc()));
699 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc, SLOT(setEnabled(bool)));
700 subMenu->addAction(actionDrawArc3P);
701 connect(actionDrawArc3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc3P()));
702 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc3P, SLOT(setEnabled(bool)));
703 subMenu->addAction(actionDrawArcParallel);
704 connect(actionDrawArcParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcParallel()));
705 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcParallel, SLOT(setEnabled(bool)));
706 subMenu->addAction(actionDrawArcTangential);
707 connect(actionDrawArcTangential, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcTangential()));
708 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcTangential, SLOT(setEnabled(bool)));
709 menu->addMenu(subMenu);
712 subMenu = new QMenu(tr("&Circle"), this);
713 // action = actionFactory.createAction(RS2::ActionDrawCircle, actionHandler);
714 subMenu->addAction(actionDrawCircle);
715 connect(actionDrawCircle, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle()));
716 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle, SLOT(setEnabled(bool)));
717 // action = actionFactory.createAction(RS2::ActionDrawCircleCR, actionHandler);
718 subMenu->addAction(actionDrawCircleCR);
719 connect(actionDrawCircleCR, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleCR()));
720 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleCR, SLOT(setEnabled(bool)));
721 // action = actionFactory.createAction(RS2::ActionDrawCircle2P, actionHandler);
722 subMenu->addAction(actionDrawCircle2P);
723 connect(actionDrawCircle2P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle2P()));
724 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle2P, SLOT(setEnabled(bool)));
725 // action = actionFactory.createAction(RS2::ActionDrawCircle3P, actionHandler);
726 subMenu->addAction(actionDrawCircle3P);
727 connect(actionDrawCircle3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle3P()));
728 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle3P, SLOT(setEnabled(bool)));
729 // action = actionFactory.createAction(RS2::ActionDrawCircleParallel, actionHandler);
730 subMenu->addAction(actionDrawCircleParallel);
731 connect(actionDrawCircleParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleParallel()));
732 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleParallel, SLOT(setEnabled(bool)));
733 menu->addMenu(subMenu);
736 subMenu = new QMenu(tr("&Ellipse"), this);
737 // action = actionFactory.createAction(RS2::ActionDrawEllipseAxis, actionHandler);
738 subMenu->addAction(actionDrawEllipseAxis);
739 connect(actionDrawEllipseAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseAxis()));
740 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseAxis, SLOT(setEnabled(bool)));
741 // action = actionFactory.createAction(RS2::ActionDrawEllipseArcAxis, actionHandler);
742 subMenu->addAction(actionDrawEllipseArcAxis);
743 connect(actionDrawEllipseArcAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseArcAxis()));
744 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseArcAxis, SLOT(setEnabled(bool)));
745 menu->addMenu(subMenu);
748 subMenu = new QMenu(tr("&Spline"), this);
749 // action = actionFactory.createAction(RS2::ActionDrawSpline, actionHandler);
750 subMenu->addAction(actionDrawSpline);
751 connect(actionDrawSpline, SIGNAL(activated()), actionHandler, SLOT(slotDrawSpline()));
752 connect(this, SIGNAL(windowsChanged(bool)), actionDrawSpline, SLOT(setEnabled(bool)));
753 menu->addMenu(subMenu);
756 subMenu = new QMenu(tr("&Polyline"), this);
757 // action = actionFactory.createAction(RS2::ActionDrawPolyline, actionHandler);
758 subMenu->addAction(actionDrawPolyline);
759 connect(actionDrawPolyline, SIGNAL(activated()), actionHandler, SLOT(slotDrawPolyline()));
760 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPolyline, SLOT(setEnabled(bool)));
761 // action = actionFactory.createAction(RS2::ActionPolylineAdd, actionHandler);
762 subMenu->addAction(actionPolylineAdd);
763 connect(actionPolylineAdd, SIGNAL(activated()), actionHandler, SLOT(slotPolylineAdd()));
764 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineAdd, SLOT(setEnabled(bool)));
765 // action = actionFactory.createAction(RS2::ActionPolylineDel, actionHandler);
766 subMenu->addAction(actionPolylineDel);
767 connect(actionPolylineDel, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDel()));
768 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDel, SLOT(setEnabled(bool)));
769 // action = actionFactory.createAction(RS2::ActionPolylineDelBetween, actionHandler);
770 subMenu->addAction(actionPolylineDelBetween);
771 connect(actionPolylineDelBetween, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDelBetween()));
772 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDelBetween, SLOT(setEnabled(bool)));
773 // action = actionFactory.createAction(RS2::ActionPolylineTrim, actionHandler);
774 subMenu->addAction(actionPolylineTrim);
775 connect(actionPolylineTrim, SIGNAL(activated()), actionHandler, SLOT(slotPolylineTrim()));
776 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineTrim, SLOT(setEnabled(bool)));
777 menu->addMenu(subMenu);
780 // action = actionFactory.createAction(RS2::ActionDrawText, actionHandler);
781 menu->addAction(actionDrawText);
782 connect(actionDrawText, SIGNAL(activated()), actionHandler, SLOT(slotDrawText()));
783 connect(this, SIGNAL(windowsChanged(bool)), actionDrawText, SLOT(setEnabled(bool)));
785 // action = actionFactory.createAction(RS2::ActionDrawHatch, actionHandler);
786 menu->addAction(actionDrawHatch);
787 connect(actionDrawHatch, SIGNAL(activated()), actionHandler, SLOT(slotDrawHatch()));
788 connect(this, SIGNAL(windowsChanged(bool)), actionDrawHatch, SLOT(setEnabled(bool)));
790 // action = actionFactory.createAction(RS2::ActionDrawImage, actionHandler);
791 menu->addAction(actionDrawImage);
792 connect(actionDrawImage, SIGNAL(activated()), actionHandler, SLOT(slotDrawImage()));
793 connect(this, SIGNAL(windowsChanged(bool)), actionDrawImage, SLOT(setEnabled(bool)));
794 // menuBar()->insertItem(tr("&Draw"), menu);
795 menuBar()->addMenu(menu);
797 // Dimensioning actions:
803 menu = new QMenu(tr("&Dimension"), this);
804 // action = actionFactory.createAction(RS2::ActionDimAligned, actionHandler);
805 menu->addAction(actionDimAligned);
806 connect(actionDimAligned, SIGNAL(activated()), actionHandler, SLOT(slotDimAligned()));
807 connect(this, SIGNAL(windowsChanged(bool)), actionDimAligned, SLOT(setEnabled(bool)));
808 // action = actionFactory.createAction(RS2::ActionDimLinear, actionHandler);
809 menu->addAction(actionDimLinear);
810 connect(actionDimLinear, SIGNAL(activated()), actionHandler, SLOT(slotDimLinear()));
811 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinear, SLOT(setEnabled(bool)));
812 // action = actionFactory.createAction(RS2::ActionDimLinearHor, actionHandler);
813 menu->addAction(actionDimLinearHor);
814 connect(actionDimLinearHor, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearHor()));
815 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearHor, SLOT(setEnabled(bool)));
816 // action = actionFactory.createAction(RS2::ActionDimLinearVer, actionHandler);
817 menu->addAction(actionDimLinearVer);
818 connect(actionDimLinearVer, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearVer()));
819 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearVer, SLOT(setEnabled(bool)));
820 // action = actionFactory.createAction(RS2::ActionDimRadial, actionHandler);
821 menu->addAction(actionDimRadial);
822 connect(actionDimRadial, SIGNAL(activated()), actionHandler, SLOT(slotDimRadial()));
823 connect(this, SIGNAL(windowsChanged(bool)), actionDimRadial, SLOT(setEnabled(bool)));
824 // action = actionFactory.createAction(RS2::ActionDimDiametric, actionHandler);
825 menu->addAction(actionDimDiametric);
826 connect(actionDimDiametric, SIGNAL(activated()), actionHandler, SLOT(slotDimDiametric()));
827 connect(this, SIGNAL(windowsChanged(bool)), actionDimDiametric, SLOT(setEnabled(bool)));
828 // action = actionFactory.createAction(RS2::ActionDimAngular, actionHandler);
829 menu->addAction(actionDimAngular);
830 connect(actionDimAngular, SIGNAL(activated()), actionHandler, SLOT(slotDimAngular()));
831 connect(this, SIGNAL(windowsChanged(bool)), actionDimAngular, SLOT(setEnabled(bool)));
832 // action = actionFactory.createAction(RS2::ActionDimLeader, actionHandler);
833 menu->addAction(actionDimLeader);
834 connect(actionDimLeader, SIGNAL(activated()), actionHandler, SLOT(slotDimLeader()));
835 connect(this, SIGNAL(windowsChanged(bool)), actionDimLeader, SLOT(setEnabled(bool)));
837 m->insertItem(tr("&Dimension"), menu);
839 menuBar()->addMenu(menu);
842 // Modifying actions:
844 menu = new QMenu(tr("&Modify"), this);
845 // action = actionFactory.createAction(RS2::ActionModifyMove, actionHandler);
846 menu->addAction(actionModifyMove);
847 connect(actionModifyMove, SIGNAL(activated()), actionHandler, SLOT(slotModifyMove()));
848 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMove, SLOT(setEnabled(bool)));
849 // action = actionFactory.createAction(RS2::ActionModifyRotate, actionHandler);
850 menu->addAction(actionModifyRotate);
851 connect(actionModifyRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate()));
852 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate, SLOT(setEnabled(bool)));
853 // action = actionFactory.createAction(RS2::ActionModifyScale, actionHandler);
854 menu->addAction(actionModifyScale);
855 connect(actionModifyScale, SIGNAL(activated()), actionHandler, SLOT(slotModifyScale()));
856 connect(this, SIGNAL(windowsChanged(bool)), actionModifyScale, SLOT(setEnabled(bool)));
857 // action = actionFactory.createAction(RS2::ActionModifyMirror, actionHandler);
858 menu->addAction(actionModifyMirror);
859 connect(actionModifyMirror, SIGNAL(activated()), actionHandler, SLOT(slotModifyMirror()));
860 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMirror, SLOT(setEnabled(bool)));
861 // action = actionFactory.createAction(RS2::ActionModifyMoveRotate, actionHandler);
862 menu->addAction(actionModifyMoveRotate);
863 connect(actionModifyMoveRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyMoveRotate()));
864 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMoveRotate, SLOT(setEnabled(bool)));
865 // action = actionFactory.createAction(RS2::ActionModifyRotate2, actionHandler);
866 menu->addAction(actionModifyRotate2);
867 connect(actionModifyRotate2, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate2()));
868 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate2, SLOT(setEnabled(bool)));
869 // action = actionFactory.createAction(RS2::ActionModifyTrim, actionHandler);
870 menu->addAction(actionModifyTrim);
871 connect(actionModifyTrim, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim()));
872 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim, SLOT(setEnabled(bool)));
873 // action = actionFactory.createAction(RS2::ActionModifyTrim2, actionHandler);
874 menu->addAction(actionModifyTrim2);
875 connect(actionModifyTrim2, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim2()));
876 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim2, SLOT(setEnabled(bool)));
877 // action = actionFactory.createAction(RS2::ActionModifyTrimAmount, actionHandler);
878 menu->addAction(actionModifyTrimAmount);
879 connect(actionModifyTrimAmount, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrimAmount()));
880 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrimAmount, SLOT(setEnabled(bool)));
881 // action = actionFactory.createAction(RS2::ActionModifyBevel, actionHandler);
882 menu->addAction(actionModifyBevel);
883 connect(actionModifyBevel, SIGNAL(activated()), actionHandler, SLOT(slotModifyBevel()));
884 connect(this, SIGNAL(windowsChanged(bool)), actionModifyBevel, SLOT(setEnabled(bool)));
885 // action = actionFactory.createAction(RS2::ActionModifyRound, actionHandler);
886 menu->addAction(actionModifyRound);
887 connect(actionModifyRound, SIGNAL(activated()), actionHandler, SLOT(slotModifyRound()));
888 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRound, SLOT(setEnabled(bool)));
889 // action = actionFactory.createAction(RS2::ActionModifyCut, actionHandler);
890 menu->addAction(actionModifyCut);
891 connect(actionModifyCut, SIGNAL(activated()), actionHandler, SLOT(slotModifyCut()));
892 connect(this, SIGNAL(windowsChanged(bool)), actionModifyCut, SLOT(setEnabled(bool)));
893 // action = actionFactory.createAction(RS2::ActionModifyStretch, actionHandler);
894 menu->addAction(actionModifyStretch);
895 connect(actionModifyStretch, SIGNAL(activated()), actionHandler, SLOT(slotModifyStretch()));
896 connect(this, SIGNAL(windowsChanged(bool)), actionModifyStretch, SLOT(setEnabled(bool)));
897 // action = actionFactory.createAction(RS2::ActionModifyEntity, actionHandler);
898 menu->addAction(actionModifyEntity);
899 connect(actionModifyEntity, SIGNAL(activated()), actionHandler, SLOT(slotModifyEntity()));
900 connect(this, SIGNAL(windowsChanged(bool)), actionModifyEntity, SLOT(setEnabled(bool)));
901 // action = actionFactory.createAction(RS2::ActionModifyAttributes, actionHandler);
902 menu->addAction(actionModifyAttributes);
903 connect(actionModifyAttributes, SIGNAL(activated()), actionHandler, SLOT(slotModifyAttributes()));
904 connect(this, SIGNAL(windowsChanged(bool)), actionModifyAttributes, SLOT(setEnabled(bool)));
905 // action = actionFactory.createAction(RS2::ActionModifyDelete, actionHandler);
906 menu->addAction(actionModifyDelete);
907 connect(actionModifyDelete, SIGNAL(activated()), actionHandler, SLOT(slotModifyDelete()));
908 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDelete, SLOT(setEnabled(bool)));
909 // action = actionFactory.createAction(RS2::ActionModifyDeleteQuick, actionHandler);
910 menu->addAction(actionModifyDeleteQuick);
911 connect(actionModifyDeleteQuick, SIGNAL(activated()), actionHandler, SLOT(slotModifyDeleteQuick()));
912 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDeleteQuick, SLOT(setEnabled(bool)));
913 // action = actionFactory.createAction(RS2::ActionModifyExplodeText, actionHandler);
914 menu->addAction(actionModifyExplodeText);
915 connect(actionModifyExplodeText, SIGNAL(activated()), actionHandler, SLOT(slotModifyExplodeText()));
916 connect(this, SIGNAL(windowsChanged(bool)), actionModifyExplodeText, SLOT(setEnabled(bool)));
917 //// action = actionFactory.createAction(RS2::ActionModifyDeleteFree, actionHandler);
918 //// menu->addAction(action);
919 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
920 menu->addAction(actionBlocksExplode);
921 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
922 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
923 menuBar()->addMenu(menu);
927 menu = new QMenu(tr("&Snap"), this);
928 // action = actionFactory.createAction(RS2::ActionSnapFree, actionHandler);
929 menu->addAction(actionSnapFree);
930 actionHandler->setActionSnapFree(actionSnapFree); // ???Why???
931 connect(actionSnapFree, SIGNAL(activated()), actionHandler, SLOT(slotSnapFree()));
932 connect(this, SIGNAL(windowsChanged(bool)), actionSnapFree, SLOT(setEnabled(bool)));
933 actionSnapFree->setChecked(true);
934 // action = actionFactory.createAction(RS2::ActionSnapGrid, actionHandler);
935 menu->addAction(actionSnapGrid);
936 actionHandler->setActionSnapGrid(actionSnapGrid); // ???Why???
937 connect(actionSnapGrid, SIGNAL(activated()), actionHandler, SLOT(slotSnapGrid()));
938 connect(this, SIGNAL(windowsChanged(bool)), actionSnapGrid, SLOT(setEnabled(bool)));
939 // action = actionFactory.createAction(RS2::ActionSnapEndpoint, actionHandler);
940 menu->addAction(actionSnapEndpoint);
941 actionHandler->setActionSnapEndpoint(actionSnapEndpoint); // ???Why???
942 connect(actionSnapEndpoint, SIGNAL(activated()), actionHandler, SLOT(slotSnapEndpoint()));
943 connect(this, SIGNAL(windowsChanged(bool)), actionSnapEndpoint, SLOT(setEnabled(bool)));
944 // action = actionFactory.createAction(RS2::ActionSnapOnEntity, actionHandler);
945 menu->addAction(actionSnapOnEntity);
946 actionHandler->setActionSnapOnEntity(actionSnapOnEntity); // ???Why???
947 connect(actionSnapOnEntity, SIGNAL(activated()), actionHandler, SLOT(slotSnapOnEntity()));
948 connect(this, SIGNAL(windowsChanged(bool)), actionSnapOnEntity, SLOT(setEnabled(bool)));
949 // action = actionFactory.createAction(RS2::ActionSnapCenter, actionHandler);
950 menu->addAction(actionSnapCenter);
951 actionHandler->setActionSnapCenter(actionSnapCenter); // ???Why???
952 connect(actionSnapCenter, SIGNAL(activated()), actionHandler, SLOT(slotSnapCenter()));
953 connect(this, SIGNAL(windowsChanged(bool)), actionSnapCenter, SLOT(setEnabled(bool)));
954 // action = actionFactory.createAction(RS2::ActionSnapMiddle, actionHandler);
955 menu->addAction(actionSnapMiddle);
956 actionHandler->setActionSnapMiddle(actionSnapMiddle); // ???Why???
957 connect(actionSnapMiddle, SIGNAL(activated()), actionHandler, SLOT(slotSnapMiddle()));
958 connect(this, SIGNAL(windowsChanged(bool)), actionSnapMiddle, SLOT(setEnabled(bool)));
959 // action = actionFactory.createAction(RS2::ActionSnapDist, actionHandler);
960 menu->addAction(actionSnapDist);
961 actionHandler->setActionSnapDist(actionSnapDist); // ???Why???
962 connect(actionSnapDist, SIGNAL(activated()), actionHandler, SLOT(slotSnapDist()));
963 connect(this, SIGNAL(windowsChanged(bool)), actionSnapDist, SLOT(setEnabled(bool)));
964 // action = actionFactory.createAction(RS2::ActionSnapIntersection, actionHandler);
965 menu->addAction(actionSnapIntersection);
966 actionHandler->setActionSnapIntersection(actionSnapIntersection); // ???Why???
967 connect(actionSnapIntersection, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersection()));
968 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersection, SLOT(setEnabled(bool)));
969 // action = actionFactory.createAction(RS2::ActionSnapIntersectionManual, actionHandler);
970 menu->addAction(actionSnapIntersectionManual);
971 actionHandler->setActionSnapIntersectionManual(actionSnapIntersectionManual); // ???Why???
972 connect(actionSnapIntersectionManual, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersectionManual()));
973 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersectionManual, SLOT(setEnabled(bool)));
975 menu->addSeparator();
977 // action = actionFactory.createAction(RS2::ActionRestrictNothing, actionHandler);
978 menu->addAction(actionRestrictNothing);
979 actionHandler->setActionRestrictNothing(actionRestrictNothing); // ???WHY???
980 connect(actionRestrictNothing, SIGNAL(activated()), actionHandler, SLOT(slotRestrictNothing()));
981 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictNothing, SLOT(setEnabled(bool)));
982 actionRestrictNothing->setChecked(true);
983 // action = actionFactory.createAction(RS2::ActionRestrictOrthogonal, actionHandler);
984 menu->addAction(actionRestrictOrthogonal);
985 actionHandler->setActionRestrictOrthogonal(actionRestrictOrthogonal); // ???WHY???
986 connect(actionRestrictOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictOrthogonal()));
987 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictOrthogonal, SLOT(setEnabled(bool)));
988 // action = actionFactory.createAction(RS2::ActionRestrictHorizontal, actionHandler);
989 menu->addAction(actionRestrictHorizontal);
990 actionHandler->setActionRestrictHorizontal(actionRestrictHorizontal); // ???WHY???
991 connect(actionRestrictHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictHorizontal()));
992 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictHorizontal, SLOT(setEnabled(bool)));
993 // action = actionFactory.createAction(RS2::ActionRestrictVertical, actionHandler);
994 menu->addAction(actionRestrictVertical);
995 actionHandler->setActionRestrictVertical(actionRestrictVertical); // ???WHY???
996 connect(actionRestrictVertical, SIGNAL(activated()), actionHandler, SLOT(slotRestrictVertical()));
997 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictVertical, SLOT(setEnabled(bool)));
999 menu->addSeparator();
1001 // action = actionFactory.createAction(RS2::ActionSetRelativeZero, actionHandler);
1002 menu->addAction(actionSetRelativeZero);
1003 connect(actionSetRelativeZero, SIGNAL(activated()), actionHandler, SLOT(slotSetRelativeZero()));
1004 connect(this, SIGNAL(windowsChanged(bool)), actionSetRelativeZero, SLOT(setEnabled(bool)));
1005 // action = actionFactory.createAction(RS2::ActionLockRelativeZero, actionHandler);
1006 menu->addAction(actionLockRelativeZero);
1007 actionHandler->setActionLockRelativeZero(actionLockRelativeZero);
1008 connect(actionLockRelativeZero, SIGNAL(toggled(bool)), actionHandler, SLOT(slotLockRelativeZero(bool))); // ???WHY???
1009 connect(this, SIGNAL(windowsChanged(bool)), actionLockRelativeZero, SLOT(setEnabled(bool)));
1010 menuBar()->addMenu(menu);
1015 menu = new QMenu(tr("&Info"), this);
1016 //action = actionFactory.createAction(RS2::ActionInfoInside, actionHandler);
1017 //menu->addAction(action);
1018 menu->addAction(actionInfoDist);
1019 connect(actionInfoDist, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist()));
1020 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist, SLOT(setEnabled(bool)));
1021 menu->addAction(actionInfoDist2);
1022 connect(actionInfoDist2, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist2()));
1023 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist2, SLOT(setEnabled(bool)));
1024 menu->addAction(actionInfoAngle);
1025 connect(actionInfoAngle, SIGNAL(activated()), actionHandler, SLOT(slotInfoAngle()));
1026 connect(this, SIGNAL(windowsChanged(bool)), actionInfoAngle, SLOT(setEnabled(bool)));
1027 menu->addAction(actionInfoTotalLength);
1028 connect(actionInfoTotalLength, SIGNAL(activated()), actionHandler, SLOT(slotInfoTotalLength()));
1029 connect(this, SIGNAL(windowsChanged(bool)), actionInfoTotalLength, SLOT(setEnabled(bool)));
1030 menu->addAction(actionInfoArea);
1031 connect(actionInfoArea, SIGNAL(activated()), actionHandler, SLOT(slotInfoArea()));
1032 connect(this, SIGNAL(windowsChanged(bool)), actionInfoArea, SLOT(setEnabled(bool)));
1033 menuBar()->addMenu(menu);
1038 menu = new QMenu(tr("&Layer"), this);
1039 // action = actionFactory.createAction(RS2::ActionLayersDefreezeAll, actionHandler);
1040 menu->addAction(actionLayersDefreezeAll);
1041 connect(actionLayersDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersDefreezeAll()));
1042 connect(this, SIGNAL(windowsChanged(bool)), actionLayersDefreezeAll, SLOT(setEnabled(bool)));
1043 // action = actionFactory.createAction(RS2::ActionLayersFreezeAll, actionHandler);
1044 menu->addAction(actionLayersFreezeAll);
1045 connect(actionLayersFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersFreezeAll()));
1046 connect(this, SIGNAL(windowsChanged(bool)), actionLayersFreezeAll, SLOT(setEnabled(bool)));
1047 // action = actionFactory.createAction(RS2::ActionLayersAdd, actionHandler);
1048 menu->addAction(actionLayersAdd);
1049 connect(actionLayersAdd, SIGNAL(activated()), actionHandler, SLOT(slotLayersAdd()));
1050 connect(this, SIGNAL(windowsChanged(bool)), actionLayersAdd, SLOT(setEnabled(bool)));
1051 // action = actionFactory.createAction(RS2::ActionLayersRemove, actionHandler);
1052 menu->addAction(actionLayersRemove);
1053 connect(actionLayersRemove, SIGNAL(activated()), actionHandler, SLOT(slotLayersRemove()));
1054 connect(this, SIGNAL(windowsChanged(bool)), actionLayersRemove, SLOT(setEnabled(bool)));
1055 // action = actionFactory.createAction(RS2::ActionLayersEdit, actionHandler);
1056 menu->addAction(actionLayersEdit);
1057 connect(actionLayersEdit, SIGNAL(activated()), actionHandler, SLOT(slotLayersEdit()));
1058 connect(this, SIGNAL(windowsChanged(bool)), actionLayersEdit, SLOT(setEnabled(bool)));
1059 // action = actionFactory.createAction(RS2::ActionLayersToggleView, actionHandler);
1060 menu->addAction(actionLayersToggleView);
1061 connect(actionLayersToggleView, SIGNAL(activated()), actionHandler, SLOT(slotLayersToggleView()));
1062 connect(this, SIGNAL(windowsChanged(bool)), actionLayersToggleView, SLOT(setEnabled(bool)));
1063 menuBar()->addMenu(menu);
1067 menu = new QMenu(tr("&Block"), this);
1068 // action = actionFactory.createAction(RS2::ActionBlocksDefreezeAll, actionHandler);
1069 menu->addAction(actionBlocksDefreezeAll);
1070 connect(actionBlocksDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksDefreezeAll()));
1071 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksDefreezeAll, SLOT(setEnabled(bool)));
1072 // action = actionFactory.createAction(RS2::ActionBlocksFreezeAll, actionHandler);
1073 menu->addAction(actionBlocksFreezeAll);
1074 connect(actionBlocksFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksFreezeAll()));
1075 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksFreezeAll, SLOT(setEnabled(bool)));
1076 // action = actionFactory.createAction(RS2::ActionBlocksAdd, actionHandler);
1077 menu->addAction(actionBlocksAdd);
1078 connect(actionBlocksAdd, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAdd()));
1079 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAdd, SLOT(setEnabled(bool)));
1080 // action = actionFactory.createAction(RS2::ActionBlocksRemove, actionHandler);
1081 menu->addAction(actionBlocksRemove);
1082 connect(actionBlocksRemove, SIGNAL(activated()), actionHandler, SLOT(slotBlocksRemove()));
1083 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksRemove, SLOT(setEnabled(bool)));
1084 // action = actionFactory.createAction(RS2::ActionBlocksAttributes, actionHandler);
1085 menu->addAction(actionBlocksAttributes);
1086 connect(actionBlocksAttributes, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAttributes()));
1087 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAttributes, SLOT(setEnabled(bool)));
1088 // action = actionFactory.createAction(RS2::ActionBlocksInsert, actionHandler);
1089 menu->addAction(actionBlocksInsert);
1090 connect(actionBlocksInsert, SIGNAL(activated()), actionHandler, SLOT(slotBlocksInsert()));
1091 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksInsert, SLOT(setEnabled(bool)));
1092 // action = actionFactory.createAction(RS2::ActionBlocksEdit, actionHandler);
1093 menu->addAction(actionBlocksEdit);
1094 connect(actionBlocksEdit, SIGNAL(activated()), actionHandler, SLOT(slotBlocksEdit()));
1095 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksEdit, SLOT(setEnabled(bool)));
1096 // action = actionFactory.createAction(RS2::ActionBlocksCreate, actionHandler);
1097 menu->addAction(actionBlocksCreate);
1098 connect(actionBlocksCreate, SIGNAL(activated()), actionHandler, SLOT(slotBlocksCreate()));
1099 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksCreate, SLOT(setEnabled(bool)));
1100 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
1101 menu->addAction(actionBlocksExplode);
1102 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
1103 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
1104 menuBar()->addMenu(menu);
1106 //will *this* make a toolbar break for us???
1107 addToolBarBreak(Qt::TopToolBarArea);
1108 // addDockWindow(penToolBar, tr("Pen"), Qt::DockTop);
1109 // addDockWindow(optionWidget, tr("Tool Options"), Qt::DockTop, true);
1110 addToolBar(Qt::TopToolBarArea, (QToolBar *)penToolBar); // hmm.
1111 addToolBar(Qt::TopToolBarArea, optionWidget);
1116 scriptMenu = new QMenu(this);
1117 scriptOpenIDE = actionFactory.createAction(RS2::ActionScriptOpenIDE, this);
1118 scriptOpenIDE->addTo(scriptMenu);
1119 scriptRun = actionFactory.createAction(RS2::ActionScriptRun, this);
1120 scriptRun->addTo(scriptMenu);
1123 scriptOpenIDE = NULL;
1129 menu = new QMenu(tr("&CAM"), this);
1130 action = actionFactory.createAction(RS2::ActionCamExportAuto, actionHandler);
1131 menu->addAction(action);
1132 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1133 action = actionFactory.createAction(RS2::ActionCamReorder, actionHandler);
1134 menu->addAction(action);
1135 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1136 menuBar()->addMenu(menu);
1141 helpAboutApp = new QAction(QIcon(QC_APP_ICON16), tr("&About Architektonas"), this);
1142 // helpAboutApp = new QAction(tr("About"), qPixmapFromMimeSource(QC_APP_ICON16), tr("&About %1").arg(QC_APPNAME), 0, this);
1143 helpAboutApp->setStatusTip(tr("About the application"));
1144 //helpAboutApp->setWhatsThis(tr("About\n\nAbout the application"));
1145 connect(helpAboutApp, SIGNAL(activated()), this, SLOT(slotHelpAbout()));
1147 helpManual = new QAction(QIcon(":/res/contents.png"), tr("&Manual"), this);
1148 helpManual->setShortcut(Qt::Key_F1);
1149 // helpManual = new QAction(qPixmapFromMimeSource("contents.png"), tr("&Manual"), Qt::Key_F1, this);
1150 helpManual->setStatusTip(tr("Launch the online manual"));
1151 connect(helpManual, SIGNAL(activated()), this, SLOT(slotHelpManual()));
1153 testDumpEntities = new QAction("Dump &Entities", this);
1154 // testDumpEntities = new QAction("Dump Entities", "Dump &Entities", 0, this);
1155 connect(testDumpEntities, SIGNAL(activated()), this, SLOT(slotTestDumpEntities()));
1157 testDumpUndo = new QAction("Undo Info", this);
1158 // testDumpUndo = new QAction("Dump Undo Info", "Undo Info", 0, this);
1159 connect(testDumpUndo, SIGNAL(activated()), this, SLOT(slotTestDumpUndo()));
1161 testUpdateInserts = new QAction("&Update Inserts", this);
1162 // testUpdateInserts = new QAction("Update Inserts", "&Update Inserts", 0, this);
1163 connect(testUpdateInserts, SIGNAL(activated()), this, SLOT(slotTestUpdateInserts()));
1165 testDrawFreehand = new QAction("Draw Freehand", this);
1166 // testDrawFreehand = new QAction("Draw Freehand", "Draw Freehand", 0, this);
1167 connect(testDrawFreehand, SIGNAL(activated()), this, SLOT(slotTestDrawFreehand()));
1169 testInsertBlock = new QAction("Insert Block", this);
1170 // testInsertBlock = new QAction("Insert Block", "Insert Block", 0, this);
1171 connect(testInsertBlock, SIGNAL(activated()), this, SLOT(slotTestInsertBlock()));
1173 testInsertText = new QAction("Insert Text", this);
1174 // testInsertText = new QAction("Insert Text", "Insert Text", 0, this);
1175 connect(testInsertText, SIGNAL(activated()), this, SLOT(slotTestInsertText()));
1177 testInsertImage = new QAction("Insert Image", this);
1178 // testInsertImage = new QAction("Insert Image", "Insert Image", 0, this);
1179 connect(testInsertImage, SIGNAL(activated()), this, SLOT(slotTestInsertImage()));
1181 testUnicode = new QAction("Unicode", this);
1182 // testUnicode = new QAction("Unicode", "Unicode", 0, this);
1183 connect(testUnicode, SIGNAL(activated()), this, SLOT(slotTestUnicode()));
1185 testInsertEllipse = new QAction("Insert Ellipse", this);
1186 // testInsertEllipse = new QAction("Insert Ellipse", "Insert Ellipse", 0, this);
1187 connect(testInsertEllipse, SIGNAL(activated()), this, SLOT(slotTestInsertEllipse()));
1189 testMath01 = new QAction("Math01", this);
1190 // testMath01 = new QAction("Math01", "Math01", 0, this);
1191 connect(testMath01, SIGNAL(activated()), this, SLOT(slotTestMath01()));
1193 testResize640 = new QAction("Resize 1", this);
1194 // testResize640 = new QAction("Resize to 640x480", "Resize 1", 0, this);
1195 connect(testResize640, SIGNAL(activated()), this, SLOT(slotTestResize640()));
1197 testResize800 = new QAction("Resize 2", this);
1198 // testResize800 = new QAction("Resize to 800x600", "Resize 2", 0, this);
1199 connect(testResize800, SIGNAL(activated()), this, SLOT(slotTestResize800()));
1201 testResize1024 = new QAction("Resize 3", this);
1202 // testResize1024 = new QAction("Resize to 1024x768", "Resize 3", 0, this);
1203 connect(testResize1024, SIGNAL(activated()), this, SLOT(slotTestResize1024()));
1207 * Initializes the menu bar.
1209 void ApplicationWindow::initMenuBar()
1211 RS_DEBUG->print("ApplicationWindow::initMenuBar()");
1213 // menuBar entry windowsMenu
1214 windowsMenu = new QMenu(tr("&Window"), this);
1215 //according to docs, this is obsolete: windowsMenu->setCheckable(true);
1216 connect(windowsMenu, SIGNAL(aboutToShow()), this, SLOT(slotWindowsMenuAboutToShow()));
1218 // menuBar entry scriptMenu
1219 //scriptMenu = new QPopupMenu(this);
1220 //scriptMenu->setCheckable(true);
1221 //scriptOpenIDE->addTo(scriptMenu);
1222 //scriptRun->addTo(scriptMenu);
1223 //connect(scriptMenu, SIGNAL(aboutToShow()), this, SLOT(slotScriptMenuAboutToShow()));
1225 // menuBar entry helpMenu
1226 helpMenu = new QMenu(tr("&Help"), this);
1227 helpMenu->addAction(helpManual);//helpManual->addTo(helpMenu);
1229 // helpMenu->insertSeparator(helpManual);
1230 helpMenu->addSeparator();
1232 helpMenu->addAction(helpAboutApp);//helpAboutApp->addTo(helpMenu);
1234 // menuBar entry test menu
1235 testMenu = new QMenu(tr("De&bugging"), this);
1236 testMenu->addAction(testDumpEntities);//testDumpEntities->addTo(testMenu);
1237 testMenu->addAction(testDumpUndo);//testDumpUndo->addTo(testMenu);
1238 testMenu->addAction(testUpdateInserts);//testUpdateInserts->addTo(testMenu);
1239 testMenu->addAction(testDrawFreehand);//testDrawFreehand->addTo(testMenu);
1240 testMenu->addAction(testInsertBlock);//testInsertBlock->addTo(testMenu);
1241 testMenu->addAction(testInsertText);//testInsertText->addTo(testMenu);
1242 testMenu->addAction(testInsertImage);//testInsertImage->addTo(testMenu);
1243 testMenu->addAction(testInsertEllipse);//testInsertEllipse->addTo(testMenu);
1244 testMenu->addAction(testUnicode);//testUnicode->addTo(testMenu);
1245 testMenu->addAction(testMath01);//testMath01->addTo(testMenu);
1246 testMenu->addAction(testResize640);//testResize640->addTo(testMenu);
1247 testMenu->addAction(testResize800);//testResize800->addTo(testMenu);
1248 testMenu->addAction(testResize1024);//testResize1024->addTo(testMenu);
1250 // menuBar configuration
1252 // menuBar()->insertItem(tr("&Scripts"), scriptMenu);
1253 menuBar()->addMenu(scriptMenu);
1255 // menuBar()->insertItem(tr("&Window"), windowsMenu);
1256 menuBar()->addMenu(windowsMenu);
1258 // menuBar()->insertSeparator();
1259 // menuBar()->insertItem(tr("&Help"), helpMenu);
1260 menuBar()->addMenu(helpMenu);
1263 // menuBar()->insertItem(tr("De&bugging"), testMenu);
1264 menuBar()->addMenu(testMenu);
1266 recentFiles = new RecentFiles(this, fileMenu);
1270 * Initializes the tool bars (file tool bar and pen tool bar).
1272 void ApplicationWindow::initToolBar()
1274 RS_DEBUG->print("ApplicationWindow::initToolBar()");
1276 // fileToolBar = new Q3ToolBar(this, "File Operations");
1277 fileToolBar = addToolBar(tr("File Operations"));
1278 fileToolBar->setObjectName("file");
1279 // editToolBar = new Q3ToolBar(this, "Edit Operations");
1280 editToolBar = addToolBar(tr("Edit Operations"));
1281 editToolBar->setObjectName("edit");
1282 // zoomToolBar = new Q3ToolBar(this, "Zoom Operations");
1283 zoomToolBar = addToolBar(tr("Zoom Operations"));
1284 zoomToolBar->setObjectName("zoom");
1285 penToolBar = new QG_PenToolBar(this, "Pen Selection");
1286 penToolBar->setObjectName("pen");
1288 connect(penToolBar, SIGNAL(penChanged(RS_Pen)), this, SLOT(slotPenChanged(RS_Pen)));
1290 // optionWidget = new Q3ToolBar(this, "Tool Options");
1291 //addToolBarBreak() does nothing...
1292 #warning "!!! add/insertToolBarBreak() does nothing !!!"
1293 // addToolBarBreak(Qt::TopToolBarArea);
1294 optionWidget = addToolBar(tr("Tool Options"));
1295 optionWidget->setObjectName("tooloptions");
1296 optionWidget->setMinimumHeight(26);
1297 optionWidget->setMaximumHeight(26);
1298 #warning "!!! No analogue found for setHorizontallyStretchable yet !!!"
1299 //Maybe sizePolicy or somesuch??
1300 optionWidget->setMinimumWidth(150);
1301 optionWidget->setMaximumWidth(800);
1302 #warning "Following line commented out..."
1303 // optionWidget->setFixedExtentHeight(26);
1304 // optionWidget->setHorizontallyStretchable(true);
1305 // addDockWindow(optionWidget, DockTop, true);
1307 // CAD toolbar left:
1308 // Q3ToolBar * t = new Q3ToolBar(this, "CAD Tools");
1309 QToolBar * t = addToolBar(tr("CAD Tools"));
1310 t->setObjectName("cadtools");
1311 #warning "Following two lines commented out..."
1312 // t->setFixedExtentWidth(59);
1313 t->setMinimumWidth(59);
1314 t->setMaximumWidth(59);
1315 // t->setVerticallyStretchable(true);
1316 // addDockWindow(t, Qt::DockLeft, false);
1317 addToolBar(Qt::LeftToolBarArea, t);
1319 cadToolBar = new CadToolBar(t);//, "CAD Tools");
1320 cadToolBar->createSubToolBars(actionHandler);
1322 connect(cadToolBar, SIGNAL(signalBack()), this, SLOT(slotBack()));
1323 connect(this, SIGNAL(windowsChanged(bool)), cadToolBar, SLOT(setEnabled(bool)));
1325 // QG_CadToolBarMain * cadToolBarMain = new QG_CadToolBarMain(cadToolBar);
1326 //No, no break inserted here either...
1327 // insertToolBarBreak(optionWidget);
1331 * Initializes the status bar at the bottom.
1333 void ApplicationWindow::initStatusBar()
1335 RS_DEBUG->print("ApplicationWindow::initStatusBar()");
1337 statusBar()->setMinimumHeight(32);
1338 coordinateWidget = new CoordinateWidget(statusBar());//, "coordinates");
1339 statusBar()->addWidget(coordinateWidget);
1340 mouseWidget = new MouseWidget(statusBar());//, "mouse info");
1341 statusBar()->addWidget(mouseWidget);
1342 selectionWidget = new SelectionWidget(statusBar());//, "selections");
1343 statusBar()->addWidget(selectionWidget);
1347 * Initializes the global application settings from the
1348 * config file (unix, mac) or registry (windows).
1350 void ApplicationWindow::initSettings()
1352 RS_DEBUG->print("ApplicationWindow::initSettings()");
1353 settings.beginGroup("RecentFiles");
1355 for(int i=0; i<recentFiles->Maximum(); ++i)
1357 QString filename = settings.value(QString("File") + QString::number(i + 1)).toString();
1359 if (!filename.isEmpty())
1360 // recentFiles->add(filename);
1361 recentFiles->add(filename);
1364 settings.endGroup();
1366 if (recentFiles->count() > 0)
1367 // updateRecentFilesMenu();
1368 recentFiles->UpdateGUI();
1370 settings.beginGroup("Geometry");
1371 QSize windowSize = settings.value("WindowSize", QSize(950, 700)).toSize();
1372 QPoint windowPos = settings.value("WindowPos", QPoint(0, 30)).toPoint();
1373 restoreState(settings.value("DockWindows").toByteArray());
1374 settings.endGroup();
1377 // if (windowY < 30)
1379 if (windowSize.y() < 30)
1380 windowSize.y() = 30;
1388 * Stores the global application settings to file or registry.
1390 void ApplicationWindow::storeSettings()
1392 RS_DEBUG->print("ApplicationWindow::storeSettings()");
1394 settings.beginGroup("RecentFiles");
1396 for(int i=0; i<recentFiles->count(); ++i)
1397 settings.setValue(QString("File") + QString::number(i + 1), recentFiles->get(i));
1399 settings.endGroup();
1401 settings.beginGroup("Geometry");
1402 settings.setValue("WindowSize", size());
1403 settings.setValue("WindowPos", pos());
1404 settings.setValue("DockWindows", saveState());
1405 settings.endGroup();
1407 RS_DEBUG->print("ApplicationWindow::storeSettings(): OK");
1411 * Initializes the view.
1413 void ApplicationWindow::initView()
1415 RS_DEBUG->print("ApplicationWindow::initView()");
1417 RS_DEBUG->print("init view..");
1421 libraryWidget = NULL;
1422 commandWidget = NULL;
1424 simulationControls = NULL;
1428 RS_DEBUG->print(" simulation widget..");
1429 dw = new QDockWidget(QDockWidget::InDock, this, "Simulation");
1430 simulationControls = new RS_SimulationControls(dw, "Simulation");
1431 simulationControls->setFocusPolicy(Qt::NoFocus);
1432 connect(simulationControls, SIGNAL(escape()), this, SLOT(slotFocus()));
1433 connect(this, SIGNAL(windowsChanged(bool)), simulationControls, SLOT(setEnabled(bool)));
1434 dw->setWidget(simulationControls);
1435 dw->resize(240, 80);
1436 dw->setResizeEnabled(true);
1437 dw->setFixedExtentWidth(120);
1438 dw->setFixedHeight(80);
1439 dw->setCaption(tr("Simulation Controls"));
1440 dw->setCloseMode(Q3DockWindow::Always);
1441 addDockWindow(dw, Qt::DockRight);
1442 simulationDockWindow = dw;
1443 //simulationDockWindow->hide();
1446 RS_DEBUG->print(" layer widget..");
1447 // dw = new QDockWidget(QDockWidget::InDock, this, "Layer");
1448 dw = new QDockWidget(tr("Layer List"), this);
1449 dw->setObjectName("layer");
1450 layerWidget = new QG_LayerWidget(actionHandler, dw, "Layer");
1451 layerWidget->setFocusPolicy(Qt::NoFocus);
1452 connect(layerWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1453 connect(this, SIGNAL(windowsChanged(bool)), layerWidget, SLOT(setEnabled(bool)));
1454 dw->setWidget(layerWidget);
1455 #warning "following four lines commented out..."
1456 // dw->setFixedExtentWidth(120);
1457 // dw->setResizeEnabled(true);
1458 // dw->setCloseMode(Q3DockWindow::Always);
1459 // dw->setCaption(tr("Layer List"));
1460 addDockWidget(Qt::RightDockWidgetArea, dw);
1461 layerDockWindow = dw;
1463 RS_DEBUG->print(" block widget..");
1464 // dw = new QDockWidget(QDockWidget::InDock, this, "Block");
1465 dw = new QDockWidget(tr("Block List"), this);
1466 dw->setObjectName("block");
1467 blockWidget = new QG_BlockWidget(actionHandler, dw, "Block");
1468 blockWidget->setFocusPolicy(Qt::NoFocus);
1469 connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1470 connect(this, SIGNAL(windowsChanged(bool)), blockWidget, SLOT(setEnabled(bool)));
1471 dw->setWidget(blockWidget);
1472 #warning "following four lines commented out..."
1473 // dw->setFixedExtentWidth(120);
1474 // dw->setResizeEnabled(true);
1475 // dw->setCloseMode(Q3DockWindow::Always);
1476 // dw->setCaption(tr("Block List"));
1477 addDockWidget(Qt::RightDockWidgetArea, dw);
1478 blockDockWindow = dw;
1480 RS_DEBUG->print(" library widget..");
1481 // dw = new QDockWidget(QDockWidget::OutsideDock, this, "Library");
1482 dw = new QDockWidget(tr("Library Browser"), this);
1483 dw->setObjectName("library");
1484 libraryWidget = new LibraryWidget(dw);//WAS:, "Library");
1485 libraryWidget->setActionHandler(actionHandler);
1486 libraryWidget->setFocusPolicy(Qt::NoFocus);
1487 connect(libraryWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1489 // connect(this, SIGNAL(windowsChanged(bool)), (QObject *)libraryWidget->bInsert, SLOT(setEnabled(bool)));
1490 dw->setWidget(libraryWidget);
1491 dw->resize(240, 400);
1492 #warning "following three lines commented out..."
1493 // dw->setResizeEnabled(true);
1494 // dw->setCloseMode(Q3DockWindow::Always);
1495 // dw->setCaption(tr("Library Browser"));
1496 //not sure how to fix this one
1497 #warning "QMainWindow::addDockWidget: invalid 'area' argument"
1498 addDockWidget(Qt::NoDockWidgetArea, dw);
1499 libraryDockWindow = dw;
1500 libraryDockWindow->hide();
1502 RS_DEBUG->print(" command widget..");
1503 // dw = new QDockWidget(QDockWidget::InDock, this, "Command");
1504 dw = new QDockWidget(tr("Command line"), this);
1505 dw->setObjectName("command");
1506 commandWidget = new CommandWidget(dw);//WAS:, "Command");
1507 commandWidget->setActionHandler(actionHandler);
1508 // commandWidget->redirectStderr();
1509 // std::cerr << "Ready.\n";
1510 // commandWidget->processStderr();
1511 connect(this, SIGNAL(windowsChanged(bool)), commandWidget, SLOT(setEnabled(bool)));
1512 dw->setWidget(commandWidget);
1513 #warning "following four lines commented out..."
1514 // dw->setFixedExtentHeight(45);
1515 // dw->setResizeEnabled(true);
1516 // dw->setCloseMode(QDockWidget::Always);
1517 // dw->setCaption(tr("Command line"));
1518 commandDockWindow = dw;
1519 addDockWidget(Qt::BottomDockWidgetArea, dw);
1521 RS_DEBUG->print(" done");
1525 * Creates a new toolbar.
1526 * Implementation from QG_MainWindowInterface.
1527 * Can be called from scripts to add individual GUI elements.
1529 /*QToolBar* ApplicationWindow::createToolBar(const QString& name) {
1530 QToolBar* tb = new QToolBar(this, name);
1536 * Creates a new button in the given tool bar for running a script.
1538 /*void ApplicationWindow::addToolBarButton(QToolBar* tb) {
1540 QAction* action = new QAction("Blah",
1541 QPixmap::fromMimeSource("zoomwindow.png"),
1542 "&Blah", QKeySequence(), NULL);
1543 action->setStatusTip("Blah blah");
1549 * Goes back to the previous menu or one step in the current action.
1551 void ApplicationWindow::slotBack()
1553 GraphicView * graphicView = getGraphicView();
1556 graphicView->back();
1560 cadToolBar->showToolBar(RS2::ToolBarMain);
1565 * Goes one step further in the current action.
1567 void ApplicationWindow::slotEnter()
1569 if (!commandWidget || !commandWidget->checkFocus())
1572 cadToolBar->forceNext();
1575 GraphicView * graphicView = getGraphicView();
1578 graphicView->enter();
1584 * Sets the keyboard focus on the command line.
1586 void ApplicationWindow::slotFocusCommandLine()
1588 if (commandWidget->isVisible())
1589 commandWidget->setFocus();
1593 * Shows the given error on the command line.
1595 void ApplicationWindow::slotError(const QString & msg)
1597 commandWidget->appendHistory(msg);
1601 * Hands focus back to the application window. In the rare event
1602 * of a escape press from the layer widget (e.g after switching desktops
1605 void ApplicationWindow::slotFocus()
1607 //QG_GraphicView* graphicView = getGraphicView();
1608 /*if (graphicView!=NULL) {
1609 graphicView->setFocus();
1617 * Called when a document window was activated.
1619 void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/)
1621 RS_DEBUG->print("ApplicationWindow::slotWindowActivated begin");
1623 //the following does: return (MDIWindow *)workspace->activeSubWindow();
1624 //which means the subwindow is NOT being activated!!!
1625 MDIWindow * m = getMDIWindow();
1626 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m=%08X", m);
1628 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m->getDoc=%08X", m->getDocument());
1630 if (m && m->getDocument())
1632 //m->setWindowState(WindowMaximized);
1634 RS_DEBUG->print("ApplicationWindow::slotWindowActivated: document: %d", m->getDocument()->getId());
1636 bool showByBlock = m->getDocument()->rtti() == RS2::EntityBlock;
1637 layerWidget->setLayerList(m->getDocument()->getLayerList(), showByBlock);
1638 coordinateWidget->setGraphic(m->getGraphic());
1641 simulationControls->setGraphicView(m->getGraphicView());
1644 // Only graphics show blocks. (blocks don't)
1645 if (m->getDocument()->rtti() == RS2::EntityGraphic)
1646 blockWidget->setBlockList(m->getDocument()->getBlockList());
1648 blockWidget->setBlockList(NULL);
1650 // Update all inserts in this graphic (blocks might have changed):
1651 m->getDocument()->updateInserts();
1652 m->getGraphicView()->redraw();
1654 // set snapmode from snapping menu
1655 actionHandler->updateSnapMode();
1657 // set pen from pen toolbar
1658 slotPenChanged(penToolBar->getPen());
1660 // update toggle button status:
1661 if (m->getGraphic() != NULL)
1663 emit(gridChanged(m->getGraphic()->isGridOn()));
1664 emit(printPreviewChanged(m->getGraphicView()->isPrintPreview()));
1668 //Seems to work now.
1669 //#warning "This is failing... !!! FIX !!!"
1670 // Disable/Enable menu and toolbar items
1671 emit windowsChanged(m != NULL && m->getDocument() != NULL);
1673 RS_DEBUG->print("ApplicationWindow::slotWindowActivated end");
1677 * Called when the menu 'windows' is about to be shown.
1678 * This is used to update the window list in the menu.
1680 void ApplicationWindow::slotWindowsMenuAboutToShow()
1682 RS_DEBUG->print("ApplicationWindow::slotWindowsMenuAboutToShow");
1684 windowsMenu->clear();
1686 int cascadeId = windowsMenu->insertItem(tr("&Cascade"), workspace, SLOT(cascade()));
1687 int tileId = windowsMenu->insertItem(tr("&Tile"), this, SLOT(slotTileVertical()));
1688 int horTileId = windowsMenu->insertItem(tr("Tile &Horizontally"), this, SLOT(slotTileHorizontal()));
1690 if (workspace->subWindowList().isEmpty())
1692 windowsMenu->setItemEnabled(cascadeId, false);
1693 windowsMenu->setItemEnabled(tileId, false);
1694 windowsMenu->setItemEnabled(horTileId, false);
1697 windowsMenu->insertSeparator();
1699 #warning "!!! Qt4 implementation of insertItem is vastly different from Qt3--FIX !!!"
1701 QList<QMdiSubWindow *> windows = workspace->subWindowList();
1703 //#warning "Need to add window numbers underlined so can access windows via keyboard. !!! FIX !!!"
1705 for(int i=0; i<int(windows.count()); ++i)
1707 // int id = windowsMenu->insertItem(windows.at(i)->caption(), this, SLOT(slotWindowsMenuActivated(int)));
1708 //For some reason the triggered() signal created here is type bool... Dunno why...
1709 //It's signalling using the QAction signal, which is type bool (checked or not).
1711 QString actionName = QString("&%1 %2").arg(i + 1).arg(windows.at(i)->windowTitle());
1712 // QAction * action = new QAction(windows.at(i)->windowTitle(), this);
1713 QAction * action = new QAction(actionName, this);
1714 action->setCheckable(true);
1716 action->setChecked(workspace->activeSubWindow() == windows.at(i));
1717 windowsMenu->addAction(action);
1718 connect(windowsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotWindowsMenuActivated(QAction *)));
1719 // connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1721 QAction * id = windowsMenu->addAction(windows.at(i)->windowTitle(), this,
1722 // SLOT(slotWindowsMenuActivated(int)));
1723 SLOT(slotWindowsMenuActivated(QAction *)));
1725 // windowsMenu->setItemParameter(id, i);
1726 // windowsMenu->setItemChecked(id, workspace->activeSubWindow() == windows.at(i));
1728 id->setChecked(workspace->activeSubWindow() == windows.at(i));
1734 * Called when the user selects a document window from the
1737 void ApplicationWindow::slotWindowsMenuActivated(QAction * id)
1739 RS_DEBUG->print("ApplicationWindow::slotWindowsMenuActivated");
1741 // QMdiSubWindow * w = workspace->subWindowList().at(id);
1742 QMdiSubWindow * w = workspace->subWindowList().at(id->data().toInt());
1750 * Tiles MDI windows horizontally.
1752 void ApplicationWindow::slotTileHorizontal()
1754 RS_DEBUG->print("ApplicationWindow::slotTileHorizontal");
1757 // primitive horizontal tiling
1758 QWidgetList windows = workspace->windowList();
1760 if (windows.count() == 0)
1763 int heightForEach = workspace->height() / windows.count();
1766 for(int i=0; i<int(windows.count()); ++i)
1768 QWidget * window = windows.at(i);
1770 #warning "Need to port to Qt4... !!! FIX !!!"
1772 if (window->testWState(WState_Maximized))
1776 window->showNormal();
1780 int preferredHeight = window->minimumHeight() + window->parentWidget()->baseSize().height();
1781 int actHeight = QMAX(heightForEach, preferredHeight);
1783 // window->parentWidget()->resize(workspace->width(), actHeight);
1784 window->parentWidget()->setGeometry(0, y, workspace->width(), actHeight);
1788 workspace->tileSubWindows();
1793 * Tiles MDI windows vertically.
1795 void ApplicationWindow::slotTileVertical()
1801 QWidgetList windows = workspace->windowList();
1802 if (windows.count()==0) {
1806 //int heightForEach = workspace->height() / windows.count();
1808 for (int i=0; i<int(windows.count()); ++i) {
1809 QWidget *window = windows.at(i);
1810 if (window->testWState(WState_Maximized)) {
1813 window->showNormal();
1815 //int preferredHeight = window->minimumHeight()
1816 // + window->parentWidget()->baseSize().height();
1817 //int actHeight = QMAX(heightForEach, preferredHeight);
1819 //window->parentWidget()->setGeometry(0, y,
1820 // workspace->width(), actHeight);
1821 //window->parentWidget()->resize(window->parentWidget()->width(),
1822 // window->parentWidget()->height());
1823 //window->resize(window->width(), window->height());
1828 workspace->tileSubWindows();
1837 void ApplicationWindow::slotCamExportAuto() {
1838 printf("CAM export..\n");
1840 RS_Document* d = getDocument();
1842 Drawing* graphic = (Drawing*)d;
1844 RS_CamDialog dlg(graphic, this);
1852 * Called when something changed in the pen tool bar
1853 * (e.g. color, width, style).
1855 void ApplicationWindow::slotPenChanged(RS_Pen pen)
1857 RS_DEBUG->print("ApplicationWindow::slotPenChanged() begin");
1858 RS_DEBUG->print("Setting active pen...");
1859 MDIWindow * m = getMDIWindow();
1862 m->slotPenChanged(pen);
1864 RS_DEBUG->print("ApplicationWindow::slotPenChanged() end");
1868 * Creates a new MDI window with the given document or a new
1869 * document if 'doc' is NULL.
1871 MDIWindow * ApplicationWindow::slotFileNew(RS_Document * doc)
1873 RS_DEBUG->print("ApplicationWindow::slotFileNew() begin");
1878 statusBar()->showMessage(tr("Creating new file..."));
1880 #warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible"
1881 RS_DEBUG->print(" creating MDI window");
1882 // MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::WA_DeleteOnClose);
1883 MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::SubWindow);
1884 w->setAttribute(Qt::WA_DeleteOnClose);
1885 // w->setWindowState(WindowMaximized);
1886 connect(w, SIGNAL(signalClosing()), this, SLOT(slotFileClosing()));
1888 if (w->getDocument()->rtti() == RS2::EntityBlock)
1889 // w->setCaption(tr("Block '%1'").arg(((RS_Block *)(w->getDocument()))->getName()));
1890 w->setWindowTitle(tr("Block '%1'").arg(((RS_Block *)(w->getDocument()))->getName()));
1892 // w->setCaption(tr("unnamed document %1").arg(id));
1893 w->setWindowTitle(tr("unnamed document %1").arg(id));
1895 // w->setIcon(qPixmapFromMimeSource("document.png"));
1896 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
1897 w->setWindowIcon(QIcon(":/res/document.png"));
1899 // only graphics offer block lists, blocks don't
1900 RS_DEBUG->print(" adding listeners");
1901 Drawing * graphic = w->getDocument()->getGraphic();
1903 if (graphic != NULL)
1905 // Link the graphic's layer list to the pen tool bar
1906 graphic->addLayerListListener(penToolBar);
1907 // Link the layer list to the layer widget
1908 graphic->addLayerListListener(layerWidget);
1909 // Link the block list to the block widget
1910 graphic->addBlockListListener(blockWidget);
1913 // Link the dialog factory to the mouse widget:
1914 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
1915 // Link the dialog factory to the coordinate widget:
1916 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
1917 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
1918 // Link the dialog factory to the option widget:
1919 // QG_DIALOGFACTORY->setOptionWidget(optionWidget);
1920 // Link the dialog factory to the cad tool bar:
1921 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
1922 // Link the dialog factory to the command widget:
1923 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
1924 // Link the dialog factory to the main app window:
1925 QG_DIALOGFACTORY->setMainWindow(this);
1927 #if 1 //bugfix for Qt3->4 conversion
1928 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotFileNew: adding window to workspace...");
1929 // workspace->addWindow(w);
1930 workspace->addSubWindow(w);
1933 RS_DEBUG->print(" showing MDI window");
1936 #warning "w->showMaximized() doesn't seem to do anything here..."
1937 //but then again, the subWindowList isn't going to be empty at this point either...
1938 if (workspace->subWindowList().isEmpty())
1944 #warning "!!! SubWindow is not being activated !!!"
1945 //neither of these is working... Is the event being eaten somewhere???
1946 // workspace->activateNextSubWindow();
1948 //printf("--> ApplicationWindow::slotFileNew(): w %s focus...\n", (w->hasFocus() ? "has" : "DOES NOT HAVE"));
1951 #warning "!!! Parameter to slotWindowActivated() is ignored !!!"
1952 slotWindowActivated(w);
1953 statusBar()->showMessage(tr("New Drawing created."), 2000);
1955 RS_DEBUG->print("ApplicationWindow::slotFileNew() OK");
1962 * Menu file -> open.
1964 void ApplicationWindow::slotFileOpen()
1966 RS_DEBUG->print("ApplicationWindow::slotFileOpen()");
1968 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 001");
1969 RS2::FormatType type = RS2::FormatUnknown;
1970 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 002");
1971 QString fileName = QG_FileDialog::getOpenFileName(this, &type);
1972 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 003");
1973 slotFileOpen(fileName, type);
1974 RS_DEBUG->print("ApplicationWindow::slotFileOpen(): OK");
1978 * Called when a recently opened file is chosen from the list in the
1981 void ApplicationWindow::slotFileOpenRecent(void)
1984 RS_DEBUG->print("ApplicationWindow::slotFileOpenRecent()");
1986 statusBar()->showMessage(tr("Opening recent file..."));
1987 QString fileName = recentFiles->get(id);
1989 if (fileName.endsWith(" (DXF 1)"))
1990 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
1992 slotFileOpen(fileName, RS2::FormatUnknown);
1994 statusBar()->showMessage(tr("Opening recent file..."));
1996 QAction * action = qobject_cast<QAction *>(sender());
2001 QString fileName = action->data().toString();
2003 if (fileName.endsWith(" (DXF 1)"))
2004 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
2006 slotFileOpen(fileName, RS2::FormatUnknown);
2011 * Menu file -> open.
2013 void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType type)
2015 RS_DEBUG->print("ApplicationWindow::slotFileOpen(..)");
2017 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2019 if (!fileName.isEmpty())
2021 RS_DEBUG->print("ApplicationWindow::slotFileOpen: creating new doc window");
2022 // Create new document window:
2023 MDIWindow * w = slotFileNew();
2024 // RS_APP->processEvents(1000);
2025 //Really, is this needed???
2026 // RS_APP->processEvents(QEventLoop::AllEvents, 1000);
2028 RS_DEBUG->print("ApplicationWindow::slotFileOpen: linking layer list");
2029 // link the layer widget to the new document:
2030 layerWidget->setLayerList(w->getDocument()->getLayerList(), false);
2031 // link the block widget to the new document:
2032 blockWidget->setBlockList(w->getDocument()->getBlockList());
2033 // link coordinate widget to graphic
2034 coordinateWidget->setGraphic(w->getGraphic());
2036 // link the layer widget to the new document:
2037 simulationControls->setGraphicView(w->getGraphicView());
2040 RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file");
2042 // RS_APP->processEvents(1000);
2043 //We no longer try to do Qt better than the Qt folks...
2044 // RS_APP->processEvents(QEventLoop::AllEvents, 1000);
2046 // open the file in the new view:
2047 if (w->slotFileOpen(fileName, type) == false)
2050 QApplication::restoreOverrideCursor();
2051 QMessageBox::information(this, QMessageBox::tr("Warning"),
2052 tr("Cannot open the file\n%1\nPlease check the permissions.") .arg(fileName), QMessageBox::Ok);
2053 w->setForceClosing(true);
2058 RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file: OK");
2059 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 1");
2061 // update recent files menu:
2062 if (type == RS2::FormatDXF1)
2063 recentFiles->add(fileName + " (DXF 1)");
2065 recentFiles->add(fileName);
2067 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 2");
2068 // updateRecentFilesMenu();
2069 recentFiles->UpdateGUI();
2071 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: OK");
2073 RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption");
2075 // w->setCaption(fileName);
2076 w->setWindowTitle(fileName);
2077 RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption: OK");
2079 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget");
2080 // update coordinate widget format:
2081 RS_DIALOGFACTORY->updateCoordinateWidget(Vector(0.0, 0.0), Vector(0.0, 0.0), true);
2082 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget: OK");
2084 // show output of filter (if any):
2085 // commandWidget->processStderr();
2086 QString message = tr("Loaded document: ") + fileName;
2087 commandWidget->appendHistory(message);
2088 statusBar()->showMessage(message, 2000);
2092 statusBar()->showMessage(tr("Opening aborted"), 2000);
2095 QApplication::restoreOverrideCursor();
2096 RS_DEBUG->print("ApplicationWindow::slotFileOpen(..) OK");
2100 * Menu file -> save.
2102 void ApplicationWindow::slotFileSave()
2104 RS_DEBUG->print("ApplicationWindow::slotFileSave()");
2106 statusBar()->showMessage(tr("Saving drawing..."));
2108 MDIWindow * w = getMDIWindow();
2113 if (w->getDocument()->getFilename().isEmpty())
2119 if (w->slotFileSave(cancelled))
2123 name = w->getDocument()->getFilename();
2124 statusBar()->showMessage(tr("Saved drawing: %1").arg(name), 2000);
2130 QMessageBox::information(this, QMessageBox::tr("Warning"),
2131 tr("Cannot save the file\n%1\nPlease check the permissions.")
2132 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2139 * Menu file -> save as.
2141 void ApplicationWindow::slotFileSaveAs()
2143 RS_DEBUG->print("ApplicationWindow::slotFileSaveAs()");
2145 statusBar()->showMessage(tr("Saving drawing under new filename..."));
2147 MDIWindow * w = getMDIWindow();
2154 if (w->slotFileSaveAs(cancelled))
2158 name = w->getDocument()->getFilename();
2159 recentFiles->add(name);
2160 w->setWindowTitle(name);
2166 QMessageBox::information(this, QMessageBox::tr("Warning"),
2167 tr("Cannot save the file\n%1\nPlease check the permissions.")
2168 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2172 // updateRecentFilesMenu();
2173 recentFiles->UpdateGUI();
2175 QString message = tr("Saved drawing: %1").arg(name);
2176 statusBar()->showMessage(message, 2000);
2177 commandWidget->appendHistory(message);
2181 * Menu file -> export.
2183 void ApplicationWindow::slotFileExport()
2185 RS_DEBUG->print("ApplicationWindow::slotFileExport()");
2187 statusBar()->showMessage(tr("Exporting drawing..."));
2189 MDIWindow * w = getMDIWindow();
2194 // read default settings:
2195 settings.beginGroup("Paths");
2196 QString defDir = settings.value("ExportImage", RS_SYSTEM->getHomeDir()).toString();
2197 QString defFilter = settings.value("ExportImageFilter", "Portable Network Graphic (*.png)").toString();
2198 settings.endGroup();
2200 bool cancel = false;
2202 // Q3FileDialog fileDlg(NULL, "", true);
2203 QFileDialog fileDlg(NULL, "", "", "");
2205 #warning "Need to port to Qt4... !!! FIX !!!"
2207 Q3StrList f = QImageIO::outputFormats();
2208 QStringList formats = QStringList::fromStrList(f);
2209 QStringList filters;
2212 for (QStringList::Iterator it = formats.begin();
2213 it!=formats.end(); ++it)
2218 st = QString("%1 (*.%2 *.jpg)")
2219 .arg(QG_DialogFactory::extToFormat(*it))
2220 .arg(QString(*it).lower());
2224 st = QString("%1 (*.%2)")
2225 .arg(QG_DialogFactory::extToFormat(*it))
2226 .arg(QString(*it).lower());
2231 //if (!all.isEmpty()) {
2234 //all += QString("*.%1").arg(QString(*it).lower());
2237 QStringList filters;
2240 fileDlg.setFilters(filters);
2241 // fileDlg.setMode(Q3FileDialog::AnyFile);
2242 fileDlg.setFileMode(QFileDialog::AnyFile);
2243 // fileDlg.setCaption(QObject::tr("Export Image"));
2244 fileDlg.setWindowTitle(QObject::tr("Export Image"));
2245 // fileDlg.setDir(defDir);
2246 fileDlg.setDirectory(defDir);
2247 fileDlg.selectNameFilter(defFilter);
2249 if (fileDlg.exec() == QDialog::Accepted)
2251 // fn = fileDlg.selectedFile();
2252 QStringList files = fileDlg.selectedFiles();
2254 if (!files.isEmpty())
2262 // store new default settings:
2265 settings.beginGroup("Paths");
2266 // settings.writeEntry("/ExportImage", QFileInfo(fn).dirPath(true));
2267 settings.setValue("ExportImage", QFileInfo(fn).absolutePath());
2268 settings.setValue("ExportImageFilter", fileDlg.selectedFilter());
2269 settings.endGroup();
2271 // find out extension:
2272 QString filter = fileDlg.selectedFilter();
2273 QString format = "";
2274 // int i = filter.find("(*.");
2275 int i = filter.indexOf("(*.");
2279 // int i2 = filter.find(QRegExp("[) ]"), i);
2280 int i2 = filter.indexOf(QRegExp("[) ]"), i);
2281 format = filter.mid(i + 3, i2 - (i + 3));
2282 format = format.toUpper();
2285 // append extension to file:
2286 if (!QFileInfo(fn).fileName().contains("."))
2287 fn.append("." + format.toLower());
2289 // show options dialog:
2290 ImageOptionsDialog dlg(this);
2291 dlg.setGraphicSize(w->getGraphic()->getSize());
2295 bool ret = slotFileExport(fn, format, dlg.getSize(), dlg.isBackgroundBlack());
2299 QString message = tr("Exported: %1").arg(fn);
2300 statusBar()->showMessage(message, 2000);
2301 commandWidget->appendHistory(message);
2309 * Exports the drawing as a bitmap.
2311 * @param name File name.
2312 * @param format File format (e.g. "png")
2313 * @param size Size of the bitmap in pixel
2314 * @param black true: Black background, false: white
2315 * @param bw true: black/white export, false: color
2317 bool ApplicationWindow::slotFileExport(const QString & name, const QString & format, QSize size, bool black, bool bw)
2319 MDIWindow * w = getMDIWindow();
2323 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no window opened");
2327 Drawing * graphic = w->getDocument()->getGraphic();
2329 if (graphic == NULL)
2331 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no graphic");
2335 statusBar()->showMessage(tr("Exporting..."));
2336 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2339 QPixmap * buffer = new QPixmap(size);
2340 // RS_PainterQt * painter = new RS_PainterQt(buffer);
2341 QPainter qpntr(buffer);
2342 PaintInterface * painter = new PaintInterface(&qpntr);
2344 // black background:
2346 // painter->setBackgroundColor(RS_Color(0, 0, 0));
2347 // qpntr.setBackgroundColor(RS_Color(0, 0, 0));
2348 qpntr.setBackground(QBrush(QColor(0, 0, 0)));
2349 // white background:
2351 // painter->setBackgroundColor(RS_Color(255, 255, 255));
2352 // qpntr.setBackgroundColor(RS_Color(255, 255, 255));
2353 qpntr.setBackground(QBrush(QColor(255, 255, 255)));
2357 painter->setDrawingMode(RS2::ModeBW);
2359 // painter->eraseRect(0, 0, size.width(), size.height());
2360 qpntr.eraseRect(0, 0, size.width(), size.height());
2362 RS_StaticGraphicView gv(size.width(), size.height(), painter);
2365 gv.setBackground(RS_Color(0, 0, 0));
2367 gv.setBackground(RS_Color(255, 255, 255));
2369 gv.setContainer(graphic);
2371 gv.drawEntity(graphic, true);
2378 iio.setFileName(name);
2379 iio.setFormat(format);
2386 #warning "Need to port to Qt4... !!! FIX !!!"
2389 QApplication::restoreOverrideCursor();
2391 // GraphicView deletes painter
2398 statusBar()->showMessage(tr("Export complete"), 2000);
2400 statusBar()->showMessage(tr("Export failed!"), 2000);
2406 * Menu file -> close.
2408 void ApplicationWindow::slotFileClose()
2410 RS_DEBUG->print("ApplicationWindow::slotFileClose()");
2412 MDIWindow * m = getMDIWindow();
2421 //m->showMaximized();
2422 m->setWindowState(WindowMaximized);
2428 * Called when a MDI window is actually about to close. Used to
2429 * detach widgets from the document.
2431 void ApplicationWindow::slotFileClosing()
2433 RS_DEBUG->print("ApplicationWindow::slotFileClosing()");
2435 RS_DEBUG->print("detaching lists");
2436 layerWidget->setLayerList(NULL, false);
2437 blockWidget->setBlockList(NULL);
2438 coordinateWidget->setGraphic(NULL);
2440 simulationControls->setGraphicView(NULL);
2445 * Menu file -> print.
2447 void ApplicationWindow::slotFilePrint()
2449 RS_DEBUG->print("ApplicationWindow::slotFilePrint()");
2451 MDIWindow * w = getMDIWindow();
2455 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no window opened");
2459 Drawing * graphic = w->getDocument()->getGraphic();
2461 if (graphic == NULL)
2463 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no graphic");
2467 statusBar()->showMessage(tr("Printing..."));
2468 QPrinter * printer = new QPrinter(QPrinter::HighResolution);
2469 bool landscape = false;
2470 printer->setPageSize(RS2::rsToQtPaperFormat(graphic->getPaperFormat(&landscape)));
2473 printer->setOrientation(QPrinter::Landscape);
2475 printer->setOrientation(QPrinter::Portrait);
2477 settings.beginGroup("Print");
2478 printer->setOutputFileName(settings.value("FileName", "").toString());
2479 printer->setColorMode((QPrinter::ColorMode)settings.value("/ColorMode", (int)QPrinter::Color).toInt());
2480 #warning "!!! Need to port QPrinter::setOutputToFile() to Qt4 !!!"
2481 // printer->setOutputToFile((bool)RS_SETTINGS->readNumEntry("/PrintToFile", 0));
2482 settings.endGroup();
2485 // if (printer->setup(this))
2486 QPrintDialog dialog(printer, this);
2489 //printer->setOutputToFile(true);
2490 //printer->setOutputFileName(outputFile);
2492 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2493 printer->setFullPage(true);
2494 //Can call these functions directly from the QPaintDevice...
2495 // Q3PaintDeviceMetrics metr(printer);
2497 // RS_PainterQt * painter = new RS_PainterQt(printer);
2498 QPainter qpntr(printer);
2499 PaintInterface * painter = new PaintInterface(&qpntr);
2500 painter->setDrawingMode(w->getGraphicView()->getDrawingMode());
2502 // RS_StaticGraphicView gv(metr.width(), metr.height(), painter);
2503 RS_StaticGraphicView gv(printer->width(), printer->height(), painter);
2504 gv.setPrinting(true);
2505 gv.setBorders(0, 0, 0, 0);
2507 // double fx = (double)metr.width() / metr.widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2508 // double fy = (double)metr.height() / metr.heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2509 double fx = (double)printer->width() / printer->widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2510 double fy = (double)printer->height() / printer->heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2511 double f = (fx + fy) / 2;
2512 double scale = graphic->getPaperScale();
2514 gv.setOffset((int)(graphic->getPaperInsertionBase().x * f),
2515 (int)(graphic->getPaperInsertionBase().y * f));
2516 gv.setFactor(f * scale);
2517 gv.setContainer(graphic);
2518 gv.drawEntity(graphic, true);
2520 // GraphicView deletes painter
2525 settings.beginGroup("Print");
2526 #warning "!!! Need to port QPrinter::outputToFile() to Qt4 !!!"
2527 // settings.writeEntry("/PrintToFile", (int)printer->outputToFile());
2528 settings.setValue("ColorMode", (int)printer->colorMode());
2529 settings.setValue("FileName", printer->outputFileName());
2530 settings.endGroup();
2531 QApplication::restoreOverrideCursor();
2536 statusBar()->showMessage(tr("Printing complete"), 2000);
2540 * Menu file -> print preview.
2542 void ApplicationWindow::slotFilePrintPreview(bool on)
2544 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview()");
2546 RS_DEBUG->print(" creating MDI window");
2547 MDIWindow * parent = getMDIWindow();
2551 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrintPreview: no window opened");
2555 // close print preview:
2558 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): off");
2560 if (parent->getGraphicView()->isPrintPreview())
2562 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): close");
2566 // open print preview:
2569 // look for an existing print preview:
2570 MDIWindow * ppv = parent->getPrintPreview();
2574 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): show existing");
2575 slotWindowActivated(ppv);
2580 if (!parent->getGraphicView()->isPrintPreview())
2582 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): create");
2584 MDIWindow * w = new MDIWindow(parent->getDocument(), workspace, 0, Qt::SubWindow);
2585 w->setAttribute(Qt::WA_DeleteOnClose);
2586 parent->addChildWindow(w);
2587 //connect(w, SIGNAL(signalClosing()),
2588 // this, SLOT(slotFileClosing()));
2590 // w->setCaption(tr("Print preview for %1").arg(parent->caption()));
2591 w->setWindowTitle(tr("Print preview for %1").arg(parent->windowTitle()));
2592 // w->setIcon(qPixmapFromMimeSource("document.png"));
2593 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
2594 w->setWindowIcon(QIcon(":/res/document.png"));
2595 w->getGraphicView()->setPrintPreview(true);
2596 w->getGraphicView()->setBackground(RS_Color(255, 255, 255));
2597 w->getGraphicView()->setDefaultAction(new RS_ActionPrintPreview(*w->getDocument(), *w->getGraphicView()));
2599 // only graphics offer block lists, blocks don't
2600 RS_DEBUG->print(" adding listeners");
2601 Drawing * graphic = w->getDocument()->getGraphic();
2603 if (graphic != NULL)
2605 // Link the layer list to the pen tool bar
2606 graphic->addLayerListListener(penToolBar);
2607 // Link the layer list to the layer widget
2608 graphic->addLayerListListener(layerWidget);
2609 // Link the block list to the block widget
2610 graphic->addBlockListListener(blockWidget);
2611 // Center by default:
2612 graphic->centerToPage();
2615 // Link the graphic view to the mouse widget:
2616 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
2617 // Link the graphic view to the coordinate widget:
2618 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
2619 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
2620 // Link the graphic view to the option widget:
2621 //QG_DIALOGFACTORY->setOptionWidget(optionWidget);
2622 // Link the graphic view to the cad tool bar:
2623 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
2624 // Link the graphic view to the command widget:
2625 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
2627 RS_DEBUG->print(" showing MDI window");
2629 if (workspace->subWindowList().isEmpty())
2634 w->getGraphicView()->zoomPage();
2637 slotWindowActivated(w);
2644 * Menu file -> quit.
2646 void ApplicationWindow::slotFileQuit()
2648 RS_DEBUG->print("ApplicationWindow::slotFileQuit()");
2650 statusBar()->showMessage(tr("Exiting application..."));
2652 if (queryExit(false))
2657 * Forces termination of QCad (demo version).
2659 void ApplicationWindow::slotFileDemoQuit()
2661 statusBar()->showMessage(tr("Exiting application..."));
2668 * Shows / hides the grid.
2670 * @param toggle true: show, false: hide.
2672 void ApplicationWindow::slotViewGrid(bool toggle)
2674 RS_DEBUG->print("ApplicationWindow::slotViewGrid()");
2676 MDIWindow * m = getMDIWindow();
2680 Drawing * g = m->getGraphic();
2683 g->setGridOn(toggle);
2689 RS_DEBUG->print("ApplicationWindow::slotViewGrid() OK");
2693 * Enables / disables the draft mode.
2695 * @param toggle true: enable, false: disable.
2697 void ApplicationWindow::slotViewDraft(bool toggle)
2699 RS_DEBUG->print("ApplicationWindow::slotViewDraft()");
2701 /*MDIWindow* m = getMDIWindow();
2703 Drawing* g = m->getGraphic();
2705 g->setDraftOn(toggle);
2709 settings.beginGroup("Appearance");
2710 settings.setValue("DraftMode", toggle);
2711 settings.endGroup();
2717 * Redraws all mdi windows.
2719 void ApplicationWindow::redrawAll()
2723 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2725 for(int i=0; i<int(windows.count()); ++i)
2727 MDIWindow * m = (MDIWindow *)windows.at(i);
2731 QG_GraphicView * gv = m->getGraphicView();
2741 * Updates all grids of all graphic views.
2743 void ApplicationWindow::updateGrids()
2747 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2749 for(int i=0; i<int(windows.count()); ++i)
2751 MDIWindow * m = (MDIWindow *)windows.at(i);
2755 QG_GraphicView * gv = m->getGraphicView();
2765 * Shows / hides the status bar.
2767 * @param showSB true: show, false: hide.
2769 void ApplicationWindow::slotViewStatusBar(bool showSB)
2771 RS_DEBUG->print("ApplicationWindow::slotViewStatusBar()");
2774 statusBar()->show();
2776 statusBar()->hide();
2780 * Shows / hides the layer list.
2782 * @param toggle true: show, false: hide.
2784 /*void ApplicationWindow::slotViewLayerList(bool toggle) {
2785 RS_DEBUG->print("ApplicationWindow::slotViewLayerList()");
2787 if (toggle==false) {
2788 layerDockWindow->hide();
2790 layerDockWindow->show();
2796 * Shows / hides the block list.
2798 * @param toggle true: show, false: hide.
2801 void ApplicationWindow::slotViewBlockList(bool toggle) {
2802 RS_DEBUG->print("ApplicationWindow::slotViewBlockList()");
2804 if (toggle==false) {
2805 blockDockWindow->hide();
2807 blockDockWindow->show();
2813 * Shows / hides the command line.
2815 * @param toggle true: show, false: hide.
2818 void ApplicationWindow::slotViewCommandLine(bool toggle) {
2819 RS_DEBUG->print("ApplicationWindow::slotViewCommandLine()");
2821 if (toggle==false) {
2822 commandDockWindow->hide();
2823 //QG_GraphicView* graphicView = getGraphicView();
2824 //if (graphicView!=NULL) {
2825 //graphicView->setFocus();
2829 commandDockWindow->show();
2835 * Shows / hides the option toolbar.
2837 * @param toggle true: show, false: hide.
2840 void ApplicationWindow::slotViewOptionToolbar(bool toggle) {
2841 RS_DEBUG->print("ApplicationWindow::slotViewOptionToolbar()");
2843 if (toggle==false) {
2844 optionWidget->hide();
2846 optionWidget->show();
2852 * Creates a new MDI window for editing the selected block.
2855 void ApplicationWindow::slotBlocksEdit() {
2856 RS_DEBUG->print("ApplicationWindow::slotBlocksEdit()");
2858 MDIWindow* parent = getMDIWindow();
2860 RS_BlockList* blist = blockWidget->getBlockList();
2862 RS_Block* blk = blist->getActiveBlock();
2864 MDIWindow* w = slotFileNew(blk);
2865 // the parent needs a pointer to the block window and
2867 parent->addChildWindow(w);
2868 w->getGraphicView()->zoomAuto();
2876 * Shows the dialog for general application preferences.
2878 void ApplicationWindow::slotOptionsGeneral()
2880 RS_DIALOGFACTORY->requestOptionsGeneralDialog();
2882 // update background color of all open drawings:
2883 settings.beginGroup("Appearance");
2884 QColor color(settings.value("BackgroundColor", "#000000").toString());
2885 QColor gridColor(settings.value("GridColor", "Gray").toString());
2886 QColor metaGridColor(settings.value("MetaGridColor", "Darkgray").toString());
2887 QColor selectedColor(settings.value("SelectedColor", "#A54747").toString());
2888 QColor highlightedColor(settings.value("HighlightedColor", "#739373").toString());
2889 settings.endGroup();
2891 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2893 for(int i=0; i<int(windows.count()); ++i)
2895 MDIWindow * m = (MDIWindow *)windows.at(i);
2899 QG_GraphicView * gv = m->getGraphicView();
2903 gv->setBackground(color);
2904 gv->setGridColor(gridColor);
2905 gv->setMetaGridColor(metaGridColor);
2906 gv->setSelectedColor(selectedColor);
2907 gv->setHighlightedColor(highlightedColor);
2916 * Menu script -> show ide
2918 void ApplicationWindow::slotScriptOpenIDE()
2921 scripter->openIDE();
2926 * Menu script -> run
2928 void ApplicationWindow::slotScriptRun()
2931 scripter->runScript();
2936 * Menu help -> about.
2938 void ApplicationWindow::slotHelpAbout()
2940 RS_DEBUG->print("ApplicationWindow::slotHelpAbout()");
2941 QStringList modules;
2948 modules += "Scripting";
2951 QString modulesString;
2953 if (modules.empty() == false)
2954 modulesString = modules.join(", ");
2956 modulesString = tr("None");
2958 QMessageBox box(this);
2959 box.setWindowTitle(tr("About..."));
2960 box.setText(QString("<qt>") + // no center for main stream QCad
2961 #ifdef QC_ABOUT_HEADER
2962 QString("<center>") +
2963 QString(QC_ABOUT_HEADER) +
2965 //FAIL "<h2>"+ QC_APPNAME+ "</h2>" +
2966 "<h2>Architektonas</h2>" +
2968 tr("Version: %1").arg("1.0.0") + "<br>" +
2969 tr("Date: %1").arg(__DATE__) + "<br>" +
2970 QString("© 2010 Underground Software,<br>James Hammons") +
2972 #ifdef QC_ABOUT_ADD_COMPANY
2973 + QString("<br>") + QC_ABOUT_ADD_COMPANY
2975 + QString("</center>")
2977 #ifndef QC_ABOUT_HEADER
2978 #warning "Failure..."
2979 // box.setIcon(qPixmapFromMimeSource(QC_APP_ICON));
2980 box.setFixedWidth(340);
2981 box.setFixedHeight(250);
2987 * Menu help -> help.
2989 void ApplicationWindow::slotHelpManual()
2991 #warning "No help system ported to Qt4... !!! FIX !!!"
2993 RS_DEBUG->print("ApplicationWindow::slotHelpManual()");
2995 if (assistant == NULL)
2997 RS_DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
2998 RS_DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
2999 assistant = new QAssistantClient(RS_SYSTEM->getAppDir()+"/bin", this);
3000 connect(assistant, SIGNAL(error(const QString&)), this, SLOT(slotError(const QString&)));
3003 args << QDir::convertSeparators(RS_SYSTEM->getDocPath() + "/qcaddoc.adp");
3004 // args << QString("doc") + QDir::separator() + QString("qcaddoc.adp");
3006 #if QT_VERSION>=0x030200
3007 assistant->setArguments(args);
3010 assistant->openAssistant();
3011 //assistant->showPage("index.html");
3018 void ApplicationWindow::slotTestDumpEntities(RS_EntityContainer * d)
3020 RS_DEBUG->print("ApplicationWindow::slotTestDumpEntities()");
3021 static int level = 0;
3022 std::ofstream dumpFile;
3027 dumpFile.open("debug_entities.html");
3032 dumpFile.open("debug_entities.html", std::ios::app);
3040 dumpFile << "<html>\n";
3041 dumpFile << "<body>\n";
3044 for (RS_Entity* e=d->firstEntity();
3049 dumpFile << "<table border=\"1\">\n";
3050 dumpFile << "<tr><td>Entity: " << e->getId()
3054 << "<tr><td><table><tr>"
3055 << "<td>VIS:" << e->isVisible() << "</td>"
3056 << "<td>UND:" << e->isUndone() << "</td>"
3057 << "<td>SEL:" << e->isSelected() << "</td>"
3058 << "<td>TMP:" << e->getFlag(RS2::FlagTemp) << "</td>";
3059 QString lay = "NULL";
3060 if (e->getLayer()!=NULL) {
3061 lay = e->getLayer()->getName();
3064 //fail << "<td>Layer: " << lay << "</td>"
3065 << "<td>Width: " << (int)e->getPen(false).getWidth() << "</td>"
3066 << "<td>Parent: " << e->getParent()->getId() << "</td>"
3074 case RS2::EntityPoint:
3076 RS_Point* p = (RS_Point*)e;
3078 << "<table><tr><td>"
3090 case RS2::EntityLine:
3092 RS_Line* l = (RS_Line*)e;
3094 << "<table><tr><td>"
3100 << l->getStartpoint()
3109 case RS2::EntityArc: {
3110 RS_Arc* a = (RS_Arc*)e;
3112 << "<table><tr><td>"
3129 << "<td>Startpoint: "
3130 << a->getStartpoint()
3136 << (int)a->isReversed()
3142 case RS2::EntityCircle: {
3143 RS_Circle* c = (RS_Circle*)e;
3145 << "<table><tr><td>"
3160 case RS2::EntityDimAligned: {
3161 RS_DimAligned* d = (RS_DimAligned*)e;
3163 << "<table><tr><td>"
3164 << "<b>Dimension / Aligned:</b>"
3169 << d->getDefinitionPoint()
3172 << d->getExtensionPoint1()
3175 << d->getExtensionPoint2()
3178 << d->getText().toLatin1().data()
3181 << d->getLabel().toLatin1().data()
3187 case RS2::EntityDimLinear:
3189 RS_DimLinear* d = (RS_DimLinear*)e;
3191 << "<table><tr><td>"
3192 << "<b>Dimension / Linear:</b>"
3197 << d->getDefinitionPoint()
3200 << d->getExtensionPoint1()
3203 << d->getExtensionPoint2()
3206 //fail << d->getText()
3209 //fail << d->getLabel()
3215 case RS2::EntityInsert: {
3216 RS_Insert* i = (RS_Insert*)e;
3218 << "<table><tr><td>"
3223 << "<td>Insertion point:"
3224 << i->getInsertionPoint()
3230 case RS2::EntityText: {
3231 RS_Text* t = (RS_Text*)e;
3233 << "<table><tr><td>"
3239 << t->getText().toLatin1().data()
3248 case RS2::EntityHatch: {
3249 RS_Hatch* h = (RS_Hatch*)e;
3251 << "<table><tr><td>"
3257 << h->getPattern().toLatin1().data()
3263 << (int)h->isSolid()
3272 << "<b>Unknown Entity: " << e->rtti() << "</b>"
3277 if (e->isContainer() || e->rtti()==RS2::EntityHatch) {
3278 RS_EntityContainer* ec = (RS_EntityContainer*)e;
3279 dumpFile << "<table><tr><td valign=\"top\"> Contents:</td><td>\n";
3281 slotTestDumpEntities(ec);
3282 dumpFile.open("debug_entities.html", std::ios::app);
3283 dumpFile << "</td></tr></table>\n";
3293 dumpFile << "</body>\n";
3294 dumpFile << "</html>\n";
3304 void ApplicationWindow::slotTestDumpUndo()
3306 RS_DEBUG->print("ApplicationWindow::slotTestDumpUndo()");
3308 RS_Document * d = getDocument();
3312 std::cout << *(RS_Undo*)d;
3313 std::cout << std::endl;
3320 void ApplicationWindow::slotTestUpdateInserts()
3322 RS_DEBUG->print("ApplicationWindow::slotTestUpdateInserts()");
3324 RS_Document * d = getDocument();
3333 void ApplicationWindow::slotTestDrawFreehand()
3335 RS_DEBUG->print("ApplicationWindow::slotTestDrawFreehand()");
3337 //Drawing* g = document->getMarking();
3340 RS_ActionDrawLineFree* action =
3341 new RS_ActionDrawLineFree(*document->getGraphic(),
3344 for (int i=0; i<100; ++i) {
3346 int posx = (random()%600);
3347 int posy = (random()%400);
3349 //RS_MouseEvent rsm1(posx, posy, LEFT);
3350 RS_MouseEvent rsm1(QEvent::MouseButtonPress,
3354 action->mousePressEvent(&rsm1);
3359 for (int k=0; k<100; ++k) {
3360 int accx = (random()%40)-20;
3361 int accy = (random()%40)-20;
3369 //RS_MouseEvent rsm2(posx, posy, LEFT);
3371 RS_MouseEvent rsm2(QEvent::MouseMove,
3375 action->mouseMoveEvent(&rsm2);
3378 action->mouseReleaseEvent(NULL);
3390 void ApplicationWindow::slotTestInsertBlock()
3392 RS_DEBUG->print("ApplicationWindow::slotTestInsertBlock()");
3394 RS_Document * d = getDocument();
3396 if (d != NULL && d->rtti() == RS2::EntityGraphic)
3398 Drawing * graphic = (Drawing *)d;
3400 if (graphic == NULL)
3403 graphic->addLayer(new RS_Layer("default"));
3404 RS_Block * block = new RS_Block(graphic, RS_BlockData("debugblock", Vector(0.0, 0.0), true));
3410 // Add one red line:
3411 line = new RS_Line(block, RS_LineData(Vector(0.0, 0.0), Vector(50.0, 0.0)));
3412 line->setLayerToActive();
3413 line->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3414 block->addEntity(line);
3416 // Add one line with attributes from block:
3417 line = new RS_Line(block, RS_LineData(Vector(50.0, 0.0), Vector(50.0, 50.0)));
3418 line->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3419 block->addEntity(line);
3421 // Add one arc with attributes from block:
3422 RS_ArcData d(Vector(50.0, 0.0), 50.0, M_PI / 2.0, M_PI, false);
3423 arc = new RS_Arc(block, d);
3424 arc->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3425 block->addEntity(arc);
3427 // Add one blue circle:
3428 RS_CircleData circleData(Vector(20.0, 15.0), 12.5);
3429 circle = new RS_Circle(block, circleData);
3430 circle->setLayerToActive();
3431 circle->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width01, RS2::SolidLine));
3432 block->addEntity(circle);
3434 graphic->addBlock(block);
3437 RS_InsertData insData("debugblock", Vector(0.0, 0.0), Vector(1.0, 1.0), 0.0, 1, 1, Vector(0.0, 0.0), NULL, RS2::NoUpdate);
3439 // insert one magenta instance of the block (original):
3440 ins = new RS_Insert(graphic, insData);
3441 ins->setLayerToActive();
3442 ins->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width02, RS2::SolidLine));
3444 graphic->addEntity(ins);
3446 // insert one green instance of the block (rotate):
3447 insData = RS_InsertData("debugblock", Vector(-50.0, 20.0), Vector(1.0, 1.0), 30.0 / ARAD, 1, 1, Vector(0.0, 0.0), NULL, RS2::NoUpdate);
3448 ins = new RS_Insert(graphic, insData);
3449 ins->setLayerToActive();
3450 ins->setPen(RS_Pen(RS_Color(0, 255, 0), RS2::Width02, RS2::SolidLine));
3452 graphic->addEntity(ins);
3454 // insert one cyan instance of the block (move):
3455 insData = RS_InsertData("debugblock", Vector(10.0, 20.0), Vector(1.0, 1.0), 0.0, 1, 1, Vector(0.0, 0.0), NULL, RS2::NoUpdate);
3456 ins = new RS_Insert(graphic, insData);
3457 ins->setLayerToActive();
3458 ins->setPen(RS_Pen(RS_Color(0, 255, 255), RS2::Width02, RS2::SolidLine));
3460 graphic->addEntity(ins);
3462 // insert one blue instance of the block:
3463 for(double a=0.0; a<360.0; a+=45.0)
3465 insData = RS_InsertData("debugblock", Vector(60.0, 0.0), Vector(2.0 / 5, 2.0 / 5), a/ARAD, 1, 1, Vector(0.0, 0.0), NULL, RS2::NoUpdate);
3466 ins = new RS_Insert(graphic, insData);
3467 ins->setLayerToActive();
3468 ins->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width05, RS2::SolidLine));
3470 graphic->addEntity(ins);
3473 // insert an array of yellow instances of the block:
3474 insData = RS_InsertData("debugblock", Vector(-100.0, -100.0), Vector(0.2, 0.2), M_PI / 6.0, 6, 4, Vector(100.0, 100.0), NULL, RS2::NoUpdate);
3475 ins = new RS_Insert(graphic, insData);
3476 ins->setLayerToActive();
3477 ins->setPen(RS_Pen(RS_Color(255, 255, 0), RS2::Width01, RS2::SolidLine));
3479 graphic->addEntity(ins);
3481 GraphicView * v = getGraphicView();
3491 void ApplicationWindow::slotTestInsertEllipse()
3493 RS_DEBUG->print("ApplicationWindow::slotTestInsertEllipse()");
3495 RS_Document * d = getDocument();
3499 Drawing * graphic = (Drawing *)d;
3501 if (graphic == NULL)
3504 RS_Ellipse * ellipse;
3507 for (double a=0.0; a<2*M_PI; a+=0.1)
3510 v.setPolar(50.0, a);
3511 double xp = 1000.0*a;
3513 RS_EllipseData ellipseData(Vector(xp, 0.0), v, 0.5, 0.0, 2 * M_PI, false);
3514 ellipse = new RS_Ellipse(graphic, ellipseData);
3516 ellipse->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width01, RS2::SolidLine));
3518 graphic->addEntity(ellipse);
3519 //graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3520 //graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3522 line = new RS_Line(graphic, RS_LineData(Vector(xp, 0.0), Vector(xp, 0.0) + v));
3523 line->setPen(RS_Pen(RS_Color(128, 128, 128), RS2::Width01, RS2::SolidLine));
3524 graphic->addEntity(line);
3527 for (double mx=-60.0; mx<60.0; mx+=1.0) {
3528 //for (double mx=0.0; mx<1.0; mx+=2.5) {
3529 VectorSolutions sol = ellipse->mapX(xp + mx);
3530 //graphic->addEntity(new RS_Point(graphic,
3531 // sol.vector2 + Vector(a*500.0, 0.0)));
3532 //graphic->addEntity(new RS_Point(graphic,
3533 // sol.vector3 + Vector(a*500.0, 0.0)));
3534 //graphic->addEntity(new RS_Point(graphic,
3535 // sol.vector4 + Vector(a*500.0, 0.0)));
3537 line = new RS_Line(graphic,
3538 RS_LineData(Vector(xp+mx,-50.0),
3539 Vector(xp+mx,50.0)));
3540 line->setPen(RS_Pen(RS_Color(60, 60, 60),
3543 graphic->addEntity(line);
3545 graphic->addEntity(new RS_Point(graphic,
3551 // different minor/minor relations
3554 for (y=-250.0; y<=250.0; y+=50.0) {
3555 for (x=-250.0; x<=250.0; x+=50.0) {
3558 ellipse = new RS_Ellipse(graphic,
3560 Vector((x/5+50.0)/2.0, 0.0),
3565 ellipse->setPen(RS_Pen(RS_Color(255, 255, 0),
3569 graphic->addEntity(ellipse);
3570 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3571 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3573 ellipse = new RS_Ellipse(graphic,
3574 v + Vector(750.0, 0.0),
3575 Vector((x/5+50.0)/2.0, 0.0),
3580 graphic->addEntity(ellipse);
3581 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3582 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3588 // different rotation angles:
3590 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3591 ellipse = new RS_Ellipse(graphic,
3592 Vector(rot*200, 500.0),
3593 Vector(50.0, 0.0).rotate(rot),
3597 graphic->addEntity(ellipse);
3598 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3599 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3603 // different arc angles:
3605 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3606 for (a1=0.0; a1<=2*M_PI+0.1; a1+=(M_PI/8)) {
3607 for (a2=a1+M_PI/8; a2<=2*M_PI+a1+0.1; a2+=(M_PI/8)) {
3608 ellipse = new RS_Ellipse(graphic,
3609 Vector(-500.0-a1*200.0-5000.0*rot,
3611 Vector(50.0, 0.0).rotate(rot),
3615 graphic->addEntity(ellipse);
3616 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3617 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3623 GraphicView * v = getGraphicView();
3633 void ApplicationWindow::slotTestInsertText()
3635 RS_DEBUG->print("ApplicationWindow::slotTestInsertText()");
3637 RS_Document * d = getDocument();
3641 Drawing * graphic = (Drawing *)d;
3643 if (graphic == NULL)
3647 RS_TextData textData;
3649 textData = RS_TextData(Vector(10.0, 10.0), 10.0, 100.0, RS2::VAlignTop, RS2::HAlignLeft, RS2::LeftToRight, RS2::Exact, 1.0, "Andrew", "normal", 0.0);
3650 text = new RS_Text(graphic, textData);
3651 text->setLayerToActive();
3652 text->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3653 graphic->addEntity(text);
3657 for (y=-250.0; y<=250.0; y+=50.0) {
3658 for (x=-250.0; x<=250.0; x+=50.0) {
3661 textData = RS_TextData(v,
3672 text = new RS_Text(graphic, textData);
3674 text->setLayerToActive();
3675 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3678 graphic->addEntity(text);
3683 for (x=0.0; x<M_PI*2.0; x+=0.2) {
3684 Vector v(600.0+cos(x)*50.0, 0.0+sin(x)*50.0);
3686 line = new RS_Line(graphic,
3687 RS_LineData(Vector(600.0,0.0),
3689 line->setLayerToActive();
3690 line->setPenToActive();
3691 graphic->addEntity(line);
3693 textData = RS_TextData(v,
3704 text = new RS_Text(graphic, textData);
3706 text->setLayerToActive();
3707 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3710 graphic->addEntity(text);
3713 RS_SolidData solidData = RS_SolidData(Vector(5.0, 10.0),
3715 Vector(15.0, 30.0));
3717 RS_Solid* s = new RS_Solid(graphic, solidData);
3719 s->setLayerToActive();
3720 s->setPen(RS_Pen(RS_Color(255, 255, 0),
3723 graphic->addEntity(s);
3725 GraphicView* v = getGraphicView();
3736 void ApplicationWindow::slotTestInsertImage()
3738 RS_DEBUG->print("ApplicationWindow::slotTestInsertImage()");
3740 RS_Document * d = getDocument();
3744 Drawing * graphic = (Drawing *)d;
3746 if (graphic == NULL)
3750 RS_ImageData imageData;
3752 imageData = RS_ImageData(0, Vector(50.0, 30.0), Vector(0.5, 0.5), Vector(-0.5, 0.5), Vector(640, 480), "/home/andrew/data/image.png", 50, 50, 0);
3753 image = new RS_Image(graphic, imageData);
3755 image->setLayerToActive();
3756 image->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3757 graphic->addEntity(image);
3764 void ApplicationWindow::slotTestUnicode()
3766 RS_DEBUG->print("ApplicationWindow::slotTestUnicode()");
3768 slotFileOpen("./fonts/unicode.cxf", RS2::FormatCXF);
3769 RS_Document* d = getDocument();
3771 Drawing* graphic = (Drawing*)d;
3772 if (graphic==NULL) {
3780 QChar uCode; // e.g. 65 (or 'A')
3781 QString strCode; // unicde as string e.g. '[0041] A'
3783 graphic->setAutoUpdateBorders(false);
3785 for (col=0x0000; col<=0xFFF0; col+=0x10) {
3786 printf("col: %X\n", col);
3787 for (row=0x0; row<=0xF; row++) {
3788 //printf(" row: %X\n", row);
3790 uCode = QChar(col+row);
3791 //printf(" code: %X\n", uCode.unicode());
3793 strCode.setNum(uCode.unicode(), 16);
3794 while (strCode.length()<4) {
3795 strCode="0"+strCode;
3797 strCode = "[" + strCode + "] " + uCode;
3799 if (graphic->findBlock(strCode)!=NULL) {
3800 RS_InsertData d(strCode,
3801 Vector(col/0x10*20.0,row*20.0),
3802 Vector(1.0,1.0), 0.0,
3803 1, 1, Vector(0.0, 0.0),
3804 NULL, RS2::NoUpdate);
3805 ins = new RS_Insert(graphic, d);
3806 ins->setLayerToActive();
3807 ins->setPen(RS_Pen(RS_Color(255, 255, 255),
3811 graphic->addEntity(ins);
3815 graphic->setAutoUpdateBorders(true);
3816 graphic->calculateBorders();
3823 void ApplicationWindow::slotTestMath01()
3825 RS_DEBUG->print("ApplicationWindow::slotTestMath01()");
3827 RS_Document* d = getDocument();
3829 Drawing* graphic = (Drawing*)d;
3830 if (graphic==NULL) {
3835 graphic->addEntity(new RS_Line(graphic,
3836 RS_LineData(Vector(0.0,0.0),
3837 Vector(2*M_PI,0.0))));
3838 graphic->addEntity(new RS_Line(graphic,
3839 RS_LineData(Vector(0.0,-1.0),
3844 double x = 59.0/ARAD;
3845 double x_0 = 60.0/ARAD;
3846 for (a=0.01; a<2*M_PI; a+=0.01) {
3848 RS_Line* line = new RS_Line(graphic,
3849 RS_LineData(Vector(a-0.01, cos(a-0.01)),
3850 Vector(a, cos(a))));
3851 graphic->addEntity(line);
3854 graphic->addEntity(new RS_Line(graphic,
3855 RS_LineData(Vector(a-0.01,cos(x_0)-sin(x_0)*(a-0.01-x_0)),
3856 Vector(a,cos(x_0)-sin(x_0)*(a-x_0)))));
3860 graphic->addEntity(new RS_Line(graphic,
3861 RS_LineData(Vector(x,0.0),
3865 graphic->addEntity(new RS_Line(graphic,
3866 RS_LineData(Vector(x_0,0.0),
3870 //graphic->addEntity(new RS_Line(graphic,
3871 // Vector(0.0,cos(x_0)-sin(x_0)*(0.0-x_0)),
3872 // Vector(6.0,cos(x_0)-sin(x_0)*(6.0-x_0))));
3875 GraphicView* v = getGraphicView();
3885 void ApplicationWindow::slotTestResize640()
3887 RS_DEBUG->print("ApplicationWindow::slotTestResize640()");
3895 void ApplicationWindow::slotTestResize800()
3897 RS_DEBUG->print("ApplicationWindow::slotTestResize800()");
3905 void ApplicationWindow::slotTestResize1024()
3907 RS_DEBUG->print("ApplicationWindow::slotTestResize1024()");
3913 * overloaded for Message box on last window exit.
3915 bool ApplicationWindow::queryExit(bool force)
3917 RS_DEBUG->print("ApplicationWindow::queryExit()");
3924 QMessageBox::information(this, QMessageBox::tr("Warning"),
3925 tr("This is a %1 version "
3926 "which terminates\n"
3927 "automatically after 10min. This software is\n"
3928 "not intended for production use. Please buy\n"
3929 "a full version of the application from\n%2.\n"
3930 "You can save your work now.")
3931 //FAIL .arg(QC_APPNAME)
3932 .arg("Architektonas")
3933 #ifdef QC_CUSTOM_VENDOR
3934 .arg(QC_CUSTOM_VENDOR),
3936 .arg("RibbonSoft, http://www.ribbonsoft.com"),
3941 QList<QMdiSubWindow *> list = workspace->subWindowList();
3943 // for(QWidget * w=list.first(); w!=NULL; w=list.next())
3944 for(int i=0; i<list.size(); i++)
3946 succ = ((MDIWindow *)list[i])->closeMDI(force);
3955 RS_DEBUG->print("ApplicationWindow::queryExit(): OK");
3961 * Handle hotkeys. Don't let it to the default handler of Qt.
3962 * it will consume them also if a text field is active
3963 * which means it's impossible to enter a command.
3965 void ApplicationWindow::keyPressEvent(QKeyEvent * e)
3967 #warning "!!! keyPressEvent(): Do we need this anymore? !!!"
3969 static QTime ts = QTime();
3970 static QString firstKey = "";
3972 // single key codes:
3976 case Qt::Key_Control:
3979 case Qt::Key_CapsLock:
3981 QMainWindow::keyPressEvent(e);
3983 // forward to actions:
3984 GraphicView * graphicView = getGraphicView();
3987 graphicView->keyPressEvent(e);
3993 case Qt::Key_Escape:
3999 case Qt::Key_Return:
4000 if (firstKey.isEmpty())
4008 if (firstKey.isEmpty())
4010 actionHandler->slotZoomIn();
4016 if (firstKey.isEmpty())
4018 actionHandler->slotZoomOut();
4028 if (e->isAccepted())
4031 QTime now = QTime::currentTime();
4034 if (ts.msecsTo(now) < 2000)
4036 QString code = QString("%1%2").arg(firstKey).arg(QChar(e->key())).toLower();
4038 if (actionHandler->keycode(code) == false)
4042 if (QChar(e->key()).isPrint())
4043 firstKey += e->key();
4052 if (QChar(e->key()).isPrint())
4053 firstKey = e->key();
4056 // Q3MainWindow::keyPressEvent(e);
4057 QMainWindow::keyPressEvent(e);
4060 void ApplicationWindow::keyReleaseEvent(QKeyEvent * e)
4065 case Qt::Key_Control:
4068 case Qt::Key_CapsLock:
4070 // Q3MainWindow::keyReleaseEvent(e);
4071 QMainWindow::keyReleaseEvent(e);
4073 // forward to actions:
4074 GraphicView * graphicView = getGraphicView();
4077 graphicView->keyReleaseEvent(e);
4084 // Q3MainWindow::keyPressEvent(e);
4085 QMainWindow::keyPressEvent(e);
4089 * @return Pointer to application window.
4091 /*static*/ ApplicationWindow * ApplicationWindow::getAppWindow()
4097 * @return Pointer to workspace.
4099 QMdiArea * ApplicationWindow::getWorkspace()
4105 * @return Pointer to the currently active MDI Window or NULL if no
4106 * MDI Window is active.
4108 MDIWindow * ApplicationWindow::getMDIWindow()
4110 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::getMDIWindow: workspace=%08X", workspace);
4114 RS_DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=%08X", workspace->activeSubWindow());
4115 return (MDIWindow *)workspace->activeSubWindow();
4118 RS_DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=??? (workspace == NULL)");
4123 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4125 * @return Pointer to the graphic view of the currently active document
4126 * window or NULL if no window is available.
4128 /*virtual*/ GraphicView * ApplicationWindow::getGraphicView()
4130 MDIWindow * m = getMDIWindow();
4132 return (m ? m->getGraphicView() : NULL);
4136 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4138 * @return Pointer to the graphic document of the currently active document
4139 * window or NULL if no window is available.
4141 /*virtual*/ RS_Document * ApplicationWindow::getDocument()
4143 MDIWindow * m = getMDIWindow();
4145 return (m ? m->getDocument() : NULL);
4149 * Creates a new document. Implementation from RS_MainWindowInterface.
4151 /*virtual*/ void ApplicationWindow::createNewDocument(const QString & fileName/*= QString::null*/,
4152 RS_Document * doc/*= NULL*/)
4156 if (fileName != QString::null && getDocument())
4157 getDocument()->setFilename(fileName);
4161 * Implementation from QG_MainWindowInterface.
4163 * @return Pointer to this.
4165 /*virtual*/ QMainWindow * ApplicationWindow::GetMainWindow()
4171 * @return Pointer to action handler. Implementation from QG_MainWindowInterface.
4173 /*virtual*/ QG_ActionHandler * ApplicationWindow::getActionHandler()
4175 return actionHandler;
4179 * Implementation from QG_MainWindowInterface.
4181 /*virtual*/ void ApplicationWindow::showSimulationControls()
4184 simulationDockWindow->show();
4190 * @return Pointer to the qsa object.
4192 QSProject * ApplicationWindow::getQSAProject()
4194 if (scripter != NULL)
4195 return scripter->getQSAProject();
4202 * Implementation from QG_MainWindowInterface.
4204 /*virtual*/ void ApplicationWindow::setFocus2()