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 "cadtoolbar.h"
52 #include "cadtoolbarmain.h"
53 #include "coordinatewidget.h"
54 #include "dlgimageoptions.h"
55 #include "mousewidget.h"
56 #include "selectionwidget.h"
58 #include "mdiwindow.h"
59 #include "qc_dialogfactory.h"
60 #include "createqtactions.h"
63 ApplicationWindow * ApplicationWindow::appWindow = NULL;
66 # define QC_APP_ICON "qcad.png"
69 # define QC_APP_ICON16 "qcad16.png"
72 extern QSplashScreen * splash;
75 * Constructor. Initializes the app.
77 ApplicationWindow::ApplicationWindow():
78 // Q3MainWindow(0, "", Qt::WDestructiveClose), QG_MainWindowInterface()
79 QMainWindow((QWidget *)NULL/*,this is not a Qt::WindowFlags --> Qt::WA_DeleteOnClose*/), QG_MainWindowInterface()
81 RS_DEBUG->print("ApplicationWindow::ApplicationWindow");
84 //no assistant = NULL;
87 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: setting icon");
88 // setIcon(qPixmapFromMimeSource(QC_APP_ICON));
89 // setWindowIcon(qPixmapFromMimeSource(QC_APP_ICON));
90 setWindowIcon(QIcon(":/res/" QC_APP_ICON));
92 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler");
93 actionHandler = new QG_ActionHandler(this);
94 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler: OK");
97 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating scripter");
98 scripter = new QS_Scripter(this, this);
99 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating scripter: OK");
102 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init view");
104 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init toolbar");
106 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init actions");
108 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init menu bar");
110 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init status bar");
113 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory");
114 dialogFactory = new QC_DialogFactory(this, optionWidget);
115 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory: OK");
116 RS_DEBUG->print("setting dialog factory object");
118 if (RS_DialogFactory::instance() == NULL)
119 RS_DEBUG->print("no RS_DialogFactory instance");
121 RS_DEBUG->print("got RS_DialogFactory instance");
123 RS_DialogFactory::instance()->setFactoryObject(dialogFactory);
124 RS_DEBUG->print("setting dialog factory object: OK");
126 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init settings");
129 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init MDI");
132 // Disable menu and toolbar items
133 emit windowsChanged(FALSE);
135 //FAIL statusBar()->showMessage(QC_APPNAME " Ready", 2000);
136 statusBar()->showMessage("Architektonas Ready", 2000);
137 //setFocusPolicy(WheelFocus);
143 ApplicationWindow::~ApplicationWindow()
145 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow");
147 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting scripter");
149 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting scripter: OK");
152 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting action handler");
153 delete actionHandler;
154 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting action handler: OK");
156 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory");
157 delete dialogFactory;
158 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory: OK");
160 //no RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: "
161 // "deleting assistant..");
162 // if (assistant!=NULL) {
165 // RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: "
166 // "deleting assistant: OK");
167 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: OK");
171 * Runs the start script if scripting is available.
173 void ApplicationWindow::slotRunStartScript()
175 slotRunScript("autostart.qs");
179 * Runs a script. The action that triggers this slot has to carry the
180 * name of the script file.
182 void ApplicationWindow::slotRunScript()
184 RS_DEBUG->print("ApplicationWindow::slotRunScript");
186 const QObject * s = sender();
190 QString script = ((QAction *)s)->text();
191 RS_DEBUG->print("ApplicationWindow::slotRunScript: %s", script.toLatin1().data());
192 slotRunScript(script);
197 * Runs the script with the given name.
199 void ApplicationWindow::slotRunScript(const QString & name)
202 RS_DEBUG->print("ApplicationWindow::slotRunScript");
204 if (scripter == NULL)
206 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotRunScript: scripter not initialized");
210 statusBar()->showMessage(tr("Running script '%1'").arg(name), 2000);
212 QStringList scriptList = RS_SYSTEM->getScriptList();
213 scriptList.append(RS_SYSTEM->getHomeDir() + "/.qcad/" + name);
215 for (QStringList::Iterator it = scriptList.begin(); it!=scriptList.end(); ++it)
217 RS_DEBUG->print("ApplicationWindow::slotRunScript: checking script '%s'", (*it).toLatin1().data();
220 if (fi.exists() && fi.fileName() == name)
222 RS_DEBUG->print("ApplicationWindow::slotRunScript: running '%s'", (*it).toLatin1().data());
223 scripter->runScript(*it, "main");
230 * Called from toolbar buttons that were added by scripts to
233 void ApplicationWindow::slotInsertBlock()
235 const QObject * s = sender();
239 QString block = ((QAction *)s)->text();
240 RS_DEBUG->print("ApplicationWindow::slotInsertBlock: %s", block.toLatin1().data());
241 slotInsertBlock(block);
246 * Called to insert blocks.
248 void ApplicationWindow::slotInsertBlock(const QString & name)
250 RS_DEBUG->print("ApplicationWindow::slotInsertBlock: '%s'", name.toLatin1().data());
252 statusBar()->showMessage(tr("Inserting block '%1'").arg(name), 2000);
254 RS_GraphicView * graphicView = getGraphicView();
255 RS_Document * document = getDocument();
257 if (graphicView != NULL && document != NULL)
259 RS_ActionLibraryInsert * action = new RS_ActionLibraryInsert(*document, *graphicView);
260 action->setFile(name);
261 graphicView->setCurrentAction(action);
266 * Shows the main application window and a splash screen.
268 void ApplicationWindow::show()
270 #ifdef QSPLASHSCREEN_H
277 #ifdef QSPLASHSCREEN_H
281 qApp->processEvents();
282 splash->clearMessage();
283 # ifdef QC_DELAYED_SPLASH_SCREEN
284 QTimer::singleShot(1000 * 2, this, SLOT(finishSplashScreen()));
286 finishSplashScreen();
293 * Called when the splash screen has to terminate.
295 void ApplicationWindow::finishSplashScreen()
297 #ifdef QSPLASHSCREEN_H
300 splash->finish(this);
308 * Close Event. Called when the user tries to close the app.
310 void ApplicationWindow::closeEvent(QCloseEvent * /*ce*/)
312 RS_DEBUG->print("ApplicationWindow::closeEvent()");
314 RS_DEBUG->print("ApplicationWindow::closeEvent(): OK");
318 * Handles right-clicks for moving back to the last cad tool bar.
320 void ApplicationWindow::mouseReleaseEvent(QMouseEvent * e)
322 if (e->button() == Qt::RightButton && cadToolBar != NULL)
323 cadToolBar->showToolBarMain();
329 * Initializes the MDI workspace.
331 void ApplicationWindow::initMDI()
333 RS_DEBUG->print("ApplicationWindow::initMDI() begin");
335 /* Could use QVBoxLayout instead of Q3VBox, but do we even need to? */
336 // Q3VBox * vb = new Q3VBox(this);
337 // vb->setFrameStyle(Q3Frame::StyledPanel | Q3Frame::Sunken);
338 // workspace = new QMdiArea(vb);
339 workspace = new QMdiArea(this);
340 // workspace->setScrollBarsEnabled(true);
341 // setCentralWidget(vb);
342 setCentralWidget(workspace);//JLH:hmm. (Yes, it works! \o/)
343 RS_DEBUG->print("ApplicationWindow::initMDI(): workspace=%08X", workspace);
345 //#warning "Object::connect: No such signal QMdiArea::windowActivated(QWidget *)"
346 // connect(workspace, SIGNAL(windowActivated(QWidget *)), this, SLOT(slotWindowActivated(QWidget *)));
347 connect(workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this,
348 SLOT(slotWindowActivated(QMdiSubWindow *)));
350 RS_DEBUG->print("ApplicationWindow::initMDI() end");
354 * Initializes all QActions of the application.
355 * (Actually, it creates all application menus & toolbars. All actions are
356 * created in CreateQtActions() and simply referenced here.)
358 void ApplicationWindow::initActions()
360 RS_DEBUG->print("ApplicationWindow::initActions()");
361 CreateQtActions(this);
366 QMenu * menu = new QMenu(tr("&File"), this);
367 QToolBar * tb = fileToolBar;
368 tb->setWindowTitle("File");
369 // tb->setCloseMode(Q3DockWindow::Undocked);
371 menu->addAction(actionFileNew);
372 tb->addAction(actionFileNew);
373 connect(actionFileNew, SIGNAL(activated()), this, SLOT(slotFileNew()));
374 menu->addAction(actionFileOpen);
375 tb->addAction(actionFileOpen);
376 connect(actionFileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen()));
377 menu->addAction(actionFileSave);
378 tb->addAction(actionFileSave);
379 connect(actionFileSave, SIGNAL(activated()), this, SLOT(slotFileSave()));
380 connect(this, SIGNAL(windowsChanged(bool)), actionFileSave, SLOT(setEnabled(bool)));
381 menu->addAction(actionFileSaveAs);
382 connect(actionFileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs()));
383 connect(this, SIGNAL(windowsChanged(bool)), actionFileSaveAs, SLOT(setEnabled(bool)));
384 menu->addAction(actionFileExport);
385 connect(actionFileExport, SIGNAL(activated()), this, SLOT(slotFileExport()));
386 connect(this, SIGNAL(windowsChanged(bool)), actionFileExport, SLOT(setEnabled(bool)));
388 menu->addSeparator();
390 menu->addAction(actionFileClose);
391 connect(actionFileClose, SIGNAL(activated()), this, SLOT(slotFileClose()));
392 connect(this, SIGNAL(windowsChanged(bool)), actionFileClose, SLOT(setEnabled(bool)));
394 menu->addSeparator();
396 menu->addAction(actionFilePrint);
397 tb->addAction(actionFilePrint);
398 connect(actionFilePrint, SIGNAL(activated()), this, SLOT(slotFilePrint()));
399 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrint, SLOT(setEnabled(bool)));
400 menu->addAction(actionFilePrintPreview);
401 tb->addAction(actionFilePrintPreview);
402 connect(actionFilePrintPreview, SIGNAL(toggled(bool)), this, SLOT(slotFilePrintPreview(bool)));
403 connect(this, SIGNAL(printPreviewChanged(bool)), actionFilePrintPreview, SLOT(setOn(bool)));
404 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrintPreview, SLOT(setEnabled(bool)));
406 menu->addSeparator();
408 menu->addAction(actionFileQuit);
409 connect(actionFileQuit, SIGNAL(activated()), this, SLOT(slotFileQuit()));
411 menu->addSeparator();
413 menuBar()->addMenu(menu);
414 addToolBar(Qt::TopToolBarArea, tb);
420 menu = new QMenu(tr("&Edit"), this);
422 tb->setWindowTitle("Edit");
423 // tb->setCloseMode(Q3DockWindow::Undocked);
425 // action = actionFactory.createAction(RS2::ActionEditUndo, actionHandler);
426 menu->addAction(actionEditUndo);
427 tb->addAction(actionEditUndo);
428 connect(actionEditUndo, SIGNAL(activated()), actionHandler, SLOT(slotEditUndo()));
429 connect(this, SIGNAL(windowsChanged(bool)), actionEditUndo, SLOT(setEnabled(bool)));
430 // action = actionFactory.createAction(RS2::ActionEditRedo, actionHandler);
431 menu->addAction(actionEditRedo);
432 tb->addAction(actionEditRedo);
433 connect(actionEditRedo, SIGNAL(activated()), actionHandler, SLOT(slotEditRedo()));
434 connect(this, SIGNAL(windowsChanged(bool)), actionEditRedo, SLOT(setEnabled(bool)));
437 menu->addSeparator();
439 // action = actionFactory.createAction(RS2::ActionEditCut, actionHandler);
440 menu->addAction(actionEditCut);
441 tb->addAction(actionEditCut);
442 connect(actionEditCut, SIGNAL(activated()), actionHandler, SLOT(slotEditCut()));
443 connect(this, SIGNAL(windowsChanged(bool)), actionEditCut, SLOT(setEnabled(bool)));
444 // action = actionFactory.createAction(RS2::ActionEditCopy, actionHandler);
445 menu->addAction(actionEditCopy);
446 tb->addAction(actionEditCopy);
447 connect(actionEditCopy, SIGNAL(activated()), actionHandler, SLOT(slotEditCopy()));
448 connect(this, SIGNAL(windowsChanged(bool)), actionEditCopy, SLOT(setEnabled(bool)));
449 // action = actionFactory.createAction(RS2::ActionEditPaste, actionHandler);
450 menu->addAction(actionEditPaste);
451 tb->addAction(actionEditPaste);
452 connect(actionEditPaste, SIGNAL(activated()), actionHandler, SLOT(slotEditPaste()));
453 connect(this, SIGNAL(windowsChanged(bool)), actionEditPaste, SLOT(setEnabled(bool)));
455 menu->addSeparator();
457 menu->addAction(actionOptionsGeneral);
458 connect(actionOptionsGeneral, SIGNAL(activated()), this, SLOT(slotOptionsGeneral()));
459 menu->addAction(actionOptionsDrawing);
460 connect(actionOptionsDrawing, SIGNAL(activated()), actionHandler, SLOT(slotOptionsDrawing()));
461 connect(this, SIGNAL(windowsChanged(bool)), actionOptionsDrawing, SLOT(setEnabled(bool)));
463 menuBar()->addMenu(menu);
464 addToolBar(Qt::TopToolBarArea, tb);
468 //menu = new QPopupMenu(this);
469 //menuBar()->insertItem(tr("&Options"), menu);
471 // Viewing / Zooming actions:
473 // menu = new Q3PopupMenu(this);
474 menu = new QMenu(tr("&View"), this);
475 //obsolete: menu->setCheckable(true);
477 tb->setWindowTitle("View");
478 // tb->setCloseMode(Q3DockWindow::Undocked);
480 // action = actionFactory.createAction(RS2::ActionViewGrid, this);
481 menu->addAction(actionViewGrid);
482 tb->addAction(actionViewGrid);
483 actionViewGrid->setChecked(true);
484 connect(actionViewGrid, SIGNAL(toggled(bool)), this, SLOT(slotViewGrid(bool)));
485 connect(this, SIGNAL(gridChanged(bool)), actionViewGrid, SLOT(setOn(bool)));
486 connect(this, SIGNAL(windowsChanged(bool)), actionViewGrid, SLOT(setEnabled(bool)));
488 settings.beginGroup("Appearance");
489 bool draftMode = settings.value("DraftMode", false).toBool();
492 // action = actionFactory.createAction(RS2::ActionViewDraft, this);
493 menu->addAction(actionViewDraft);
494 tb->addAction(actionViewDraft);
495 actionViewDraft->setChecked(draftMode);
496 connect(actionViewDraft, SIGNAL(toggled(bool)), this, SLOT(slotViewDraft(bool)));
497 connect(this, SIGNAL(draftChanged(bool)), actionViewDraft, SLOT(setOn(bool)));
498 connect(this, SIGNAL(windowsChanged(bool)), actionViewDraft, SLOT(setEnabled(bool)));
501 action = actionFactory.createAction(RS2::ActionViewLayerList, this);
503 action->setChecked(true);
504 action = actionFactory.createAction(RS2::ActionViewBlockList, this);
506 action->setChecked(true);
507 action = actionFactory.createAction(RS2::ActionViewOptionToolbar, this);
509 action->setChecked(true);
510 action = actionFactory.createAction(RS2::ActionViewCommandLine, this);
512 action->setChecked(true);*/
514 // action = actionFactory.createAction(RS2::ActionZoomRedraw, actionHandler);
515 menu->addAction(actionZoomRedraw);
516 tb->addAction(actionZoomRedraw);
517 connect(actionZoomRedraw, SIGNAL(activated()), actionHandler, SLOT(slotZoomRedraw()));
518 connect(this, SIGNAL(windowsChanged(bool)), actionZoomRedraw, SLOT(setEnabled(bool)));
519 // action = actionFactory.createAction(RS2::ActionZoomIn, actionHandler);
520 menu->addAction(actionZoomIn);
521 tb->addAction(actionZoomIn);
522 connect(actionZoomIn, SIGNAL(activated()), actionHandler, SLOT(slotZoomIn()));
523 connect(this, SIGNAL(windowsChanged(bool)), actionZoomIn, SLOT(setEnabled(bool)));
524 // action = actionFactory.createAction(RS2::ActionZoomOut, actionHandler);
525 menu->addAction(actionZoomOut);
526 tb->addAction(actionZoomOut);
527 connect(actionZoomOut, SIGNAL(activated()), actionHandler, SLOT(slotZoomOut()));
528 connect(this, SIGNAL(windowsChanged(bool)), actionZoomOut, SLOT(setEnabled(bool)));
529 // action = actionFactory.createAction(RS2::ActionZoomAuto, actionHandler);
530 menu->addAction(actionZoomAuto);
531 tb->addAction(actionZoomAuto);
532 connect(actionZoomAuto, SIGNAL(activated()), actionHandler, SLOT(slotZoomAuto()));
533 connect(this, SIGNAL(windowsChanged(bool)), actionZoomAuto, SLOT(setEnabled(bool)));
534 // action = actionFactory.createAction(RS2::ActionZoomPrevious, actionHandler);
535 menu->addAction(actionZoomPrevious);
536 tb->addAction(actionZoomPrevious);
537 connect(actionZoomPrevious, SIGNAL(activated()), actionHandler, SLOT(slotZoomPrevious()));
538 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPrevious, SLOT(setEnabled(bool)));
539 // action = actionFactory.createAction(RS2::ActionZoomWindow, actionHandler);
540 menu->addAction(actionZoomWindow);
541 tb->addAction(actionZoomWindow);
542 connect(actionZoomWindow, SIGNAL(activated()), actionHandler, SLOT(slotZoomWindow()));
543 connect(this, SIGNAL(windowsChanged(bool)), actionZoomWindow, SLOT(setEnabled(bool)));
544 // action = actionFactory.createAction(RS2::ActionZoomPan, actionHandler);
545 menu->addAction(actionZoomPan);
546 tb->addAction(actionZoomPan);
547 connect(actionZoomPan, SIGNAL(activated()), actionHandler, SLOT(slotZoomPan()));
548 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPan, SLOT(setEnabled(bool)));
550 menu->addSeparator();
552 // action = actionFactory.createAction(RS2::ActionViewStatusBar, this);
553 menu->addAction(actionViewStatusbar);
554 actionViewStatusbar->setChecked(true);
555 connect(actionViewStatusbar, SIGNAL(toggled(bool)), this, SLOT(slotViewStatusBar(bool)));
558 menu->insertItem(tr("Vie&ws"), createDockWindowMenu(NoToolBars));
559 menu->insertItem(tr("Tool&bars"), createDockWindowMenu(OnlyToolBars));
561 //Actually, this isn't really needed... This crap is maintained by Qt...
562 //#warning "!!! More stuff to port to Qt4 !!!"
565 menu->addAction(actionFocusCommandLine);
566 connect(actionFocusCommandLine, SIGNAL(activated()), this, SLOT(slotFocusCommandLine()));
567 connect(this, SIGNAL(windowsChanged(bool)), actionFocusCommandLine, SLOT(setEnabled(bool)));
568 menuBar()->addMenu(menu);
569 //addToolBar(tb, tr("View"));
570 // addDockWindow(tb, tr("View"), Qt::DockTop);
571 addToolBar(Qt::TopToolBarArea, tb);
573 // Selecting actions:
575 menu = new QMenu(tr("&Select"), this);
576 // action = actionFactory.createAction(RS2::ActionDeselectAll, actionHandler);
577 menu->addAction(actionDeselectAll);
578 connect(actionDeselectAll, SIGNAL(activated()), actionHandler, SLOT(slotDeselectAll()));
579 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectAll, SLOT(setEnabled(bool)));
580 // action = actionFactory.createAction(RS2::ActionSelectAll, actionHandler);
581 menu->addAction(actionSelectAll);
582 connect(actionSelectAll, SIGNAL(activated()), actionHandler, SLOT(slotSelectAll()));
583 connect(this, SIGNAL(windowsChanged(bool)), actionSelectAll, SLOT(setEnabled(bool)));
584 // action = actionFactory.createAction(RS2::ActionSelectSingle, actionHandler);
585 menu->addAction(actionSelectSingle);
586 connect(actionSelectSingle, SIGNAL(activated()), actionHandler, SLOT(slotSelectSingle()));
587 connect(this, SIGNAL(windowsChanged(bool)), actionSelectSingle, SLOT(setEnabled(bool)));
588 // action = actionFactory.createAction(RS2::ActionSelectContour, actionHandler);
589 menu->addAction(actionSelectContour);
590 connect(actionSelectContour, SIGNAL(activated()), actionHandler, SLOT(slotSelectContour()));
591 connect(this, SIGNAL(windowsChanged(bool)), actionSelectContour, SLOT(setEnabled(bool)));
592 // action = actionFactory.createAction(RS2::ActionDeselectWindow, actionHandler);
593 menu->addAction(actionDeselectWindow);
594 connect(actionDeselectWindow, SIGNAL(activated()), actionHandler, SLOT(slotDeselectWindow()));
595 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectWindow, SLOT(setEnabled(bool)));
596 // action = actionFactory.createAction(RS2::ActionSelectWindow, actionHandler);
597 menu->addAction(actionSelectWindow);
598 connect(actionSelectWindow, SIGNAL(activated()), actionHandler, SLOT(slotSelectWindow()));
599 connect(this, SIGNAL(windowsChanged(bool)), actionSelectWindow, SLOT(setEnabled(bool)));
600 // action = actionFactory.createAction(RS2::ActionSelectInvert, actionHandler);
601 menu->addAction(actionSelectInvert);
602 connect(actionSelectInvert, SIGNAL(activated()), actionHandler, SLOT(slotSelectInvert()));
603 connect(this, SIGNAL(windowsChanged(bool)), actionSelectInvert, SLOT(setEnabled(bool)));
604 // action = actionFactory.createAction(RS2::ActionSelectIntersected, actionHandler);
605 menu->addAction(actionSelectIntersected);
606 connect(actionSelectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotSelectIntersected()));
607 connect(this, SIGNAL(windowsChanged(bool)), actionSelectIntersected, SLOT(setEnabled(bool)));
608 // action = actionFactory.createAction(RS2::ActionDeselectIntersected, actionHandler);
609 menu->addAction(actionDeselectIntersected);
610 connect(actionDeselectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotDeselectIntersected()));
611 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectIntersected, SLOT(setEnabled(bool)));
612 // action = actionFactory.createAction(RS2::ActionSelectLayer, actionHandler);
613 menu->addAction(actionSelectLayer);
614 connect(actionSelectLayer, SIGNAL(activated()), actionHandler, SLOT(slotSelectLayer()));
615 connect(this, SIGNAL(windowsChanged(bool)), actionSelectLayer, SLOT(setEnabled(bool)));
616 menuBar()->addMenu(menu);
620 menu = new QMenu(tr("&Draw"), this);
623 QMenu * subMenu = new QMenu(tr("&Point"), this);
624 // action = actionFactory.createAction(RS2::ActionDrawPoint, actionHandler);
625 subMenu->addAction(actionDrawPoint);
626 connect(actionDrawPoint, SIGNAL(activated()), actionHandler, SLOT(slotDrawPoint()));
627 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPoint, SLOT(setEnabled(bool)));
628 menu->addMenu(subMenu);
631 subMenu = new QMenu(tr("&Line"), this);
632 // action = actionFactory.createAction(RS2::ActionDrawLine, actionHandler);
633 subMenu->addAction(actionDrawLine);
634 connect(actionDrawLine, SIGNAL(activated()), actionHandler, SLOT(slotDrawLine()));
635 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLine, SLOT(setEnabled(bool)));
636 // action = actionFactory.createAction(RS2::ActionDrawLineAngle, actionHandler);
637 subMenu->addAction(actionDrawLineAngle);
638 connect(actionDrawLineAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineAngle()));
639 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineAngle, SLOT(setEnabled(bool)));
640 // action = actionFactory.createAction(RS2::ActionDrawLineHorizontal, actionHandler);
641 subMenu->addAction(actionDrawLineHorizontal);
642 connect(actionDrawLineHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineHorizontal()));
643 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineHorizontal, SLOT(setEnabled(bool)));
644 // action = actionFactory.createAction(RS2::ActionDrawLineVertical, actionHandler);
645 subMenu->addAction(actionDrawLineVertical);
646 connect(actionDrawLineVertical, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineVertical()));
647 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineVertical, SLOT(setEnabled(bool)));
648 // action = actionFactory.createAction(RS2::ActionDrawLineRectangle, actionHandler);
649 subMenu->addAction(actionDrawLineRectangle);
650 connect(actionDrawLineRectangle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRectangle()));
651 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRectangle, SLOT(setEnabled(bool)));
652 // action = actionFactory.createAction(RS2::ActionDrawLineParallel, actionHandler);
653 subMenu->addAction(actionDrawLineParallel);
654 connect(actionDrawLineParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallel()));
655 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallel, SLOT(setEnabled(bool)));
656 // action = actionFactory.createAction(RS2::ActionDrawLineParallelThrough, actionHandler);
657 subMenu->addAction(actionDrawLineParallelThrough);
658 connect(actionDrawLineParallelThrough, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallelThrough()));
659 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallelThrough, SLOT(setEnabled(bool)));
660 // action = actionFactory.createAction(RS2::ActionDrawLineBisector, actionHandler);
661 subMenu->addAction(actionDrawLineBisector);
662 connect(actionDrawLineBisector, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineBisector()));
663 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineBisector, SLOT(setEnabled(bool)));
664 // action = actionFactory.createAction(RS2::ActionDrawLineTangent1, actionHandler);
665 subMenu->addAction(actionDrawLineTangent1);
666 connect(actionDrawLineTangent1, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent1()));
667 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent1, SLOT(setEnabled(bool)));
668 // action = actionFactory.createAction(RS2::ActionDrawLineTangent2, actionHandler);
669 subMenu->addAction(actionDrawLineTangent2);
670 connect(actionDrawLineTangent2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent2()));
671 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent2, SLOT(setEnabled(bool)));
672 // action = actionFactory.createAction(RS2::ActionDrawLineOrthogonal, actionHandler);
673 subMenu->addAction(actionDrawLineOrthogonal);
674 connect(actionDrawLineOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineOrthogonal()));
675 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineOrthogonal, SLOT(setEnabled(bool)));
676 // action = actionFactory.createAction(RS2::ActionDrawLineRelAngle, actionHandler);
677 subMenu->addAction(actionDrawLineRelAngle);
678 connect(actionDrawLineRelAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRelAngle()));
679 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRelAngle, SLOT(setEnabled(bool)));
680 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon, actionHandler);
681 subMenu->addAction(actionDrawLinePolygon);
682 connect(actionDrawLinePolygon, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon()));
683 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon, SLOT(setEnabled(bool)));
684 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon2, actionHandler);
685 subMenu->addAction(actionDrawLinePolygon2);
686 connect(actionDrawLinePolygon2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon2()));
687 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon2, SLOT(setEnabled(bool)));
688 // action = actionFactory.createAction(RS2::ActionDrawLineFree, actionHandler);
689 subMenu->addAction(actionDrawLineFree);
690 connect(actionDrawLineFree, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineFree()));
691 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineFree, SLOT(setEnabled(bool)));
692 menu->addMenu(subMenu);
695 subMenu = new QMenu(tr("&Arc"), this);
696 subMenu->addAction(actionDrawArc);
697 connect(actionDrawArc, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc()));
698 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc, SLOT(setEnabled(bool)));
699 subMenu->addAction(actionDrawArc3P);
700 connect(actionDrawArc3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc3P()));
701 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc3P, SLOT(setEnabled(bool)));
702 subMenu->addAction(actionDrawArcParallel);
703 connect(actionDrawArcParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcParallel()));
704 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcParallel, SLOT(setEnabled(bool)));
705 subMenu->addAction(actionDrawArcTangential);
706 connect(actionDrawArcTangential, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcTangential()));
707 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcTangential, SLOT(setEnabled(bool)));
708 menu->addMenu(subMenu);
711 subMenu = new QMenu(tr("&Circle"), this);
712 // action = actionFactory.createAction(RS2::ActionDrawCircle, actionHandler);
713 subMenu->addAction(actionDrawCircle);
714 connect(actionDrawCircle, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle()));
715 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle, SLOT(setEnabled(bool)));
716 // action = actionFactory.createAction(RS2::ActionDrawCircleCR, actionHandler);
717 subMenu->addAction(actionDrawCircleCR);
718 connect(actionDrawCircleCR, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleCR()));
719 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleCR, SLOT(setEnabled(bool)));
720 // action = actionFactory.createAction(RS2::ActionDrawCircle2P, actionHandler);
721 subMenu->addAction(actionDrawCircle2P);
722 connect(actionDrawCircle2P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle2P()));
723 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle2P, SLOT(setEnabled(bool)));
724 // action = actionFactory.createAction(RS2::ActionDrawCircle3P, actionHandler);
725 subMenu->addAction(actionDrawCircle3P);
726 connect(actionDrawCircle3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle3P()));
727 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle3P, SLOT(setEnabled(bool)));
728 // action = actionFactory.createAction(RS2::ActionDrawCircleParallel, actionHandler);
729 subMenu->addAction(actionDrawCircleParallel);
730 connect(actionDrawCircleParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleParallel()));
731 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleParallel, SLOT(setEnabled(bool)));
732 menu->addMenu(subMenu);
735 subMenu = new QMenu(tr("&Ellipse"), this);
736 // action = actionFactory.createAction(RS2::ActionDrawEllipseAxis, actionHandler);
737 subMenu->addAction(actionDrawEllipseAxis);
738 connect(actionDrawEllipseAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseAxis()));
739 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseAxis, SLOT(setEnabled(bool)));
740 // action = actionFactory.createAction(RS2::ActionDrawEllipseArcAxis, actionHandler);
741 subMenu->addAction(actionDrawEllipseArcAxis);
742 connect(actionDrawEllipseArcAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseArcAxis()));
743 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseArcAxis, SLOT(setEnabled(bool)));
744 menu->addMenu(subMenu);
747 subMenu = new QMenu(tr("&Spline"), this);
748 // action = actionFactory.createAction(RS2::ActionDrawSpline, actionHandler);
749 subMenu->addAction(actionDrawSpline);
750 connect(actionDrawSpline, SIGNAL(activated()), actionHandler, SLOT(slotDrawSpline()));
751 connect(this, SIGNAL(windowsChanged(bool)), actionDrawSpline, SLOT(setEnabled(bool)));
752 menu->addMenu(subMenu);
755 subMenu = new QMenu(tr("&Polyline"), this);
756 // action = actionFactory.createAction(RS2::ActionDrawPolyline, actionHandler);
757 subMenu->addAction(actionDrawPolyline);
758 connect(actionDrawPolyline, SIGNAL(activated()), actionHandler, SLOT(slotDrawPolyline()));
759 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPolyline, SLOT(setEnabled(bool)));
760 // action = actionFactory.createAction(RS2::ActionPolylineAdd, actionHandler);
761 subMenu->addAction(actionPolylineAdd);
762 connect(actionPolylineAdd, SIGNAL(activated()), actionHandler, SLOT(slotPolylineAdd()));
763 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineAdd, SLOT(setEnabled(bool)));
764 // action = actionFactory.createAction(RS2::ActionPolylineDel, actionHandler);
765 subMenu->addAction(actionPolylineDel);
766 connect(actionPolylineDel, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDel()));
767 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDel, SLOT(setEnabled(bool)));
768 // action = actionFactory.createAction(RS2::ActionPolylineDelBetween, actionHandler);
769 subMenu->addAction(actionPolylineDelBetween);
770 connect(actionPolylineDelBetween, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDelBetween()));
771 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDelBetween, SLOT(setEnabled(bool)));
772 // action = actionFactory.createAction(RS2::ActionPolylineTrim, actionHandler);
773 subMenu->addAction(actionPolylineTrim);
774 connect(actionPolylineTrim, SIGNAL(activated()), actionHandler, SLOT(slotPolylineTrim()));
775 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineTrim, SLOT(setEnabled(bool)));
776 menu->addMenu(subMenu);
779 // action = actionFactory.createAction(RS2::ActionDrawText, actionHandler);
780 menu->addAction(actionDrawText);
781 connect(actionDrawText, SIGNAL(activated()), actionHandler, SLOT(slotDrawText()));
782 connect(this, SIGNAL(windowsChanged(bool)), actionDrawText, SLOT(setEnabled(bool)));
784 // action = actionFactory.createAction(RS2::ActionDrawHatch, actionHandler);
785 menu->addAction(actionDrawHatch);
786 connect(actionDrawHatch, SIGNAL(activated()), actionHandler, SLOT(slotDrawHatch()));
787 connect(this, SIGNAL(windowsChanged(bool)), actionDrawHatch, SLOT(setEnabled(bool)));
789 // action = actionFactory.createAction(RS2::ActionDrawImage, actionHandler);
790 menu->addAction(actionDrawImage);
791 connect(actionDrawImage, SIGNAL(activated()), actionHandler, SLOT(slotDrawImage()));
792 connect(this, SIGNAL(windowsChanged(bool)), actionDrawImage, SLOT(setEnabled(bool)));
793 // menuBar()->insertItem(tr("&Draw"), menu);
794 menuBar()->addMenu(menu);
796 // Dimensioning actions:
802 menu = new QMenu(tr("&Dimension"), this);
803 // action = actionFactory.createAction(RS2::ActionDimAligned, actionHandler);
804 menu->addAction(actionDimAligned);
805 connect(actionDimAligned, SIGNAL(activated()), actionHandler, SLOT(slotDimAligned()));
806 connect(this, SIGNAL(windowsChanged(bool)), actionDimAligned, SLOT(setEnabled(bool)));
807 // action = actionFactory.createAction(RS2::ActionDimLinear, actionHandler);
808 menu->addAction(actionDimLinear);
809 connect(actionDimLinear, SIGNAL(activated()), actionHandler, SLOT(slotDimLinear()));
810 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinear, SLOT(setEnabled(bool)));
811 // action = actionFactory.createAction(RS2::ActionDimLinearHor, actionHandler);
812 menu->addAction(actionDimLinearHor);
813 connect(actionDimLinearHor, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearHor()));
814 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearHor, SLOT(setEnabled(bool)));
815 // action = actionFactory.createAction(RS2::ActionDimLinearVer, actionHandler);
816 menu->addAction(actionDimLinearVer);
817 connect(actionDimLinearVer, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearVer()));
818 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearVer, SLOT(setEnabled(bool)));
819 // action = actionFactory.createAction(RS2::ActionDimRadial, actionHandler);
820 menu->addAction(actionDimRadial);
821 connect(actionDimRadial, SIGNAL(activated()), actionHandler, SLOT(slotDimRadial()));
822 connect(this, SIGNAL(windowsChanged(bool)), actionDimRadial, SLOT(setEnabled(bool)));
823 // action = actionFactory.createAction(RS2::ActionDimDiametric, actionHandler);
824 menu->addAction(actionDimDiametric);
825 connect(actionDimDiametric, SIGNAL(activated()), actionHandler, SLOT(slotDimDiametric()));
826 connect(this, SIGNAL(windowsChanged(bool)), actionDimDiametric, SLOT(setEnabled(bool)));
827 // action = actionFactory.createAction(RS2::ActionDimAngular, actionHandler);
828 menu->addAction(actionDimAngular);
829 connect(actionDimAngular, SIGNAL(activated()), actionHandler, SLOT(slotDimAngular()));
830 connect(this, SIGNAL(windowsChanged(bool)), actionDimAngular, SLOT(setEnabled(bool)));
831 // action = actionFactory.createAction(RS2::ActionDimLeader, actionHandler);
832 menu->addAction(actionDimLeader);
833 connect(actionDimLeader, SIGNAL(activated()), actionHandler, SLOT(slotDimLeader()));
834 connect(this, SIGNAL(windowsChanged(bool)), actionDimLeader, SLOT(setEnabled(bool)));
836 m->insertItem(tr("&Dimension"), menu);
838 menuBar()->addMenu(menu);
841 // Modifying actions:
843 menu = new QMenu(tr("&Modify"), this);
844 // action = actionFactory.createAction(RS2::ActionModifyMove, actionHandler);
845 menu->addAction(actionModifyMove);
846 connect(actionModifyMove, SIGNAL(activated()), actionHandler, SLOT(slotModifyMove()));
847 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMove, SLOT(setEnabled(bool)));
848 // action = actionFactory.createAction(RS2::ActionModifyRotate, actionHandler);
849 menu->addAction(actionModifyRotate);
850 connect(actionModifyRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate()));
851 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate, SLOT(setEnabled(bool)));
852 // action = actionFactory.createAction(RS2::ActionModifyScale, actionHandler);
853 menu->addAction(actionModifyScale);
854 connect(actionModifyScale, SIGNAL(activated()), actionHandler, SLOT(slotModifyScale()));
855 connect(this, SIGNAL(windowsChanged(bool)), actionModifyScale, SLOT(setEnabled(bool)));
856 // action = actionFactory.createAction(RS2::ActionModifyMirror, actionHandler);
857 menu->addAction(actionModifyMirror);
858 connect(actionModifyMirror, SIGNAL(activated()), actionHandler, SLOT(slotModifyMirror()));
859 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMirror, SLOT(setEnabled(bool)));
860 // action = actionFactory.createAction(RS2::ActionModifyMoveRotate, actionHandler);
861 menu->addAction(actionModifyMoveRotate);
862 connect(actionModifyMoveRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyMoveRotate()));
863 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMoveRotate, SLOT(setEnabled(bool)));
864 // action = actionFactory.createAction(RS2::ActionModifyRotate2, actionHandler);
865 menu->addAction(actionModifyRotate2);
866 connect(actionModifyRotate2, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate2()));
867 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate2, SLOT(setEnabled(bool)));
868 // action = actionFactory.createAction(RS2::ActionModifyTrim, actionHandler);
869 menu->addAction(actionModifyTrim);
870 connect(actionModifyTrim, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim()));
871 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim, SLOT(setEnabled(bool)));
872 // action = actionFactory.createAction(RS2::ActionModifyTrim2, actionHandler);
873 menu->addAction(actionModifyTrim2);
874 connect(actionModifyTrim2, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim2()));
875 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim2, SLOT(setEnabled(bool)));
876 // action = actionFactory.createAction(RS2::ActionModifyTrimAmount, actionHandler);
877 menu->addAction(actionModifyTrimAmount);
878 connect(actionModifyTrimAmount, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrimAmount()));
879 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrimAmount, SLOT(setEnabled(bool)));
880 // action = actionFactory.createAction(RS2::ActionModifyBevel, actionHandler);
881 menu->addAction(actionModifyBevel);
882 connect(actionModifyBevel, SIGNAL(activated()), actionHandler, SLOT(slotModifyBevel()));
883 connect(this, SIGNAL(windowsChanged(bool)), actionModifyBevel, SLOT(setEnabled(bool)));
884 // action = actionFactory.createAction(RS2::ActionModifyRound, actionHandler);
885 menu->addAction(actionModifyRound);
886 connect(actionModifyRound, SIGNAL(activated()), actionHandler, SLOT(slotModifyRound()));
887 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRound, SLOT(setEnabled(bool)));
888 // action = actionFactory.createAction(RS2::ActionModifyCut, actionHandler);
889 menu->addAction(actionModifyCut);
890 connect(actionModifyCut, SIGNAL(activated()), actionHandler, SLOT(slotModifyCut()));
891 connect(this, SIGNAL(windowsChanged(bool)), actionModifyCut, SLOT(setEnabled(bool)));
892 // action = actionFactory.createAction(RS2::ActionModifyStretch, actionHandler);
893 menu->addAction(actionModifyStretch);
894 connect(actionModifyStretch, SIGNAL(activated()), actionHandler, SLOT(slotModifyStretch()));
895 connect(this, SIGNAL(windowsChanged(bool)), actionModifyStretch, SLOT(setEnabled(bool)));
896 // action = actionFactory.createAction(RS2::ActionModifyEntity, actionHandler);
897 menu->addAction(actionModifyEntity);
898 connect(actionModifyEntity, SIGNAL(activated()), actionHandler, SLOT(slotModifyEntity()));
899 connect(this, SIGNAL(windowsChanged(bool)), actionModifyEntity, SLOT(setEnabled(bool)));
900 // action = actionFactory.createAction(RS2::ActionModifyAttributes, actionHandler);
901 menu->addAction(actionModifyAttributes);
902 connect(actionModifyAttributes, SIGNAL(activated()), actionHandler, SLOT(slotModifyAttributes()));
903 connect(this, SIGNAL(windowsChanged(bool)), actionModifyAttributes, SLOT(setEnabled(bool)));
904 // action = actionFactory.createAction(RS2::ActionModifyDelete, actionHandler);
905 menu->addAction(actionModifyDelete);
906 connect(actionModifyDelete, SIGNAL(activated()), actionHandler, SLOT(slotModifyDelete()));
907 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDelete, SLOT(setEnabled(bool)));
908 // action = actionFactory.createAction(RS2::ActionModifyDeleteQuick, actionHandler);
909 menu->addAction(actionModifyDeleteQuick);
910 connect(actionModifyDeleteQuick, SIGNAL(activated()), actionHandler, SLOT(slotModifyDeleteQuick()));
911 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDeleteQuick, SLOT(setEnabled(bool)));
912 // action = actionFactory.createAction(RS2::ActionModifyExplodeText, actionHandler);
913 menu->addAction(actionModifyExplodeText);
914 connect(actionModifyExplodeText, SIGNAL(activated()), actionHandler, SLOT(slotModifyExplodeText()));
915 connect(this, SIGNAL(windowsChanged(bool)), actionModifyExplodeText, SLOT(setEnabled(bool)));
916 //// action = actionFactory.createAction(RS2::ActionModifyDeleteFree, actionHandler);
917 //// menu->addAction(action);
918 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
919 menu->addAction(actionBlocksExplode);
920 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
921 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
922 menuBar()->addMenu(menu);
926 menu = new QMenu(tr("&Snap"), this);
927 // action = actionFactory.createAction(RS2::ActionSnapFree, actionHandler);
928 menu->addAction(actionSnapFree);
929 actionHandler->setActionSnapFree(actionSnapFree); // ???Why???
930 connect(actionSnapFree, SIGNAL(activated()), actionHandler, SLOT(slotSnapFree()));
931 connect(this, SIGNAL(windowsChanged(bool)), actionSnapFree, SLOT(setEnabled(bool)));
932 actionSnapFree->setChecked(true);
933 // action = actionFactory.createAction(RS2::ActionSnapGrid, actionHandler);
934 menu->addAction(actionSnapGrid);
935 actionHandler->setActionSnapGrid(actionSnapGrid); // ???Why???
936 connect(actionSnapGrid, SIGNAL(activated()), actionHandler, SLOT(slotSnapGrid()));
937 connect(this, SIGNAL(windowsChanged(bool)), actionSnapGrid, SLOT(setEnabled(bool)));
938 // action = actionFactory.createAction(RS2::ActionSnapEndpoint, actionHandler);
939 menu->addAction(actionSnapEndpoint);
940 actionHandler->setActionSnapEndpoint(actionSnapEndpoint); // ???Why???
941 connect(actionSnapEndpoint, SIGNAL(activated()), actionHandler, SLOT(slotSnapEndpoint()));
942 connect(this, SIGNAL(windowsChanged(bool)), actionSnapEndpoint, SLOT(setEnabled(bool)));
943 // action = actionFactory.createAction(RS2::ActionSnapOnEntity, actionHandler);
944 menu->addAction(actionSnapOnEntity);
945 actionHandler->setActionSnapOnEntity(actionSnapOnEntity); // ???Why???
946 connect(actionSnapOnEntity, SIGNAL(activated()), actionHandler, SLOT(slotSnapOnEntity()));
947 connect(this, SIGNAL(windowsChanged(bool)), actionSnapOnEntity, SLOT(setEnabled(bool)));
948 // action = actionFactory.createAction(RS2::ActionSnapCenter, actionHandler);
949 menu->addAction(actionSnapCenter);
950 actionHandler->setActionSnapCenter(actionSnapCenter); // ???Why???
951 connect(actionSnapCenter, SIGNAL(activated()), actionHandler, SLOT(slotSnapCenter()));
952 connect(this, SIGNAL(windowsChanged(bool)), actionSnapCenter, SLOT(setEnabled(bool)));
953 // action = actionFactory.createAction(RS2::ActionSnapMiddle, actionHandler);
954 menu->addAction(actionSnapMiddle);
955 actionHandler->setActionSnapMiddle(actionSnapMiddle); // ???Why???
956 connect(actionSnapMiddle, SIGNAL(activated()), actionHandler, SLOT(slotSnapMiddle()));
957 connect(this, SIGNAL(windowsChanged(bool)), actionSnapMiddle, SLOT(setEnabled(bool)));
958 // action = actionFactory.createAction(RS2::ActionSnapDist, actionHandler);
959 menu->addAction(actionSnapDist);
960 actionHandler->setActionSnapDist(actionSnapDist); // ???Why???
961 connect(actionSnapDist, SIGNAL(activated()), actionHandler, SLOT(slotSnapDist()));
962 connect(this, SIGNAL(windowsChanged(bool)), actionSnapDist, SLOT(setEnabled(bool)));
963 // action = actionFactory.createAction(RS2::ActionSnapIntersection, actionHandler);
964 menu->addAction(actionSnapIntersection);
965 actionHandler->setActionSnapIntersection(actionSnapIntersection); // ???Why???
966 connect(actionSnapIntersection, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersection()));
967 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersection, SLOT(setEnabled(bool)));
968 // action = actionFactory.createAction(RS2::ActionSnapIntersectionManual, actionHandler);
969 menu->addAction(actionSnapIntersectionManual);
970 actionHandler->setActionSnapIntersectionManual(actionSnapIntersectionManual); // ???Why???
971 connect(actionSnapIntersectionManual, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersectionManual()));
972 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersectionManual, SLOT(setEnabled(bool)));
974 menu->addSeparator();
976 // action = actionFactory.createAction(RS2::ActionRestrictNothing, actionHandler);
977 menu->addAction(actionRestrictNothing);
978 actionHandler->setActionRestrictNothing(actionRestrictNothing); // ???WHY???
979 connect(actionRestrictNothing, SIGNAL(activated()), actionHandler, SLOT(slotRestrictNothing()));
980 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictNothing, SLOT(setEnabled(bool)));
981 actionRestrictNothing->setChecked(true);
982 // action = actionFactory.createAction(RS2::ActionRestrictOrthogonal, actionHandler);
983 menu->addAction(actionRestrictOrthogonal);
984 actionHandler->setActionRestrictOrthogonal(actionRestrictOrthogonal); // ???WHY???
985 connect(actionRestrictOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictOrthogonal()));
986 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictOrthogonal, SLOT(setEnabled(bool)));
987 // action = actionFactory.createAction(RS2::ActionRestrictHorizontal, actionHandler);
988 menu->addAction(actionRestrictHorizontal);
989 actionHandler->setActionRestrictHorizontal(actionRestrictHorizontal); // ???WHY???
990 connect(actionRestrictHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictHorizontal()));
991 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictHorizontal, SLOT(setEnabled(bool)));
992 // action = actionFactory.createAction(RS2::ActionRestrictVertical, actionHandler);
993 menu->addAction(actionRestrictVertical);
994 actionHandler->setActionRestrictVertical(actionRestrictVertical); // ???WHY???
995 connect(actionRestrictVertical, SIGNAL(activated()), actionHandler, SLOT(slotRestrictVertical()));
996 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictVertical, SLOT(setEnabled(bool)));
998 menu->addSeparator();
1000 // action = actionFactory.createAction(RS2::ActionSetRelativeZero, actionHandler);
1001 menu->addAction(actionSetRelativeZero);
1002 connect(actionSetRelativeZero, SIGNAL(activated()), actionHandler, SLOT(slotSetRelativeZero()));
1003 connect(this, SIGNAL(windowsChanged(bool)), actionSetRelativeZero, SLOT(setEnabled(bool)));
1004 // action = actionFactory.createAction(RS2::ActionLockRelativeZero, actionHandler);
1005 menu->addAction(actionLockRelativeZero);
1006 actionHandler->setActionLockRelativeZero(actionLockRelativeZero);
1007 connect(actionLockRelativeZero, SIGNAL(toggled(bool)), actionHandler, SLOT(slotLockRelativeZero(bool))); // ???WHY???
1008 connect(this, SIGNAL(windowsChanged(bool)), actionLockRelativeZero, SLOT(setEnabled(bool)));
1009 menuBar()->addMenu(menu);
1014 menu = new QMenu(tr("&Info"), this);
1015 //action = actionFactory.createAction(RS2::ActionInfoInside, actionHandler);
1016 //menu->addAction(action);
1017 menu->addAction(actionInfoDist);
1018 connect(actionInfoDist, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist()));
1019 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist, SLOT(setEnabled(bool)));
1020 menu->addAction(actionInfoDist2);
1021 connect(actionInfoDist2, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist2()));
1022 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist2, SLOT(setEnabled(bool)));
1023 menu->addAction(actionInfoAngle);
1024 connect(actionInfoAngle, SIGNAL(activated()), actionHandler, SLOT(slotInfoAngle()));
1025 connect(this, SIGNAL(windowsChanged(bool)), actionInfoAngle, SLOT(setEnabled(bool)));
1026 menu->addAction(actionInfoTotalLength);
1027 connect(actionInfoTotalLength, SIGNAL(activated()), actionHandler, SLOT(slotInfoTotalLength()));
1028 connect(this, SIGNAL(windowsChanged(bool)), actionInfoTotalLength, SLOT(setEnabled(bool)));
1029 menu->addAction(actionInfoArea);
1030 connect(actionInfoArea, SIGNAL(activated()), actionHandler, SLOT(slotInfoArea()));
1031 connect(this, SIGNAL(windowsChanged(bool)), actionInfoArea, SLOT(setEnabled(bool)));
1032 menuBar()->addMenu(menu);
1037 menu = new QMenu(tr("&Layer"), this);
1038 // action = actionFactory.createAction(RS2::ActionLayersDefreezeAll, actionHandler);
1039 menu->addAction(actionLayersDefreezeAll);
1040 connect(actionLayersDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersDefreezeAll()));
1041 connect(this, SIGNAL(windowsChanged(bool)), actionLayersDefreezeAll, SLOT(setEnabled(bool)));
1042 // action = actionFactory.createAction(RS2::ActionLayersFreezeAll, actionHandler);
1043 menu->addAction(actionLayersFreezeAll);
1044 connect(actionLayersFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersFreezeAll()));
1045 connect(this, SIGNAL(windowsChanged(bool)), actionLayersFreezeAll, SLOT(setEnabled(bool)));
1046 // action = actionFactory.createAction(RS2::ActionLayersAdd, actionHandler);
1047 menu->addAction(actionLayersAdd);
1048 connect(actionLayersAdd, SIGNAL(activated()), actionHandler, SLOT(slotLayersAdd()));
1049 connect(this, SIGNAL(windowsChanged(bool)), actionLayersAdd, SLOT(setEnabled(bool)));
1050 // action = actionFactory.createAction(RS2::ActionLayersRemove, actionHandler);
1051 menu->addAction(actionLayersRemove);
1052 connect(actionLayersRemove, SIGNAL(activated()), actionHandler, SLOT(slotLayersRemove()));
1053 connect(this, SIGNAL(windowsChanged(bool)), actionLayersRemove, SLOT(setEnabled(bool)));
1054 // action = actionFactory.createAction(RS2::ActionLayersEdit, actionHandler);
1055 menu->addAction(actionLayersEdit);
1056 connect(actionLayersEdit, SIGNAL(activated()), actionHandler, SLOT(slotLayersEdit()));
1057 connect(this, SIGNAL(windowsChanged(bool)), actionLayersEdit, SLOT(setEnabled(bool)));
1058 // action = actionFactory.createAction(RS2::ActionLayersToggleView, actionHandler);
1059 menu->addAction(actionLayersToggleView);
1060 connect(actionLayersToggleView, SIGNAL(activated()), actionHandler, SLOT(slotLayersToggleView()));
1061 connect(this, SIGNAL(windowsChanged(bool)), actionLayersToggleView, SLOT(setEnabled(bool)));
1062 menuBar()->addMenu(menu);
1066 menu = new QMenu(tr("&Block"), this);
1067 // action = actionFactory.createAction(RS2::ActionBlocksDefreezeAll, actionHandler);
1068 menu->addAction(actionBlocksDefreezeAll);
1069 connect(actionBlocksDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksDefreezeAll()));
1070 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksDefreezeAll, SLOT(setEnabled(bool)));
1071 // action = actionFactory.createAction(RS2::ActionBlocksFreezeAll, actionHandler);
1072 menu->addAction(actionBlocksFreezeAll);
1073 connect(actionBlocksFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksFreezeAll()));
1074 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksFreezeAll, SLOT(setEnabled(bool)));
1075 // action = actionFactory.createAction(RS2::ActionBlocksAdd, actionHandler);
1076 menu->addAction(actionBlocksAdd);
1077 connect(actionBlocksAdd, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAdd()));
1078 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAdd, SLOT(setEnabled(bool)));
1079 // action = actionFactory.createAction(RS2::ActionBlocksRemove, actionHandler);
1080 menu->addAction(actionBlocksRemove);
1081 connect(actionBlocksRemove, SIGNAL(activated()), actionHandler, SLOT(slotBlocksRemove()));
1082 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksRemove, SLOT(setEnabled(bool)));
1083 // action = actionFactory.createAction(RS2::ActionBlocksAttributes, actionHandler);
1084 menu->addAction(actionBlocksAttributes);
1085 connect(actionBlocksAttributes, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAttributes()));
1086 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAttributes, SLOT(setEnabled(bool)));
1087 // action = actionFactory.createAction(RS2::ActionBlocksInsert, actionHandler);
1088 menu->addAction(actionBlocksInsert);
1089 connect(actionBlocksInsert, SIGNAL(activated()), actionHandler, SLOT(slotBlocksInsert()));
1090 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksInsert, SLOT(setEnabled(bool)));
1091 // action = actionFactory.createAction(RS2::ActionBlocksEdit, actionHandler);
1092 menu->addAction(actionBlocksEdit);
1093 connect(actionBlocksEdit, SIGNAL(activated()), actionHandler, SLOT(slotBlocksEdit()));
1094 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksEdit, SLOT(setEnabled(bool)));
1095 // action = actionFactory.createAction(RS2::ActionBlocksCreate, actionHandler);
1096 menu->addAction(actionBlocksCreate);
1097 connect(actionBlocksCreate, SIGNAL(activated()), actionHandler, SLOT(slotBlocksCreate()));
1098 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksCreate, SLOT(setEnabled(bool)));
1099 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
1100 menu->addAction(actionBlocksExplode);
1101 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
1102 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
1103 menuBar()->addMenu(menu);
1105 //will *this* make a toolbar break for us???
1106 addToolBarBreak(Qt::TopToolBarArea);
1107 // addDockWindow(penToolBar, tr("Pen"), Qt::DockTop);
1108 // addDockWindow(optionWidget, tr("Tool Options"), Qt::DockTop, true);
1109 addToolBar(Qt::TopToolBarArea, (QToolBar *)penToolBar); // hmm.
1110 addToolBar(Qt::TopToolBarArea, optionWidget);
1115 scriptMenu = new QMenu(this);
1116 scriptOpenIDE = actionFactory.createAction(RS2::ActionScriptOpenIDE, this);
1117 scriptOpenIDE->addTo(scriptMenu);
1118 scriptRun = actionFactory.createAction(RS2::ActionScriptRun, this);
1119 scriptRun->addTo(scriptMenu);
1122 scriptOpenIDE = NULL;
1128 menu = new QMenu(tr("&CAM"), this);
1129 action = actionFactory.createAction(RS2::ActionCamExportAuto, actionHandler);
1130 menu->addAction(action);
1131 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1132 action = actionFactory.createAction(RS2::ActionCamReorder, actionHandler);
1133 menu->addAction(action);
1134 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1135 menuBar()->addMenu(menu);
1140 helpAboutApp = new QAction(QIcon(QC_APP_ICON16), tr("&About Architektonas"), this);
1141 // helpAboutApp = new QAction(tr("About"), qPixmapFromMimeSource(QC_APP_ICON16), tr("&About %1").arg(QC_APPNAME), 0, this);
1142 helpAboutApp->setStatusTip(tr("About the application"));
1143 //helpAboutApp->setWhatsThis(tr("About\n\nAbout the application"));
1144 connect(helpAboutApp, SIGNAL(activated()), this, SLOT(slotHelpAbout()));
1146 helpManual = new QAction(QIcon(":/res/contents.png"), tr("&Manual"), this);
1147 helpManual->setShortcut(Qt::Key_F1);
1148 // helpManual = new QAction(qPixmapFromMimeSource("contents.png"), tr("&Manual"), Qt::Key_F1, this);
1149 helpManual->setStatusTip(tr("Launch the online manual"));
1150 connect(helpManual, SIGNAL(activated()), this, SLOT(slotHelpManual()));
1152 testDumpEntities = new QAction("Dump &Entities", this);
1153 // testDumpEntities = new QAction("Dump Entities", "Dump &Entities", 0, this);
1154 connect(testDumpEntities, SIGNAL(activated()), this, SLOT(slotTestDumpEntities()));
1156 testDumpUndo = new QAction("Undo Info", this);
1157 // testDumpUndo = new QAction("Dump Undo Info", "Undo Info", 0, this);
1158 connect(testDumpUndo, SIGNAL(activated()), this, SLOT(slotTestDumpUndo()));
1160 testUpdateInserts = new QAction("&Update Inserts", this);
1161 // testUpdateInserts = new QAction("Update Inserts", "&Update Inserts", 0, this);
1162 connect(testUpdateInserts, SIGNAL(activated()), this, SLOT(slotTestUpdateInserts()));
1164 testDrawFreehand = new QAction("Draw Freehand", this);
1165 // testDrawFreehand = new QAction("Draw Freehand", "Draw Freehand", 0, this);
1166 connect(testDrawFreehand, SIGNAL(activated()), this, SLOT(slotTestDrawFreehand()));
1168 testInsertBlock = new QAction("Insert Block", this);
1169 // testInsertBlock = new QAction("Insert Block", "Insert Block", 0, this);
1170 connect(testInsertBlock, SIGNAL(activated()), this, SLOT(slotTestInsertBlock()));
1172 testInsertText = new QAction("Insert Text", this);
1173 // testInsertText = new QAction("Insert Text", "Insert Text", 0, this);
1174 connect(testInsertText, SIGNAL(activated()), this, SLOT(slotTestInsertText()));
1176 testInsertImage = new QAction("Insert Image", this);
1177 // testInsertImage = new QAction("Insert Image", "Insert Image", 0, this);
1178 connect(testInsertImage, SIGNAL(activated()), this, SLOT(slotTestInsertImage()));
1180 testUnicode = new QAction("Unicode", this);
1181 // testUnicode = new QAction("Unicode", "Unicode", 0, this);
1182 connect(testUnicode, SIGNAL(activated()), this, SLOT(slotTestUnicode()));
1184 testInsertEllipse = new QAction("Insert Ellipse", this);
1185 // testInsertEllipse = new QAction("Insert Ellipse", "Insert Ellipse", 0, this);
1186 connect(testInsertEllipse, SIGNAL(activated()), this, SLOT(slotTestInsertEllipse()));
1188 testMath01 = new QAction("Math01", this);
1189 // testMath01 = new QAction("Math01", "Math01", 0, this);
1190 connect(testMath01, SIGNAL(activated()), this, SLOT(slotTestMath01()));
1192 testResize640 = new QAction("Resize 1", this);
1193 // testResize640 = new QAction("Resize to 640x480", "Resize 1", 0, this);
1194 connect(testResize640, SIGNAL(activated()), this, SLOT(slotTestResize640()));
1196 testResize800 = new QAction("Resize 2", this);
1197 // testResize800 = new QAction("Resize to 800x600", "Resize 2", 0, this);
1198 connect(testResize800, SIGNAL(activated()), this, SLOT(slotTestResize800()));
1200 testResize1024 = new QAction("Resize 3", this);
1201 // testResize1024 = new QAction("Resize to 1024x768", "Resize 3", 0, this);
1202 connect(testResize1024, SIGNAL(activated()), this, SLOT(slotTestResize1024()));
1206 * Initializes the menu bar.
1208 void ApplicationWindow::initMenuBar()
1210 RS_DEBUG->print("ApplicationWindow::initMenuBar()");
1212 // menuBar entry windowsMenu
1213 windowsMenu = new QMenu(tr("&Window"), this);
1214 //according to docs, this is obsolete: windowsMenu->setCheckable(true);
1215 connect(windowsMenu, SIGNAL(aboutToShow()), this, SLOT(slotWindowsMenuAboutToShow()));
1217 // menuBar entry scriptMenu
1218 //scriptMenu = new QPopupMenu(this);
1219 //scriptMenu->setCheckable(true);
1220 //scriptOpenIDE->addTo(scriptMenu);
1221 //scriptRun->addTo(scriptMenu);
1222 //connect(scriptMenu, SIGNAL(aboutToShow()), this, SLOT(slotScriptMenuAboutToShow()));
1224 // menuBar entry helpMenu
1225 helpMenu = new QMenu(tr("&Help"), this);
1226 helpMenu->addAction(helpManual);//helpManual->addTo(helpMenu);
1228 // helpMenu->insertSeparator(helpManual);
1229 helpMenu->addSeparator();
1231 helpMenu->addAction(helpAboutApp);//helpAboutApp->addTo(helpMenu);
1233 // menuBar entry test menu
1234 testMenu = new QMenu(tr("De&bugging"), this);
1235 testMenu->addAction(testDumpEntities);//testDumpEntities->addTo(testMenu);
1236 testMenu->addAction(testDumpUndo);//testDumpUndo->addTo(testMenu);
1237 testMenu->addAction(testUpdateInserts);//testUpdateInserts->addTo(testMenu);
1238 testMenu->addAction(testDrawFreehand);//testDrawFreehand->addTo(testMenu);
1239 testMenu->addAction(testInsertBlock);//testInsertBlock->addTo(testMenu);
1240 testMenu->addAction(testInsertText);//testInsertText->addTo(testMenu);
1241 testMenu->addAction(testInsertImage);//testInsertImage->addTo(testMenu);
1242 testMenu->addAction(testInsertEllipse);//testInsertEllipse->addTo(testMenu);
1243 testMenu->addAction(testUnicode);//testUnicode->addTo(testMenu);
1244 testMenu->addAction(testMath01);//testMath01->addTo(testMenu);
1245 testMenu->addAction(testResize640);//testResize640->addTo(testMenu);
1246 testMenu->addAction(testResize800);//testResize800->addTo(testMenu);
1247 testMenu->addAction(testResize1024);//testResize1024->addTo(testMenu);
1249 // menuBar configuration
1251 // menuBar()->insertItem(tr("&Scripts"), scriptMenu);
1252 menuBar()->addMenu(scriptMenu);
1254 // menuBar()->insertItem(tr("&Window"), windowsMenu);
1255 menuBar()->addMenu(windowsMenu);
1257 // menuBar()->insertSeparator();
1258 // menuBar()->insertItem(tr("&Help"), helpMenu);
1259 menuBar()->addMenu(helpMenu);
1262 // menuBar()->insertItem(tr("De&bugging"), testMenu);
1263 menuBar()->addMenu(testMenu);
1265 recentFiles = new QG_RecentFiles(this, fileMenu);
1269 * Initializes the tool bars (file tool bar and pen tool bar).
1271 void ApplicationWindow::initToolBar()
1273 RS_DEBUG->print("ApplicationWindow::initToolBar()");
1275 // fileToolBar = new Q3ToolBar(this, "File Operations");
1276 fileToolBar = addToolBar(tr("File Operations"));
1277 fileToolBar->setObjectName("file");
1278 // editToolBar = new Q3ToolBar(this, "Edit Operations");
1279 editToolBar = addToolBar(tr("Edit Operations"));
1280 editToolBar->setObjectName("edit");
1281 // zoomToolBar = new Q3ToolBar(this, "Zoom Operations");
1282 zoomToolBar = addToolBar(tr("Zoom Operations"));
1283 zoomToolBar->setObjectName("zoom");
1284 penToolBar = new QG_PenToolBar(this, "Pen Selection");
1285 penToolBar->setObjectName("pen");
1287 connect(penToolBar, SIGNAL(penChanged(RS_Pen)), this, SLOT(slotPenChanged(RS_Pen)));
1289 // optionWidget = new Q3ToolBar(this, "Tool Options");
1290 //addToolBarBreak() does nothing...
1291 #warning "!!! add/insertToolBarBreak() does nothing !!!"
1292 // addToolBarBreak(Qt::TopToolBarArea);
1293 optionWidget = addToolBar(tr("Tool Options"));
1294 optionWidget->setObjectName("tooloptions");
1295 optionWidget->setMinimumHeight(26);
1296 optionWidget->setMaximumHeight(26);
1297 #warning "!!! No analogue found for setHorizontallyStretchable yet !!!"
1298 //Maybe sizePolicy or somesuch??
1299 optionWidget->setMinimumWidth(150);
1300 optionWidget->setMaximumWidth(800);
1301 #warning "Following line commented out..."
1302 // optionWidget->setFixedExtentHeight(26);
1303 // optionWidget->setHorizontallyStretchable(true);
1304 // addDockWindow(optionWidget, DockTop, true);
1306 // CAD toolbar left:
1307 // Q3ToolBar * t = new Q3ToolBar(this, "CAD Tools");
1308 QToolBar * t = addToolBar(tr("CAD Tools"));
1309 t->setObjectName("cadtools");
1310 #warning "Following two lines commented out..."
1311 // t->setFixedExtentWidth(59);
1312 t->setMinimumWidth(59);
1313 t->setMaximumWidth(59);
1314 // t->setVerticallyStretchable(true);
1315 // addDockWindow(t, Qt::DockLeft, false);
1316 addToolBar(Qt::LeftToolBarArea, t);
1318 cadToolBar = new CadToolBar(t);//, "CAD Tools");
1319 cadToolBar->createSubToolBars(actionHandler);
1321 connect(cadToolBar, SIGNAL(signalBack()), this, SLOT(slotBack()));
1322 connect(this, SIGNAL(windowsChanged(bool)), cadToolBar, SLOT(setEnabled(bool)));
1324 // QG_CadToolBarMain * cadToolBarMain = new QG_CadToolBarMain(cadToolBar);
1325 //No, no break inserted here either...
1326 // insertToolBarBreak(optionWidget);
1330 * Initializes the status bar at the bottom.
1332 void ApplicationWindow::initStatusBar()
1334 RS_DEBUG->print("ApplicationWindow::initStatusBar()");
1336 statusBar()->setMinimumHeight(32);
1337 coordinateWidget = new CoordinateWidget(statusBar());//, "coordinates");
1338 statusBar()->addWidget(coordinateWidget);
1339 mouseWidget = new MouseWidget(statusBar());//, "mouse info");
1340 statusBar()->addWidget(mouseWidget);
1341 selectionWidget = new SelectionWidget(statusBar());//, "selections");
1342 statusBar()->addWidget(selectionWidget);
1346 * Initializes the global application settings from the
1347 * config file (unix, mac) or registry (windows).
1349 void ApplicationWindow::initSettings()
1351 RS_DEBUG->print("ApplicationWindow::initSettings()");
1352 settings.beginGroup("RecentFiles");
1354 for(int i=0; i<recentFiles->Maximum(); ++i)
1356 QString filename = settings.value(QString("File") + QString::number(i + 1)).toString();
1358 if (!filename.isEmpty())
1359 // recentFiles->add(filename);
1360 recentFiles->add(filename);
1363 settings.endGroup();
1365 if (recentFiles->count() > 0)
1366 // updateRecentFilesMenu();
1367 recentFiles->UpdateGUI();
1369 settings.beginGroup("Geometry");
1370 QSize windowSize = settings.value("WindowSize", QSize(950, 700)).toSize();
1371 QPoint windowPos = settings.value("WindowPos", QPoint(0, 30)).toPoint();
1372 restoreState(settings.value("DockWindows").toByteArray());
1373 settings.endGroup();
1376 // if (windowY < 30)
1378 if (windowSize.y() < 30)
1379 windowSize.y() = 30;
1387 * Stores the global application settings to file or registry.
1389 void ApplicationWindow::storeSettings()
1391 RS_DEBUG->print("ApplicationWindow::storeSettings()");
1393 settings.beginGroup("RecentFiles");
1395 for(int i=0; i<recentFiles->count(); ++i)
1396 settings.setValue(QString("File") + QString::number(i + 1), recentFiles->get(i));
1398 settings.endGroup();
1400 settings.beginGroup("Geometry");
1401 settings.setValue("WindowSize", size());
1402 settings.setValue("WindowPos", pos());
1403 settings.setValue("DockWindows", saveState());
1404 settings.endGroup();
1406 RS_DEBUG->print("ApplicationWindow::storeSettings(): OK");
1410 * Initializes the view.
1412 void ApplicationWindow::initView()
1414 RS_DEBUG->print("ApplicationWindow::initView()");
1416 RS_DEBUG->print("init view..");
1420 libraryWidget = NULL;
1421 commandWidget = NULL;
1423 simulationControls = NULL;
1427 RS_DEBUG->print(" simulation widget..");
1428 dw = new QDockWidget(QDockWidget::InDock, this, "Simulation");
1429 simulationControls = new RS_SimulationControls(dw, "Simulation");
1430 simulationControls->setFocusPolicy(Qt::NoFocus);
1431 connect(simulationControls, SIGNAL(escape()), this, SLOT(slotFocus()));
1432 connect(this, SIGNAL(windowsChanged(bool)), simulationControls, SLOT(setEnabled(bool)));
1433 dw->setWidget(simulationControls);
1434 dw->resize(240, 80);
1435 dw->setResizeEnabled(true);
1436 dw->setFixedExtentWidth(120);
1437 dw->setFixedHeight(80);
1438 dw->setCaption(tr("Simulation Controls"));
1439 dw->setCloseMode(Q3DockWindow::Always);
1440 addDockWindow(dw, Qt::DockRight);
1441 simulationDockWindow = dw;
1442 //simulationDockWindow->hide();
1445 RS_DEBUG->print(" layer widget..");
1446 // dw = new QDockWidget(QDockWidget::InDock, this, "Layer");
1447 dw = new QDockWidget(tr("Layer List"), this);
1448 dw->setObjectName("layer");
1449 layerWidget = new QG_LayerWidget(actionHandler, dw, "Layer");
1450 layerWidget->setFocusPolicy(Qt::NoFocus);
1451 connect(layerWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1452 connect(this, SIGNAL(windowsChanged(bool)), layerWidget, SLOT(setEnabled(bool)));
1453 dw->setWidget(layerWidget);
1454 #warning "following four lines commented out..."
1455 // dw->setFixedExtentWidth(120);
1456 // dw->setResizeEnabled(true);
1457 // dw->setCloseMode(Q3DockWindow::Always);
1458 // dw->setCaption(tr("Layer List"));
1459 addDockWidget(Qt::RightDockWidgetArea, dw);
1460 layerDockWindow = dw;
1462 RS_DEBUG->print(" block widget..");
1463 // dw = new QDockWidget(QDockWidget::InDock, this, "Block");
1464 dw = new QDockWidget(tr("Block List"), this);
1465 dw->setObjectName("block");
1466 blockWidget = new QG_BlockWidget(actionHandler, dw, "Block");
1467 blockWidget->setFocusPolicy(Qt::NoFocus);
1468 connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1469 connect(this, SIGNAL(windowsChanged(bool)), blockWidget, SLOT(setEnabled(bool)));
1470 dw->setWidget(blockWidget);
1471 #warning "following four lines commented out..."
1472 // dw->setFixedExtentWidth(120);
1473 // dw->setResizeEnabled(true);
1474 // dw->setCloseMode(Q3DockWindow::Always);
1475 // dw->setCaption(tr("Block List"));
1476 addDockWidget(Qt::RightDockWidgetArea, dw);
1477 blockDockWindow = dw;
1479 RS_DEBUG->print(" library widget..");
1480 // dw = new QDockWidget(QDockWidget::OutsideDock, this, "Library");
1481 dw = new QDockWidget(tr("Library Browser"), this);
1482 dw->setObjectName("library");
1483 libraryWidget = new LibraryWidget(dw);//WAS:, "Library");
1484 libraryWidget->setActionHandler(actionHandler);
1485 libraryWidget->setFocusPolicy(Qt::NoFocus);
1486 connect(libraryWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1488 // connect(this, SIGNAL(windowsChanged(bool)), (QObject *)libraryWidget->bInsert, SLOT(setEnabled(bool)));
1489 dw->setWidget(libraryWidget);
1490 dw->resize(240, 400);
1491 #warning "following three lines commented out..."
1492 // dw->setResizeEnabled(true);
1493 // dw->setCloseMode(Q3DockWindow::Always);
1494 // dw->setCaption(tr("Library Browser"));
1495 //not sure how to fix this one
1496 #warning "QMainWindow::addDockWidget: invalid 'area' argument"
1497 addDockWidget(Qt::NoDockWidgetArea, dw);
1498 libraryDockWindow = dw;
1499 libraryDockWindow->hide();
1501 RS_DEBUG->print(" command widget..");
1502 // dw = new QDockWidget(QDockWidget::InDock, this, "Command");
1503 dw = new QDockWidget(tr("Command line"), this);
1504 dw->setObjectName("command");
1505 commandWidget = new CommandWidget(dw);//WAS:, "Command");
1506 commandWidget->setActionHandler(actionHandler);
1507 // commandWidget->redirectStderr();
1508 // std::cerr << "Ready.\n";
1509 // commandWidget->processStderr();
1510 connect(this, SIGNAL(windowsChanged(bool)), commandWidget, SLOT(setEnabled(bool)));
1511 dw->setWidget(commandWidget);
1512 #warning "following four lines commented out..."
1513 // dw->setFixedExtentHeight(45);
1514 // dw->setResizeEnabled(true);
1515 // dw->setCloseMode(QDockWidget::Always);
1516 // dw->setCaption(tr("Command line"));
1517 commandDockWindow = dw;
1518 addDockWidget(Qt::BottomDockWidgetArea, dw);
1520 RS_DEBUG->print(" done");
1524 * Creates a new toolbar.
1525 * Implementation from QG_MainWindowInterface.
1526 * Can be called from scripts to add individual GUI elements.
1528 /*QToolBar* ApplicationWindow::createToolBar(const QString& name) {
1529 QToolBar* tb = new QToolBar(this, name);
1535 * Creates a new button in the given tool bar for running a script.
1537 /*void ApplicationWindow::addToolBarButton(QToolBar* tb) {
1539 QAction* action = new QAction("Blah",
1540 QPixmap::fromMimeSource("zoomwindow.png"),
1541 "&Blah", QKeySequence(), NULL);
1542 action->setStatusTip("Blah blah");
1547 #warning "!!! ApplicationWindow::updateRecentFilesMenu() is DEPRECATED !!!"
1549 * Updates the recent file list in the file menu.
1551 void ApplicationWindow::updateRecentFilesMenu()
1553 RS_DEBUG->print("ApplicationWindow::updateRecentFilesMenu()");
1554 RS_DEBUG->print("Updating recent file menu...");
1557 for(int i=0; i<recentFiles->getNumber(); ++i)
1559 QString label = QString("&%1 %2").arg(i + 1).arg(recentFiles->get(i));
1561 if (fileMenu->findItem(i))
1563 RS_DEBUG->print("Changeing item %d", i);
1564 fileMenu->changeItem(i, label);
1566 else if (i < int(recentFiles->count()))
1568 RS_DEBUG->print("Adding item %d", i);
1569 fileMenu->insertItem(label, this, SLOT(slotFileOpenRecent(int)), 0, i);
1573 //#warning "!!! Need to fix ApplicationWindow::updateRecentFilesMenu() !!!"
1574 recentFiles->UpdateGUI();
1579 * Goes back to the previous menu or one step in the current action.
1581 void ApplicationWindow::slotBack()
1583 RS_GraphicView * graphicView = getGraphicView();
1585 if (graphicView != NULL)
1586 graphicView->back();
1589 if (cadToolBar != NULL)
1590 cadToolBar->showToolBar(RS2::ToolBarMain);
1595 * Goes one step further in the current action.
1597 void ApplicationWindow::slotEnter()
1599 if (commandWidget == NULL || !commandWidget->checkFocus())
1601 if (cadToolBar != NULL)
1602 cadToolBar->forceNext();
1605 RS_GraphicView * graphicView = getGraphicView();
1607 if (graphicView != NULL)
1608 graphicView->enter();
1614 * Sets the keyboard focus on the command line.
1616 void ApplicationWindow::slotFocusCommandLine()
1618 if (commandWidget->isVisible())
1619 commandWidget->setFocus();
1623 * Shows the given error on the command line.
1625 void ApplicationWindow::slotError(const QString & msg)
1627 commandWidget->appendHistory(msg);
1631 * Hands focus back to the application window. In the rare event
1632 * of a escape press from the layer widget (e.g after switching desktops
1635 void ApplicationWindow::slotFocus()
1637 //QG_GraphicView* graphicView = getGraphicView();
1638 /*if (graphicView!=NULL) {
1639 graphicView->setFocus();
1647 * Called when a document window was activated.
1649 void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/)
1651 RS_DEBUG->print("ApplicationWindow::slotWindowActivated begin");
1653 //the following does: return (MDIWindow *)workspace->activeSubWindow();
1654 //which means the subwindow is NOT being activated!!!
1655 MDIWindow * m = getMDIWindow();
1656 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m=%08X", m);
1658 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m->getDoc=%08X", m->getDocument());
1660 if (m != NULL && m->getDocument() != NULL)
1662 //m->setWindowState(WindowMaximized);
1664 RS_DEBUG->print("ApplicationWindow::slotWindowActivated: document: %d", m->getDocument()->getId());
1666 bool showByBlock = m->getDocument()->rtti() == RS2::EntityBlock;
1667 layerWidget->setLayerList(m->getDocument()->getLayerList(), showByBlock);
1668 coordinateWidget->setGraphic(m->getGraphic());
1671 simulationControls->setGraphicView(m->getGraphicView());
1674 // Only graphics show blocks. (blocks don't)
1675 if (m->getDocument()->rtti() == RS2::EntityGraphic)
1676 blockWidget->setBlockList(m->getDocument()->getBlockList());
1678 blockWidget->setBlockList(NULL);
1680 // Update all inserts in this graphic (blocks might have changed):
1681 m->getDocument()->updateInserts();
1682 m->getGraphicView()->redraw();
1684 // set snapmode from snapping menu
1685 actionHandler->updateSnapMode();
1687 // set pen from pen toolbar
1688 slotPenChanged(penToolBar->getPen());
1690 // update toggle button status:
1691 if (m->getGraphic() != NULL)
1693 emit(gridChanged(m->getGraphic()->isGridOn()));
1694 emit(printPreviewChanged(m->getGraphicView()->isPrintPreview()));
1698 //Seems to work now.
1699 //#warning "This is failing... !!! FIX !!!"
1700 // Disable/Enable menu and toolbar items
1701 emit windowsChanged(m != NULL && m->getDocument() != NULL);
1703 RS_DEBUG->print("ApplicationWindow::slotWindowActivated end");
1707 * Called when the menu 'windows' is about to be shown.
1708 * This is used to update the window list in the menu.
1710 void ApplicationWindow::slotWindowsMenuAboutToShow()
1712 RS_DEBUG->print("ApplicationWindow::slotWindowsMenuAboutToShow");
1714 windowsMenu->clear();
1716 int cascadeId = windowsMenu->insertItem(tr("&Cascade"), workspace, SLOT(cascade()));
1717 int tileId = windowsMenu->insertItem(tr("&Tile"), this, SLOT(slotTileVertical()));
1718 int horTileId = windowsMenu->insertItem(tr("Tile &Horizontally"), this, SLOT(slotTileHorizontal()));
1720 if (workspace->subWindowList().isEmpty())
1722 windowsMenu->setItemEnabled(cascadeId, false);
1723 windowsMenu->setItemEnabled(tileId, false);
1724 windowsMenu->setItemEnabled(horTileId, false);
1727 windowsMenu->insertSeparator();
1729 #warning "!!! Qt4 implementation of insertItem is vastly different from Qt3--FIX !!!"
1731 QList<QMdiSubWindow *> windows = workspace->subWindowList();
1733 //#warning "Need to add window numbers underlined so can access windows via keyboard. !!! FIX !!!"
1735 for(int i=0; i<int(windows.count()); ++i)
1737 // int id = windowsMenu->insertItem(windows.at(i)->caption(), this, SLOT(slotWindowsMenuActivated(int)));
1738 //For some reason the triggered() signal created here is type bool... Dunno why...
1739 //It's signalling using the QAction signal, which is type bool (checked or not).
1741 QString actionName = QString("&%1 %2").arg(i + 1).arg(windows.at(i)->windowTitle());
1742 // QAction * action = new QAction(windows.at(i)->windowTitle(), this);
1743 QAction * action = new QAction(actionName, this);
1744 action->setCheckable(true);
1746 action->setChecked(workspace->activeSubWindow() == windows.at(i));
1747 windowsMenu->addAction(action);
1748 connect(windowsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotWindowsMenuActivated(QAction *)));
1749 // connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1751 QAction * id = windowsMenu->addAction(windows.at(i)->windowTitle(), this,
1752 // SLOT(slotWindowsMenuActivated(int)));
1753 SLOT(slotWindowsMenuActivated(QAction *)));
1755 // windowsMenu->setItemParameter(id, i);
1756 // windowsMenu->setItemChecked(id, workspace->activeSubWindow() == windows.at(i));
1758 id->setChecked(workspace->activeSubWindow() == windows.at(i));
1764 * Called when the user selects a document window from the
1767 void ApplicationWindow::slotWindowsMenuActivated(QAction * id)
1769 RS_DEBUG->print("ApplicationWindow::slotWindowsMenuActivated");
1771 // QMdiSubWindow * w = workspace->subWindowList().at(id);
1772 QMdiSubWindow * w = workspace->subWindowList().at(id->data().toInt());
1780 * Tiles MDI windows horizontally.
1782 void ApplicationWindow::slotTileHorizontal()
1784 RS_DEBUG->print("ApplicationWindow::slotTileHorizontal");
1787 // primitive horizontal tiling
1788 QWidgetList windows = workspace->windowList();
1790 if (windows.count() == 0)
1793 int heightForEach = workspace->height() / windows.count();
1796 for(int i=0; i<int(windows.count()); ++i)
1798 QWidget * window = windows.at(i);
1800 #warning "Need to port to Qt4... !!! FIX !!!"
1802 if (window->testWState(WState_Maximized))
1806 window->showNormal();
1810 int preferredHeight = window->minimumHeight() + window->parentWidget()->baseSize().height();
1811 int actHeight = QMAX(heightForEach, preferredHeight);
1813 // window->parentWidget()->resize(workspace->width(), actHeight);
1814 window->parentWidget()->setGeometry(0, y, workspace->width(), actHeight);
1818 workspace->tileSubWindows();
1823 * Tiles MDI windows vertically.
1825 void ApplicationWindow::slotTileVertical()
1831 QWidgetList windows = workspace->windowList();
1832 if (windows.count()==0) {
1836 //int heightForEach = workspace->height() / windows.count();
1838 for (int i=0; i<int(windows.count()); ++i) {
1839 QWidget *window = windows.at(i);
1840 if (window->testWState(WState_Maximized)) {
1843 window->showNormal();
1845 //int preferredHeight = window->minimumHeight()
1846 // + window->parentWidget()->baseSize().height();
1847 //int actHeight = QMAX(heightForEach, preferredHeight);
1849 //window->parentWidget()->setGeometry(0, y,
1850 // workspace->width(), actHeight);
1851 //window->parentWidget()->resize(window->parentWidget()->width(),
1852 // window->parentWidget()->height());
1853 //window->resize(window->width(), window->height());
1858 workspace->tileSubWindows();
1867 void ApplicationWindow::slotCamExportAuto() {
1868 printf("CAM export..\n");
1870 RS_Document* d = getDocument();
1872 Drawing* graphic = (Drawing*)d;
1874 RS_CamDialog dlg(graphic, this);
1882 * Called when something changed in the pen tool bar
1883 * (e.g. color, width, style).
1885 void ApplicationWindow::slotPenChanged(RS_Pen pen)
1887 RS_DEBUG->print("ApplicationWindow::slotPenChanged() begin");
1888 RS_DEBUG->print("Setting active pen...");
1889 MDIWindow * m = getMDIWindow();
1892 m->slotPenChanged(pen);
1894 RS_DEBUG->print("ApplicationWindow::slotPenChanged() end");
1898 * Creates a new MDI window with the given document or a new
1899 * document if 'doc' is NULL.
1901 MDIWindow * ApplicationWindow::slotFileNew(RS_Document * doc)
1903 RS_DEBUG->print("ApplicationWindow::slotFileNew() begin");
1908 statusBar()->showMessage(tr("Creating new file..."));
1910 #warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible"
1911 RS_DEBUG->print(" creating MDI window");
1912 // MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::WA_DeleteOnClose);
1913 MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::SubWindow);
1914 w->setAttribute(Qt::WA_DeleteOnClose);
1915 // w->setWindowState(WindowMaximized);
1916 connect(w, SIGNAL(signalClosing()), this, SLOT(slotFileClosing()));
1918 if (w->getDocument()->rtti() == RS2::EntityBlock)
1919 // w->setCaption(tr("Block '%1'").arg(((RS_Block *)(w->getDocument()))->getName()));
1920 w->setWindowTitle(tr("Block '%1'").arg(((RS_Block *)(w->getDocument()))->getName()));
1922 // w->setCaption(tr("unnamed document %1").arg(id));
1923 w->setWindowTitle(tr("unnamed document %1").arg(id));
1925 // w->setIcon(qPixmapFromMimeSource("document.png"));
1926 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
1927 w->setWindowIcon(QIcon(":/res/document.png"));
1929 // only graphics offer block lists, blocks don't
1930 RS_DEBUG->print(" adding listeners");
1931 Drawing * graphic = w->getDocument()->getGraphic();
1933 if (graphic != NULL)
1935 // Link the graphic's layer list to the pen tool bar
1936 graphic->addLayerListListener(penToolBar);
1937 // Link the layer list to the layer widget
1938 graphic->addLayerListListener(layerWidget);
1939 // Link the block list to the block widget
1940 graphic->addBlockListListener(blockWidget);
1943 // Link the dialog factory to the mouse widget:
1944 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
1945 // Link the dialog factory to the coordinate widget:
1946 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
1947 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
1948 // Link the dialog factory to the option widget:
1949 // QG_DIALOGFACTORY->setOptionWidget(optionWidget);
1950 // Link the dialog factory to the cad tool bar:
1951 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
1952 // Link the dialog factory to the command widget:
1953 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
1954 // Link the dialog factory to the main app window:
1955 QG_DIALOGFACTORY->setMainWindow(this);
1957 #if 1 //bugfix for Qt3->4 conversion
1958 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotFileNew: adding window to workspace...");
1959 // workspace->addWindow(w);
1960 workspace->addSubWindow(w);
1963 RS_DEBUG->print(" showing MDI window");
1966 #warning "w->showMaximized() doesn't seem to do anything here..."
1967 //but then again, the subWindowList isn't going to be empty at this point either...
1968 if (workspace->subWindowList().isEmpty())
1974 #warning "!!! SubWindow is not being activated !!!"
1975 //neither of these is working... Is the event being eaten somewhere???
1976 // workspace->activateNextSubWindow();
1978 //printf("--> ApplicationWindow::slotFileNew(): w %s focus...\n", (w->hasFocus() ? "has" : "DOES NOT HAVE"));
1981 #warning "!!! Parameter to slotWindowActivated() is ignored !!!"
1982 slotWindowActivated(w);
1983 statusBar()->showMessage(tr("New Drawing created."), 2000);
1985 RS_DEBUG->print("ApplicationWindow::slotFileNew() OK");
1992 * Menu file -> open.
1994 void ApplicationWindow::slotFileOpen()
1996 RS_DEBUG->print("ApplicationWindow::slotFileOpen()");
1998 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 001");
1999 RS2::FormatType type = RS2::FormatUnknown;
2000 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 002");
2001 QString fileName = QG_FileDialog::getOpenFileName(this, &type);
2002 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 003");
2003 slotFileOpen(fileName, type);
2004 RS_DEBUG->print("ApplicationWindow::slotFileOpen(): OK");
2008 * Called when a recently opened file is chosen from the list in the
2011 void ApplicationWindow::slotFileOpenRecent(void)
2014 RS_DEBUG->print("ApplicationWindow::slotFileOpenRecent()");
2016 statusBar()->showMessage(tr("Opening recent file..."));
2017 QString fileName = recentFiles->get(id);
2019 if (fileName.endsWith(" (DXF 1)"))
2020 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
2022 slotFileOpen(fileName, RS2::FormatUnknown);
2024 statusBar()->showMessage(tr("Opening recent file..."));
2026 QAction * action = qobject_cast<QAction *>(sender());
2031 QString fileName = action->data().toString();
2033 if (fileName.endsWith(" (DXF 1)"))
2034 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
2036 slotFileOpen(fileName, RS2::FormatUnknown);
2041 * Menu file -> open.
2043 void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType type)
2045 RS_DEBUG->print("ApplicationWindow::slotFileOpen(..)");
2047 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2049 if (!fileName.isEmpty())
2051 RS_DEBUG->print("ApplicationWindow::slotFileOpen: creating new doc window");
2052 // Create new document window:
2053 MDIWindow * w = slotFileNew();
2054 // RS_APP->processEvents(1000);
2055 //Really, is this needed???
2056 // RS_APP->processEvents(QEventLoop::AllEvents, 1000);
2058 RS_DEBUG->print("ApplicationWindow::slotFileOpen: linking layer list");
2059 // link the layer widget to the new document:
2060 layerWidget->setLayerList(w->getDocument()->getLayerList(), false);
2061 // link the block widget to the new document:
2062 blockWidget->setBlockList(w->getDocument()->getBlockList());
2063 // link coordinate widget to graphic
2064 coordinateWidget->setGraphic(w->getGraphic());
2066 // link the layer widget to the new document:
2067 simulationControls->setGraphicView(w->getGraphicView());
2070 RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file");
2072 // RS_APP->processEvents(1000);
2073 //We no longer try to do Qt better than the Qt folks...
2074 // RS_APP->processEvents(QEventLoop::AllEvents, 1000);
2076 // open the file in the new view:
2077 if (w->slotFileOpen(fileName, type) == false)
2080 QApplication::restoreOverrideCursor();
2081 QMessageBox::information(this, QMessageBox::tr("Warning"),
2082 tr("Cannot open the file\n%1\nPlease check the permissions.") .arg(fileName), QMessageBox::Ok);
2083 w->setForceClosing(true);
2088 RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file: OK");
2089 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 1");
2091 // update recent files menu:
2092 if (type == RS2::FormatDXF1)
2093 recentFiles->add(fileName + " (DXF 1)");
2095 recentFiles->add(fileName);
2097 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 2");
2098 // updateRecentFilesMenu();
2099 recentFiles->UpdateGUI();
2101 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: OK");
2103 RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption");
2105 // w->setCaption(fileName);
2106 w->setWindowTitle(fileName);
2107 RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption: OK");
2109 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget");
2110 // update coordinate widget format:
2111 RS_DIALOGFACTORY->updateCoordinateWidget(Vector(0.0, 0.0), Vector(0.0, 0.0), true);
2112 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget: OK");
2114 // show output of filter (if any):
2115 // commandWidget->processStderr();
2116 QString message = tr("Loaded document: ") + fileName;
2117 commandWidget->appendHistory(message);
2118 statusBar()->showMessage(message, 2000);
2122 statusBar()->showMessage(tr("Opening aborted"), 2000);
2125 QApplication::restoreOverrideCursor();
2126 RS_DEBUG->print("ApplicationWindow::slotFileOpen(..) OK");
2130 * Menu file -> save.
2132 void ApplicationWindow::slotFileSave()
2134 RS_DEBUG->print("ApplicationWindow::slotFileSave()");
2136 statusBar()->showMessage(tr("Saving drawing..."));
2138 MDIWindow * w = getMDIWindow();
2143 if (w->getDocument()->getFilename().isEmpty())
2149 if (w->slotFileSave(cancelled))
2153 name = w->getDocument()->getFilename();
2154 statusBar()->showMessage(tr("Saved drawing: %1").arg(name), 2000);
2160 QMessageBox::information(this, QMessageBox::tr("Warning"),
2161 tr("Cannot save the file\n%1\nPlease check the permissions.")
2162 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2169 * Menu file -> save as.
2171 void ApplicationWindow::slotFileSaveAs()
2173 RS_DEBUG->print("ApplicationWindow::slotFileSaveAs()");
2175 statusBar()->showMessage(tr("Saving drawing under new filename..."));
2177 MDIWindow * w = getMDIWindow();
2184 if (w->slotFileSaveAs(cancelled))
2188 name = w->getDocument()->getFilename();
2189 recentFiles->add(name);
2190 w->setWindowTitle(name);
2196 QMessageBox::information(this, QMessageBox::tr("Warning"),
2197 tr("Cannot save the file\n%1\nPlease check the permissions.")
2198 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2202 // updateRecentFilesMenu();
2203 recentFiles->UpdateGUI();
2205 QString message = tr("Saved drawing: %1").arg(name);
2206 statusBar()->showMessage(message, 2000);
2207 commandWidget->appendHistory(message);
2211 * Menu file -> export.
2213 void ApplicationWindow::slotFileExport()
2215 RS_DEBUG->print("ApplicationWindow::slotFileExport()");
2217 statusBar()->showMessage(tr("Exporting drawing..."));
2219 MDIWindow * w = getMDIWindow();
2224 // read default settings:
2225 settings.beginGroup("Paths");
2226 QString defDir = settings.value("ExportImage", RS_SYSTEM->getHomeDir()).toString();
2227 QString defFilter = settings.value("ExportImageFilter", "Portable Network Graphic (*.png)").toString();
2228 settings.endGroup();
2230 bool cancel = false;
2232 // Q3FileDialog fileDlg(NULL, "", true);
2233 QFileDialog fileDlg(NULL, "", "", "");
2235 #warning "Need to port to Qt4... !!! FIX !!!"
2237 Q3StrList f = QImageIO::outputFormats();
2238 QStringList formats = QStringList::fromStrList(f);
2239 QStringList filters;
2242 for (QStringList::Iterator it = formats.begin();
2243 it!=formats.end(); ++it)
2248 st = QString("%1 (*.%2 *.jpg)")
2249 .arg(QG_DialogFactory::extToFormat(*it))
2250 .arg(QString(*it).lower());
2254 st = QString("%1 (*.%2)")
2255 .arg(QG_DialogFactory::extToFormat(*it))
2256 .arg(QString(*it).lower());
2261 //if (!all.isEmpty()) {
2264 //all += QString("*.%1").arg(QString(*it).lower());
2267 QStringList filters;
2270 fileDlg.setFilters(filters);
2271 // fileDlg.setMode(Q3FileDialog::AnyFile);
2272 fileDlg.setFileMode(QFileDialog::AnyFile);
2273 // fileDlg.setCaption(QObject::tr("Export Image"));
2274 fileDlg.setWindowTitle(QObject::tr("Export Image"));
2275 // fileDlg.setDir(defDir);
2276 fileDlg.setDirectory(defDir);
2277 fileDlg.selectNameFilter(defFilter);
2279 if (fileDlg.exec() == QDialog::Accepted)
2281 // fn = fileDlg.selectedFile();
2282 QStringList files = fileDlg.selectedFiles();
2284 if (!files.isEmpty())
2292 // store new default settings:
2295 settings.beginGroup("Paths");
2296 // settings.writeEntry("/ExportImage", QFileInfo(fn).dirPath(true));
2297 settings.setValue("ExportImage", QFileInfo(fn).absolutePath());
2298 settings.setValue("ExportImageFilter", fileDlg.selectedFilter());
2299 settings.endGroup();
2301 // find out extension:
2302 QString filter = fileDlg.selectedFilter();
2303 QString format = "";
2304 // int i = filter.find("(*.");
2305 int i = filter.indexOf("(*.");
2309 // int i2 = filter.find(QRegExp("[) ]"), i);
2310 int i2 = filter.indexOf(QRegExp("[) ]"), i);
2311 format = filter.mid(i + 3, i2 - (i + 3));
2312 format = format.toUpper();
2315 // append extension to file:
2316 if (!QFileInfo(fn).fileName().contains("."))
2317 fn.append("." + format.toLower());
2319 // show options dialog:
2320 ImageOptionsDialog dlg(this);
2321 dlg.setGraphicSize(w->getGraphic()->getSize());
2325 bool ret = slotFileExport(fn, format, dlg.getSize(), dlg.isBackgroundBlack());
2329 QString message = tr("Exported: %1").arg(fn);
2330 statusBar()->showMessage(message, 2000);
2331 commandWidget->appendHistory(message);
2339 * Exports the drawing as a bitmap.
2341 * @param name File name.
2342 * @param format File format (e.g. "png")
2343 * @param size Size of the bitmap in pixel
2344 * @param black true: Black background, false: white
2345 * @param bw true: black/white export, false: color
2347 bool ApplicationWindow::slotFileExport(const QString & name, const QString & format, QSize size, bool black, bool bw)
2349 MDIWindow * w = getMDIWindow();
2353 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no window opened");
2357 Drawing * graphic = w->getDocument()->getGraphic();
2359 if (graphic == NULL)
2361 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no graphic");
2365 statusBar()->showMessage(tr("Exporting..."));
2366 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2369 QPixmap * buffer = new QPixmap(size);
2370 // RS_PainterQt * painter = new RS_PainterQt(buffer);
2371 QPainter qpntr(buffer);
2372 PaintInterface * painter = new PaintInterface(&qpntr);
2374 // black background:
2376 // painter->setBackgroundColor(RS_Color(0, 0, 0));
2377 // qpntr.setBackgroundColor(RS_Color(0, 0, 0));
2378 qpntr.setBackground(QBrush(QColor(0, 0, 0)));
2379 // white background:
2381 // painter->setBackgroundColor(RS_Color(255, 255, 255));
2382 // qpntr.setBackgroundColor(RS_Color(255, 255, 255));
2383 qpntr.setBackground(QBrush(QColor(255, 255, 255)));
2387 painter->setDrawingMode(RS2::ModeBW);
2389 // painter->eraseRect(0, 0, size.width(), size.height());
2390 qpntr.eraseRect(0, 0, size.width(), size.height());
2392 RS_StaticGraphicView gv(size.width(), size.height(), painter);
2395 gv.setBackground(RS_Color(0, 0, 0));
2397 gv.setBackground(RS_Color(255, 255, 255));
2399 gv.setContainer(graphic);
2401 gv.drawEntity(graphic, true);
2408 iio.setFileName(name);
2409 iio.setFormat(format);
2416 #warning "Need to port to Qt4... !!! FIX !!!"
2419 QApplication::restoreOverrideCursor();
2421 // GraphicView deletes painter
2428 statusBar()->showMessage(tr("Export complete"), 2000);
2430 statusBar()->showMessage(tr("Export failed!"), 2000);
2436 * Menu file -> close.
2438 void ApplicationWindow::slotFileClose()
2440 RS_DEBUG->print("ApplicationWindow::slotFileClose()");
2442 MDIWindow * m = getMDIWindow();
2451 //m->showMaximized();
2452 m->setWindowState(WindowMaximized);
2458 * Called when a MDI window is actually about to close. Used to
2459 * detach widgets from the document.
2461 void ApplicationWindow::slotFileClosing()
2463 RS_DEBUG->print("ApplicationWindow::slotFileClosing()");
2465 RS_DEBUG->print("detaching lists");
2466 layerWidget->setLayerList(NULL, false);
2467 blockWidget->setBlockList(NULL);
2468 coordinateWidget->setGraphic(NULL);
2470 simulationControls->setGraphicView(NULL);
2475 * Menu file -> print.
2477 void ApplicationWindow::slotFilePrint()
2479 RS_DEBUG->print("ApplicationWindow::slotFilePrint()");
2481 MDIWindow * w = getMDIWindow();
2485 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no window opened");
2489 Drawing * graphic = w->getDocument()->getGraphic();
2491 if (graphic == NULL)
2493 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no graphic");
2497 statusBar()->showMessage(tr("Printing..."));
2498 QPrinter * printer = new QPrinter(QPrinter::HighResolution);
2499 bool landscape = false;
2500 printer->setPageSize(RS2::rsToQtPaperFormat(graphic->getPaperFormat(&landscape)));
2503 printer->setOrientation(QPrinter::Landscape);
2505 printer->setOrientation(QPrinter::Portrait);
2507 settings.beginGroup("Print");
2508 printer->setOutputFileName(settings.value("FileName", "").toString());
2509 printer->setColorMode((QPrinter::ColorMode)settings.value("/ColorMode", (int)QPrinter::Color).toInt());
2510 #warning "!!! Need to port QPrinter::setOutputToFile() to Qt4 !!!"
2511 // printer->setOutputToFile((bool)RS_SETTINGS->readNumEntry("/PrintToFile", 0));
2512 settings.endGroup();
2515 // if (printer->setup(this))
2516 QPrintDialog dialog(printer, this);
2519 //printer->setOutputToFile(true);
2520 //printer->setOutputFileName(outputFile);
2522 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2523 printer->setFullPage(true);
2524 //Can call these functions directly from the QPaintDevice...
2525 // Q3PaintDeviceMetrics metr(printer);
2527 // RS_PainterQt * painter = new RS_PainterQt(printer);
2528 QPainter qpntr(printer);
2529 PaintInterface * painter = new PaintInterface(&qpntr);
2530 painter->setDrawingMode(w->getGraphicView()->getDrawingMode());
2532 // RS_StaticGraphicView gv(metr.width(), metr.height(), painter);
2533 RS_StaticGraphicView gv(printer->width(), printer->height(), painter);
2534 gv.setPrinting(true);
2535 gv.setBorders(0, 0, 0, 0);
2537 // double fx = (double)metr.width() / metr.widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2538 // double fy = (double)metr.height() / metr.heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2539 double fx = (double)printer->width() / printer->widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2540 double fy = (double)printer->height() / printer->heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2541 double f = (fx + fy) / 2;
2542 double scale = graphic->getPaperScale();
2544 gv.setOffset((int)(graphic->getPaperInsertionBase().x * f),
2545 (int)(graphic->getPaperInsertionBase().y * f));
2546 gv.setFactor(f * scale);
2547 gv.setContainer(graphic);
2548 gv.drawEntity(graphic, true);
2550 // GraphicView deletes painter
2555 settings.beginGroup("Print");
2556 #warning "!!! Need to port QPrinter::outputToFile() to Qt4 !!!"
2557 // settings.writeEntry("/PrintToFile", (int)printer->outputToFile());
2558 settings.setValue("ColorMode", (int)printer->colorMode());
2559 settings.setValue("FileName", printer->outputFileName());
2560 settings.endGroup();
2561 QApplication::restoreOverrideCursor();
2566 statusBar()->showMessage(tr("Printing complete"), 2000);
2570 * Menu file -> print preview.
2572 void ApplicationWindow::slotFilePrintPreview(bool on)
2574 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview()");
2576 RS_DEBUG->print(" creating MDI window");
2577 MDIWindow * parent = getMDIWindow();
2581 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrintPreview: no window opened");
2585 // close print preview:
2588 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): off");
2590 if (parent->getGraphicView()->isPrintPreview())
2592 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): close");
2596 // open print preview:
2599 // look for an existing print preview:
2600 MDIWindow * ppv = parent->getPrintPreview();
2604 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): show existing");
2605 slotWindowActivated(ppv);
2610 if (!parent->getGraphicView()->isPrintPreview())
2612 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): create");
2614 MDIWindow * w = new MDIWindow(parent->getDocument(), workspace, 0, Qt::SubWindow);
2615 w->setAttribute(Qt::WA_DeleteOnClose);
2616 parent->addChildWindow(w);
2617 //connect(w, SIGNAL(signalClosing()),
2618 // this, SLOT(slotFileClosing()));
2620 // w->setCaption(tr("Print preview for %1").arg(parent->caption()));
2621 w->setWindowTitle(tr("Print preview for %1").arg(parent->windowTitle()));
2622 // w->setIcon(qPixmapFromMimeSource("document.png"));
2623 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
2624 w->setWindowIcon(QIcon(":/res/document.png"));
2625 w->getGraphicView()->setPrintPreview(true);
2626 w->getGraphicView()->setBackground(RS_Color(255, 255, 255));
2627 w->getGraphicView()->setDefaultAction(new RS_ActionPrintPreview(*w->getDocument(), *w->getGraphicView()));
2629 // only graphics offer block lists, blocks don't
2630 RS_DEBUG->print(" adding listeners");
2631 Drawing * graphic = w->getDocument()->getGraphic();
2633 if (graphic != NULL)
2635 // Link the layer list to the pen tool bar
2636 graphic->addLayerListListener(penToolBar);
2637 // Link the layer list to the layer widget
2638 graphic->addLayerListListener(layerWidget);
2639 // Link the block list to the block widget
2640 graphic->addBlockListListener(blockWidget);
2641 // Center by default:
2642 graphic->centerToPage();
2645 // Link the graphic view to the mouse widget:
2646 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
2647 // Link the graphic view to the coordinate widget:
2648 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
2649 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
2650 // Link the graphic view to the option widget:
2651 //QG_DIALOGFACTORY->setOptionWidget(optionWidget);
2652 // Link the graphic view to the cad tool bar:
2653 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
2654 // Link the graphic view to the command widget:
2655 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
2657 RS_DEBUG->print(" showing MDI window");
2659 if (workspace->subWindowList().isEmpty())
2664 w->getGraphicView()->zoomPage();
2667 slotWindowActivated(w);
2674 * Menu file -> quit.
2676 void ApplicationWindow::slotFileQuit()
2678 RS_DEBUG->print("ApplicationWindow::slotFileQuit()");
2680 statusBar()->showMessage(tr("Exiting application..."));
2682 if (queryExit(false))
2687 * Forces termination of QCad (demo version).
2689 void ApplicationWindow::slotFileDemoQuit()
2691 statusBar()->showMessage(tr("Exiting application..."));
2698 * Shows / hides the grid.
2700 * @param toggle true: show, false: hide.
2702 void ApplicationWindow::slotViewGrid(bool toggle)
2704 RS_DEBUG->print("ApplicationWindow::slotViewGrid()");
2706 MDIWindow * m = getMDIWindow();
2710 Drawing * g = m->getGraphic();
2713 g->setGridOn(toggle);
2719 RS_DEBUG->print("ApplicationWindow::slotViewGrid() OK");
2723 * Enables / disables the draft mode.
2725 * @param toggle true: enable, false: disable.
2727 void ApplicationWindow::slotViewDraft(bool toggle)
2729 RS_DEBUG->print("ApplicationWindow::slotViewDraft()");
2731 /*MDIWindow* m = getMDIWindow();
2733 Drawing* g = m->getGraphic();
2735 g->setDraftOn(toggle);
2739 settings.beginGroup("Appearance");
2740 settings.setValue("DraftMode", toggle);
2741 settings.endGroup();
2747 * Redraws all mdi windows.
2749 void ApplicationWindow::redrawAll()
2751 if (workspace != NULL)
2753 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2755 for(int i=0; i<int(windows.count()); ++i)
2757 MDIWindow * m = (MDIWindow *)windows.at(i);
2761 QG_GraphicView * gv = m->getGraphicView();
2771 * Updates all grids of all graphic views.
2773 void ApplicationWindow::updateGrids()
2775 if (workspace != NULL)
2777 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2779 for(int i=0; i<int(windows.count()); ++i)
2781 MDIWindow * m = (MDIWindow *)windows.at(i);
2785 QG_GraphicView * gv = m->getGraphicView();
2795 * Shows / hides the status bar.
2797 * @param showSB true: show, false: hide.
2799 void ApplicationWindow::slotViewStatusBar(bool showSB)
2801 RS_DEBUG->print("ApplicationWindow::slotViewStatusBar()");
2804 statusBar()->show();
2806 statusBar()->hide();
2810 * Shows / hides the layer list.
2812 * @param toggle true: show, false: hide.
2814 /*void ApplicationWindow::slotViewLayerList(bool toggle) {
2815 RS_DEBUG->print("ApplicationWindow::slotViewLayerList()");
2817 if (toggle==false) {
2818 layerDockWindow->hide();
2820 layerDockWindow->show();
2826 * Shows / hides the block list.
2828 * @param toggle true: show, false: hide.
2831 void ApplicationWindow::slotViewBlockList(bool toggle) {
2832 RS_DEBUG->print("ApplicationWindow::slotViewBlockList()");
2834 if (toggle==false) {
2835 blockDockWindow->hide();
2837 blockDockWindow->show();
2843 * Shows / hides the command line.
2845 * @param toggle true: show, false: hide.
2848 void ApplicationWindow::slotViewCommandLine(bool toggle) {
2849 RS_DEBUG->print("ApplicationWindow::slotViewCommandLine()");
2851 if (toggle==false) {
2852 commandDockWindow->hide();
2853 //QG_GraphicView* graphicView = getGraphicView();
2854 //if (graphicView!=NULL) {
2855 //graphicView->setFocus();
2859 commandDockWindow->show();
2865 * Shows / hides the option toolbar.
2867 * @param toggle true: show, false: hide.
2870 void ApplicationWindow::slotViewOptionToolbar(bool toggle) {
2871 RS_DEBUG->print("ApplicationWindow::slotViewOptionToolbar()");
2873 if (toggle==false) {
2874 optionWidget->hide();
2876 optionWidget->show();
2882 * Creates a new MDI window for editing the selected block.
2885 void ApplicationWindow::slotBlocksEdit() {
2886 RS_DEBUG->print("ApplicationWindow::slotBlocksEdit()");
2888 MDIWindow* parent = getMDIWindow();
2890 RS_BlockList* blist = blockWidget->getBlockList();
2892 RS_Block* blk = blist->getActiveBlock();
2894 MDIWindow* w = slotFileNew(blk);
2895 // the parent needs a pointer to the block window and
2897 parent->addChildWindow(w);
2898 w->getGraphicView()->zoomAuto();
2906 * Shows the dialog for general application preferences.
2908 void ApplicationWindow::slotOptionsGeneral()
2910 RS_DIALOGFACTORY->requestOptionsGeneralDialog();
2912 // update background color of all open drawings:
2913 settings.beginGroup("Appearance");
2914 QColor color(settings.value("BackgroundColor", "#000000").toString());
2915 QColor gridColor(settings.value("GridColor", "Gray").toString());
2916 QColor metaGridColor(settings.value("MetaGridColor", "Darkgray").toString());
2917 QColor selectedColor(settings.value("SelectedColor", "#A54747").toString());
2918 QColor highlightedColor(settings.value("HighlightedColor", "#739373").toString());
2919 settings.endGroup();
2921 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2923 for(int i=0; i<int(windows.count()); ++i)
2925 MDIWindow * m = (MDIWindow *)windows.at(i);
2929 QG_GraphicView * gv = m->getGraphicView();
2933 gv->setBackground(color);
2934 gv->setGridColor(gridColor);
2935 gv->setMetaGridColor(metaGridColor);
2936 gv->setSelectedColor(selectedColor);
2937 gv->setHighlightedColor(highlightedColor);
2946 * Menu script -> show ide
2948 void ApplicationWindow::slotScriptOpenIDE()
2951 scripter->openIDE();
2956 * Menu script -> run
2958 void ApplicationWindow::slotScriptRun()
2961 scripter->runScript();
2966 * Menu help -> about.
2968 void ApplicationWindow::slotHelpAbout()
2970 RS_DEBUG->print("ApplicationWindow::slotHelpAbout()");
2971 QStringList modules;
2978 modules += "Scripting";
2981 QString modulesString;
2983 if (modules.empty() == false)
2984 modulesString = modules.join(", ");
2986 modulesString = tr("None");
2988 QMessageBox box(this);
2989 box.setWindowTitle(tr("About..."));
2990 box.setText(QString("<qt>") + // no center for main stream QCad
2991 #ifdef QC_ABOUT_HEADER
2992 QString("<center>") +
2993 QString(QC_ABOUT_HEADER) +
2995 //FAIL "<h2>"+ QC_APPNAME+ "</h2>" +
2996 "<h2>Architektonas</h2>" +
2998 tr("Version: %1").arg("1.0.0") + "<br>" +
2999 tr("Date: %1").arg(__DATE__) + "<br>" +
3000 QString("© 2010 Underground Software,<br>James Hammons") +
3002 #ifdef QC_ABOUT_ADD_COMPANY
3003 + QString("<br>") + QC_ABOUT_ADD_COMPANY
3005 + QString("</center>")
3007 #ifndef QC_ABOUT_HEADER
3008 #warning "Failure..."
3009 // box.setIcon(qPixmapFromMimeSource(QC_APP_ICON));
3010 box.setFixedWidth(340);
3011 box.setFixedHeight(250);
3017 * Menu help -> help.
3019 void ApplicationWindow::slotHelpManual()
3021 #warning "No help system ported to Qt4... !!! FIX !!!"
3023 RS_DEBUG->print("ApplicationWindow::slotHelpManual()");
3025 if (assistant == NULL)
3027 RS_DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
3028 RS_DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
3029 assistant = new QAssistantClient(RS_SYSTEM->getAppDir()+"/bin", this);
3030 connect(assistant, SIGNAL(error(const QString&)), this, SLOT(slotError(const QString&)));
3033 args << QDir::convertSeparators(RS_SYSTEM->getDocPath() + "/qcaddoc.adp");
3034 // args << QString("doc") + QDir::separator() + QString("qcaddoc.adp");
3036 #if QT_VERSION>=0x030200
3037 assistant->setArguments(args);
3040 assistant->openAssistant();
3041 //assistant->showPage("index.html");
3048 void ApplicationWindow::slotTestDumpEntities(RS_EntityContainer * d)
3050 RS_DEBUG->print("ApplicationWindow::slotTestDumpEntities()");
3051 static int level = 0;
3052 std::ofstream dumpFile;
3057 dumpFile.open("debug_entities.html");
3062 dumpFile.open("debug_entities.html", std::ios::app);
3070 dumpFile << "<html>\n";
3071 dumpFile << "<body>\n";
3074 for (RS_Entity* e=d->firstEntity();
3079 dumpFile << "<table border=\"1\">\n";
3080 dumpFile << "<tr><td>Entity: " << e->getId()
3084 << "<tr><td><table><tr>"
3085 << "<td>VIS:" << e->isVisible() << "</td>"
3086 << "<td>UND:" << e->isUndone() << "</td>"
3087 << "<td>SEL:" << e->isSelected() << "</td>"
3088 << "<td>TMP:" << e->getFlag(RS2::FlagTemp) << "</td>";
3089 QString lay = "NULL";
3090 if (e->getLayer()!=NULL) {
3091 lay = e->getLayer()->getName();
3094 //fail << "<td>Layer: " << lay << "</td>"
3095 << "<td>Width: " << (int)e->getPen(false).getWidth() << "</td>"
3096 << "<td>Parent: " << e->getParent()->getId() << "</td>"
3104 case RS2::EntityPoint:
3106 RS_Point* p = (RS_Point*)e;
3108 << "<table><tr><td>"
3120 case RS2::EntityLine:
3122 RS_Line* l = (RS_Line*)e;
3124 << "<table><tr><td>"
3130 << l->getStartpoint()
3139 case RS2::EntityArc: {
3140 RS_Arc* a = (RS_Arc*)e;
3142 << "<table><tr><td>"
3159 << "<td>Startpoint: "
3160 << a->getStartpoint()
3166 << (int)a->isReversed()
3172 case RS2::EntityCircle: {
3173 RS_Circle* c = (RS_Circle*)e;
3175 << "<table><tr><td>"
3190 case RS2::EntityDimAligned: {
3191 RS_DimAligned* d = (RS_DimAligned*)e;
3193 << "<table><tr><td>"
3194 << "<b>Dimension / Aligned:</b>"
3199 << d->getDefinitionPoint()
3202 << d->getExtensionPoint1()
3205 << d->getExtensionPoint2()
3208 << d->getText().toLatin1().data()
3211 << d->getLabel().toLatin1().data()
3217 case RS2::EntityDimLinear:
3219 RS_DimLinear* d = (RS_DimLinear*)e;
3221 << "<table><tr><td>"
3222 << "<b>Dimension / Linear:</b>"
3227 << d->getDefinitionPoint()
3230 << d->getExtensionPoint1()
3233 << d->getExtensionPoint2()
3236 //fail << d->getText()
3239 //fail << d->getLabel()
3245 case RS2::EntityInsert: {
3246 RS_Insert* i = (RS_Insert*)e;
3248 << "<table><tr><td>"
3253 << "<td>Insertion point:"
3254 << i->getInsertionPoint()
3260 case RS2::EntityText: {
3261 RS_Text* t = (RS_Text*)e;
3263 << "<table><tr><td>"
3269 << t->getText().toLatin1().data()
3278 case RS2::EntityHatch: {
3279 RS_Hatch* h = (RS_Hatch*)e;
3281 << "<table><tr><td>"
3287 << h->getPattern().toLatin1().data()
3293 << (int)h->isSolid()
3302 << "<b>Unknown Entity: " << e->rtti() << "</b>"
3307 if (e->isContainer() || e->rtti()==RS2::EntityHatch) {
3308 RS_EntityContainer* ec = (RS_EntityContainer*)e;
3309 dumpFile << "<table><tr><td valign=\"top\"> Contents:</td><td>\n";
3311 slotTestDumpEntities(ec);
3312 dumpFile.open("debug_entities.html", std::ios::app);
3313 dumpFile << "</td></tr></table>\n";
3323 dumpFile << "</body>\n";
3324 dumpFile << "</html>\n";
3334 void ApplicationWindow::slotTestDumpUndo()
3336 RS_DEBUG->print("ApplicationWindow::slotTestDumpUndo()");
3338 RS_Document * d = getDocument();
3342 std::cout << *(RS_Undo*)d;
3343 std::cout << std::endl;
3350 void ApplicationWindow::slotTestUpdateInserts()
3352 RS_DEBUG->print("ApplicationWindow::slotTestUpdateInserts()");
3354 RS_Document * d = getDocument();
3363 void ApplicationWindow::slotTestDrawFreehand()
3365 RS_DEBUG->print("ApplicationWindow::slotTestDrawFreehand()");
3367 //Drawing* g = document->getMarking();
3370 RS_ActionDrawLineFree* action =
3371 new RS_ActionDrawLineFree(*document->getGraphic(),
3374 for (int i=0; i<100; ++i) {
3376 int posx = (random()%600);
3377 int posy = (random()%400);
3379 //RS_MouseEvent rsm1(posx, posy, LEFT);
3380 RS_MouseEvent rsm1(QEvent::MouseButtonPress,
3384 action->mousePressEvent(&rsm1);
3389 for (int k=0; k<100; ++k) {
3390 int accx = (random()%40)-20;
3391 int accy = (random()%40)-20;
3399 //RS_MouseEvent rsm2(posx, posy, LEFT);
3401 RS_MouseEvent rsm2(QEvent::MouseMove,
3405 action->mouseMoveEvent(&rsm2);
3408 action->mouseReleaseEvent(NULL);
3420 void ApplicationWindow::slotTestInsertBlock()
3422 RS_DEBUG->print("ApplicationWindow::slotTestInsertBlock()");
3424 RS_Document * d = getDocument();
3426 if (d != NULL && d->rtti() == RS2::EntityGraphic)
3428 Drawing * graphic = (Drawing *)d;
3430 if (graphic == NULL)
3433 graphic->addLayer(new RS_Layer("default"));
3434 RS_Block * block = new RS_Block(graphic, RS_BlockData("debugblock", Vector(0.0, 0.0), true));
3440 // Add one red line:
3441 line = new RS_Line(block, RS_LineData(Vector(0.0, 0.0), Vector(50.0, 0.0)));
3442 line->setLayerToActive();
3443 line->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3444 block->addEntity(line);
3446 // Add one line with attributes from block:
3447 line = new RS_Line(block, RS_LineData(Vector(50.0, 0.0), Vector(50.0, 50.0)));
3448 line->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3449 block->addEntity(line);
3451 // Add one arc with attributes from block:
3452 RS_ArcData d(Vector(50.0, 0.0), 50.0, M_PI / 2.0, M_PI, false);
3453 arc = new RS_Arc(block, d);
3454 arc->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3455 block->addEntity(arc);
3457 // Add one blue circle:
3458 RS_CircleData circleData(Vector(20.0, 15.0), 12.5);
3459 circle = new RS_Circle(block, circleData);
3460 circle->setLayerToActive();
3461 circle->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width01, RS2::SolidLine));
3462 block->addEntity(circle);
3464 graphic->addBlock(block);
3467 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);
3469 // insert one magenta instance of the block (original):
3470 ins = new RS_Insert(graphic, insData);
3471 ins->setLayerToActive();
3472 ins->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width02, RS2::SolidLine));
3474 graphic->addEntity(ins);
3476 // insert one green instance of the block (rotate):
3477 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);
3478 ins = new RS_Insert(graphic, insData);
3479 ins->setLayerToActive();
3480 ins->setPen(RS_Pen(RS_Color(0, 255, 0), RS2::Width02, RS2::SolidLine));
3482 graphic->addEntity(ins);
3484 // insert one cyan instance of the block (move):
3485 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);
3486 ins = new RS_Insert(graphic, insData);
3487 ins->setLayerToActive();
3488 ins->setPen(RS_Pen(RS_Color(0, 255, 255), RS2::Width02, RS2::SolidLine));
3490 graphic->addEntity(ins);
3492 // insert one blue instance of the block:
3493 for(double a=0.0; a<360.0; a+=45.0)
3495 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);
3496 ins = new RS_Insert(graphic, insData);
3497 ins->setLayerToActive();
3498 ins->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width05, RS2::SolidLine));
3500 graphic->addEntity(ins);
3503 // insert an array of yellow instances of the block:
3504 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);
3505 ins = new RS_Insert(graphic, insData);
3506 ins->setLayerToActive();
3507 ins->setPen(RS_Pen(RS_Color(255, 255, 0), RS2::Width01, RS2::SolidLine));
3509 graphic->addEntity(ins);
3511 RS_GraphicView * v = getGraphicView();
3521 void ApplicationWindow::slotTestInsertEllipse()
3523 RS_DEBUG->print("ApplicationWindow::slotTestInsertEllipse()");
3525 RS_Document * d = getDocument();
3529 Drawing * graphic = (Drawing *)d;
3531 if (graphic == NULL)
3534 RS_Ellipse * ellipse;
3537 for (double a=0.0; a<2*M_PI; a+=0.1)
3540 v.setPolar(50.0, a);
3541 double xp = 1000.0*a;
3543 RS_EllipseData ellipseData(Vector(xp, 0.0), v, 0.5, 0.0, 2 * M_PI, false);
3544 ellipse = new RS_Ellipse(graphic, ellipseData);
3546 ellipse->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width01, RS2::SolidLine));
3548 graphic->addEntity(ellipse);
3549 //graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3550 //graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3552 line = new RS_Line(graphic, RS_LineData(Vector(xp, 0.0), Vector(xp, 0.0) + v));
3553 line->setPen(RS_Pen(RS_Color(128, 128, 128), RS2::Width01, RS2::SolidLine));
3554 graphic->addEntity(line);
3557 for (double mx=-60.0; mx<60.0; mx+=1.0) {
3558 //for (double mx=0.0; mx<1.0; mx+=2.5) {
3559 VectorSolutions sol = ellipse->mapX(xp + mx);
3560 //graphic->addEntity(new RS_Point(graphic,
3561 // sol.vector2 + Vector(a*500.0, 0.0)));
3562 //graphic->addEntity(new RS_Point(graphic,
3563 // sol.vector3 + Vector(a*500.0, 0.0)));
3564 //graphic->addEntity(new RS_Point(graphic,
3565 // sol.vector4 + Vector(a*500.0, 0.0)));
3567 line = new RS_Line(graphic,
3568 RS_LineData(Vector(xp+mx,-50.0),
3569 Vector(xp+mx,50.0)));
3570 line->setPen(RS_Pen(RS_Color(60, 60, 60),
3573 graphic->addEntity(line);
3575 graphic->addEntity(new RS_Point(graphic,
3581 // different minor/minor relations
3584 for (y=-250.0; y<=250.0; y+=50.0) {
3585 for (x=-250.0; x<=250.0; x+=50.0) {
3588 ellipse = new RS_Ellipse(graphic,
3590 Vector((x/5+50.0)/2.0, 0.0),
3595 ellipse->setPen(RS_Pen(RS_Color(255, 255, 0),
3599 graphic->addEntity(ellipse);
3600 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3601 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3603 ellipse = new RS_Ellipse(graphic,
3604 v + Vector(750.0, 0.0),
3605 Vector((x/5+50.0)/2.0, 0.0),
3610 graphic->addEntity(ellipse);
3611 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3612 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3618 // different rotation angles:
3620 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3621 ellipse = new RS_Ellipse(graphic,
3622 Vector(rot*200, 500.0),
3623 Vector(50.0, 0.0).rotate(rot),
3627 graphic->addEntity(ellipse);
3628 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3629 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3633 // different arc angles:
3635 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3636 for (a1=0.0; a1<=2*M_PI+0.1; a1+=(M_PI/8)) {
3637 for (a2=a1+M_PI/8; a2<=2*M_PI+a1+0.1; a2+=(M_PI/8)) {
3638 ellipse = new RS_Ellipse(graphic,
3639 Vector(-500.0-a1*200.0-5000.0*rot,
3641 Vector(50.0, 0.0).rotate(rot),
3645 graphic->addEntity(ellipse);
3646 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3647 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3653 RS_GraphicView * v = getGraphicView();
3663 void ApplicationWindow::slotTestInsertText()
3665 RS_DEBUG->print("ApplicationWindow::slotTestInsertText()");
3667 RS_Document * d = getDocument();
3671 Drawing * graphic = (Drawing *)d;
3673 if (graphic == NULL)
3677 RS_TextData textData;
3679 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);
3680 text = new RS_Text(graphic, textData);
3681 text->setLayerToActive();
3682 text->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3683 graphic->addEntity(text);
3687 for (y=-250.0; y<=250.0; y+=50.0) {
3688 for (x=-250.0; x<=250.0; x+=50.0) {
3691 textData = RS_TextData(v,
3702 text = new RS_Text(graphic, textData);
3704 text->setLayerToActive();
3705 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3708 graphic->addEntity(text);
3713 for (x=0.0; x<M_PI*2.0; x+=0.2) {
3714 Vector v(600.0+cos(x)*50.0, 0.0+sin(x)*50.0);
3716 line = new RS_Line(graphic,
3717 RS_LineData(Vector(600.0,0.0),
3719 line->setLayerToActive();
3720 line->setPenToActive();
3721 graphic->addEntity(line);
3723 textData = RS_TextData(v,
3734 text = new RS_Text(graphic, textData);
3736 text->setLayerToActive();
3737 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3740 graphic->addEntity(text);
3743 RS_SolidData solidData = RS_SolidData(Vector(5.0, 10.0),
3745 Vector(15.0, 30.0));
3747 RS_Solid* s = new RS_Solid(graphic, solidData);
3749 s->setLayerToActive();
3750 s->setPen(RS_Pen(RS_Color(255, 255, 0),
3753 graphic->addEntity(s);
3755 RS_GraphicView* v = getGraphicView();
3766 void ApplicationWindow::slotTestInsertImage()
3768 RS_DEBUG->print("ApplicationWindow::slotTestInsertImage()");
3770 RS_Document * d = getDocument();
3774 Drawing * graphic = (Drawing *)d;
3776 if (graphic == NULL)
3780 RS_ImageData imageData;
3782 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);
3783 image = new RS_Image(graphic, imageData);
3785 image->setLayerToActive();
3786 image->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3787 graphic->addEntity(image);
3794 void ApplicationWindow::slotTestUnicode()
3796 RS_DEBUG->print("ApplicationWindow::slotTestUnicode()");
3798 slotFileOpen("./fonts/unicode.cxf", RS2::FormatCXF);
3799 RS_Document* d = getDocument();
3801 Drawing* graphic = (Drawing*)d;
3802 if (graphic==NULL) {
3810 QChar uCode; // e.g. 65 (or 'A')
3811 QString strCode; // unicde as string e.g. '[0041] A'
3813 graphic->setAutoUpdateBorders(false);
3815 for (col=0x0000; col<=0xFFF0; col+=0x10) {
3816 printf("col: %X\n", col);
3817 for (row=0x0; row<=0xF; row++) {
3818 //printf(" row: %X\n", row);
3820 uCode = QChar(col+row);
3821 //printf(" code: %X\n", uCode.unicode());
3823 strCode.setNum(uCode.unicode(), 16);
3824 while (strCode.length()<4) {
3825 strCode="0"+strCode;
3827 strCode = "[" + strCode + "] " + uCode;
3829 if (graphic->findBlock(strCode)!=NULL) {
3830 RS_InsertData d(strCode,
3831 Vector(col/0x10*20.0,row*20.0),
3832 Vector(1.0,1.0), 0.0,
3833 1, 1, Vector(0.0, 0.0),
3834 NULL, RS2::NoUpdate);
3835 ins = new RS_Insert(graphic, d);
3836 ins->setLayerToActive();
3837 ins->setPen(RS_Pen(RS_Color(255, 255, 255),
3841 graphic->addEntity(ins);
3845 graphic->setAutoUpdateBorders(true);
3846 graphic->calculateBorders();
3853 void ApplicationWindow::slotTestMath01()
3855 RS_DEBUG->print("ApplicationWindow::slotTestMath01()");
3857 RS_Document* d = getDocument();
3859 Drawing* graphic = (Drawing*)d;
3860 if (graphic==NULL) {
3865 graphic->addEntity(new RS_Line(graphic,
3866 RS_LineData(Vector(0.0,0.0),
3867 Vector(2*M_PI,0.0))));
3868 graphic->addEntity(new RS_Line(graphic,
3869 RS_LineData(Vector(0.0,-1.0),
3874 double x = 59.0/ARAD;
3875 double x_0 = 60.0/ARAD;
3876 for (a=0.01; a<2*M_PI; a+=0.01) {
3878 RS_Line* line = new RS_Line(graphic,
3879 RS_LineData(Vector(a-0.01, cos(a-0.01)),
3880 Vector(a, cos(a))));
3881 graphic->addEntity(line);
3884 graphic->addEntity(new RS_Line(graphic,
3885 RS_LineData(Vector(a-0.01,cos(x_0)-sin(x_0)*(a-0.01-x_0)),
3886 Vector(a,cos(x_0)-sin(x_0)*(a-x_0)))));
3890 graphic->addEntity(new RS_Line(graphic,
3891 RS_LineData(Vector(x,0.0),
3895 graphic->addEntity(new RS_Line(graphic,
3896 RS_LineData(Vector(x_0,0.0),
3900 //graphic->addEntity(new RS_Line(graphic,
3901 // Vector(0.0,cos(x_0)-sin(x_0)*(0.0-x_0)),
3902 // Vector(6.0,cos(x_0)-sin(x_0)*(6.0-x_0))));
3905 RS_GraphicView* v = getGraphicView();
3915 void ApplicationWindow::slotTestResize640()
3917 RS_DEBUG->print("ApplicationWindow::slotTestResize640()");
3925 void ApplicationWindow::slotTestResize800()
3927 RS_DEBUG->print("ApplicationWindow::slotTestResize800()");
3935 void ApplicationWindow::slotTestResize1024()
3937 RS_DEBUG->print("ApplicationWindow::slotTestResize1024()");
3943 * overloaded for Message box on last window exit.
3945 bool ApplicationWindow::queryExit(bool force)
3947 RS_DEBUG->print("ApplicationWindow::queryExit()");
3954 QMessageBox::information(this, QMessageBox::tr("Warning"),
3955 tr("This is a %1 version "
3956 "which terminates\n"
3957 "automatically after 10min. This software is\n"
3958 "not intended for production use. Please buy\n"
3959 "a full version of the application from\n%2.\n"
3960 "You can save your work now.")
3961 //FAIL .arg(QC_APPNAME)
3962 .arg("Architektonas")
3963 #ifdef QC_CUSTOM_VENDOR
3964 .arg(QC_CUSTOM_VENDOR),
3966 .arg("RibbonSoft, http://www.ribbonsoft.com"),
3971 QList<QMdiSubWindow *> list = workspace->subWindowList();
3973 // for(QWidget * w=list.first(); w!=NULL; w=list.next())
3974 for(int i=0; i<list.size(); i++)
3976 succ = ((MDIWindow *)list[i])->closeMDI(force);
3985 RS_DEBUG->print("ApplicationWindow::queryExit(): OK");
3991 * Handle hotkeys. Don't let it to the default handler of Qt.
3992 * it will consume them also if a text field is active
3993 * which means it's impossible to enter a command.
3995 void ApplicationWindow::keyPressEvent(QKeyEvent * e)
3998 static QTime ts = QTime();
3999 static QString firstKey = "";
4001 // single key codes:
4005 case Qt::Key_Control:
4008 case Qt::Key_CapsLock:
4010 // Q3MainWindow::keyPressEvent(e);
4011 QMainWindow::keyPressEvent(e);
4013 // forward to actions:
4014 RS_GraphicView * graphicView = getGraphicView();
4016 if (graphicView != NULL)
4017 graphicView->keyPressEvent(e);
4023 case Qt::Key_Escape:
4029 case Qt::Key_Return:
4030 if (firstKey.isEmpty())
4038 if (firstKey.isEmpty())
4040 actionHandler->slotZoomIn();
4046 if (firstKey.isEmpty())
4048 actionHandler->slotZoomOut();
4058 if (e->isAccepted())
4061 QTime now = QTime::currentTime();
4064 if (ts.msecsTo(now) < 2000)
4066 QString code = QString("%1%2").arg(firstKey).arg(QChar(e->key())).toLower();
4068 if (actionHandler->keycode(code) == false)
4072 if (QChar(e->key()).isPrint())
4073 firstKey += e->key();
4082 if (QChar(e->key()).isPrint())
4083 firstKey = e->key();
4086 // Q3MainWindow::keyPressEvent(e);
4087 QMainWindow::keyPressEvent(e);
4090 void ApplicationWindow::keyReleaseEvent(QKeyEvent * e)
4095 case Qt::Key_Control:
4098 case Qt::Key_CapsLock:
4100 // Q3MainWindow::keyReleaseEvent(e);
4101 QMainWindow::keyReleaseEvent(e);
4103 // forward to actions:
4104 RS_GraphicView * graphicView = getGraphicView();
4106 if (graphicView != NULL)
4107 graphicView->keyReleaseEvent(e);
4114 // Q3MainWindow::keyPressEvent(e);
4115 QMainWindow::keyPressEvent(e);
4119 * @return Pointer to application window.
4121 /*static*/ ApplicationWindow * ApplicationWindow::getAppWindow()
4127 * @return Pointer to workspace.
4129 QMdiArea * ApplicationWindow::getWorkspace()
4135 * @return Pointer to the currently active MDI Window or NULL if no
4136 * MDI Window is active.
4138 MDIWindow * ApplicationWindow::getMDIWindow()
4140 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::getMDIWindow: workspace=%08X", workspace);
4142 if (workspace != NULL)
4144 RS_DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=%08X", workspace->activeSubWindow());
4145 return (MDIWindow *)workspace->activeSubWindow();
4148 RS_DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=??? (workspace == NULL)");
4153 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4155 * @return Pointer to the graphic view of the currently active document
4156 * window or NULL if no window is available.
4158 /*virtual*/ RS_GraphicView * ApplicationWindow::getGraphicView()
4160 MDIWindow * m = getMDIWindow();
4163 return m->getGraphicView();
4169 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4171 * @return Pointer to the graphic document of the currently active document
4172 * window or NULL if no window is available.
4174 /*virtual*/ RS_Document * ApplicationWindow::getDocument()
4176 MDIWindow * m = getMDIWindow();
4179 return m->getDocument();
4185 * Creates a new document. Implementation from RS_MainWindowInterface.
4187 /*virtual*/ void ApplicationWindow::createNewDocument(const QString & fileName/*= QString::null*/,
4188 RS_Document * doc/*= NULL*/)
4192 if (fileName != QString::null && getDocument() != NULL)
4193 getDocument()->setFilename(fileName);
4197 * Implementation from QG_MainWindowInterface.
4199 * @return Pointer to this.
4201 /*virtual*/ QMainWindow * ApplicationWindow::GetMainWindow()
4207 * @return Pointer to action handler. Implementation from QG_MainWindowInterface.
4209 /*virtual*/ QG_ActionHandler * ApplicationWindow::getActionHandler()
4211 return actionHandler;
4215 * Implementation from QG_MainWindowInterface.
4217 /*virtual*/ void ApplicationWindow::showSimulationControls()
4220 simulationDockWindow->show();
4226 * @return Pointer to the qsa object.
4228 QSProject * ApplicationWindow::getQSAProject()
4230 if (scripter != NULL)
4231 return scripter->getQSAProject();
4238 * Implementation from QG_MainWindowInterface.
4240 /*virtual*/ void ApplicationWindow::setFocus2()