1 // applicationwindow.cpp
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/17/2010 Added this text. :-)
13 // JLH 05/27/2010 Finished refactoring old Qt3 based action handling code to
14 // Qt4's much more sensible action handling
17 #include "applicationwindow.h"
20 #include "rs_actiondrawlinefree.h"
21 #include "rs_actionlibraryinsert.h"
22 #include "rs_actionprintpreview.h"
23 #include "rs_creation.h"
24 #include "rs_dialogfactory.h"
25 #include "rs_dimaligned.h"
26 #include "rs_dimlinear.h"
27 #include "rs_dimradial.h"
28 #include "rs_ellipse.h"
29 #include "rs_fileio.h"
31 #include "rs_insert.h"
33 #include "paintintf.h"
34 #include "rs_script.h"
35 #include "rs_scriptlist.h"
38 #include "rs_staticgraphicview.h"
39 #include "rs_system.h"
44 #include "rs_camdialog.h"
45 #include "rs_simulationcontrols.h"
48 #include "qg_colorbox.h"
49 #include "qg_filedialog.h"
50 #include "qg_pentoolbar.h"
51 #include "recentfiles.h"
52 #include "cadtoolbar.h"
53 #include "cadtoolbarmain.h"
54 #include "coordinatewidget.h"
55 #include "dlgimageoptions.h"
56 #include "mousewidget.h"
57 #include "selectionwidget.h"
59 #include "createqtactions.h"
60 #include "qc_dialogfactory.h"
61 #include "qg_graphicview.h"
63 #include "mdiwindow.h"
65 ApplicationWindow * ApplicationWindow::appWindow = NULL;
68 # define QC_APP_ICON "qcad.png"
71 # define QC_APP_ICON16 "qcad16.png"
74 extern QSplashScreen * splash;
77 * Constructor. Initializes the app.
79 ApplicationWindow::ApplicationWindow():
80 // Q3MainWindow(0, "", Qt::WDestructiveClose), QG_MainWindowInterface()
81 QMainWindow((QWidget *)NULL/*,this is not a Qt::WindowFlags --> Qt::WA_DeleteOnClose*/), QG_MainWindowInterface()
83 RS_DEBUG->print("ApplicationWindow::ApplicationWindow");
86 //no assistant = NULL;
89 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: setting icon");
90 // setIcon(qPixmapFromMimeSource(QC_APP_ICON));
91 // setWindowIcon(qPixmapFromMimeSource(QC_APP_ICON));
92 setWindowIcon(QIcon(":/res/" QC_APP_ICON));
93 CreateQtActions(this);
95 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler");
96 actionHandler = new QG_ActionHandler(this);
97 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler: OK");
100 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating scripter");
101 scripter = new QS_Scripter(this, this);
102 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating scripter: OK");
105 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init view");
107 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init toolbar");
109 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init actions");
111 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init menu bar");
113 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init status bar");
116 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory");
117 dialogFactory = new QC_DialogFactory(this, optionWidget);
118 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory: OK");
119 RS_DEBUG->print("setting dialog factory object");
121 if (RS_DialogFactory::instance() == NULL)
122 RS_DEBUG->print("no RS_DialogFactory instance");
124 RS_DEBUG->print("got RS_DialogFactory instance");
126 RS_DialogFactory::instance()->setFactoryObject(dialogFactory);
127 RS_DEBUG->print("setting dialog factory object: OK");
129 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init settings");
132 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init MDI");
135 // Disable menu and toolbar items
136 emit windowsChanged(FALSE);
138 //FAIL statusBar()->showMessage(QC_APPNAME " Ready", 2000);
139 statusBar()->showMessage("Architektonas Ready", 2000);
140 //setFocusPolicy(WheelFocus);
146 ApplicationWindow::~ApplicationWindow()
148 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow");
150 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting scripter");
152 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting scripter: OK");
155 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting action handler");
156 delete actionHandler;
157 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting action handler: OK");
159 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory");
160 delete dialogFactory;
161 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory: OK");
163 //no RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: "
164 // "deleting assistant..");
165 // if (assistant!=NULL) {
168 // RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: "
169 // "deleting assistant: OK");
170 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: OK");
174 * Runs the start script if scripting is available.
176 void ApplicationWindow::slotRunStartScript()
178 slotRunScript("autostart.qs");
182 * Runs a script. The action that triggers this slot has to carry the
183 * name of the script file.
185 void ApplicationWindow::slotRunScript()
187 RS_DEBUG->print("ApplicationWindow::slotRunScript");
189 const QObject * s = sender();
193 QString script = ((QAction *)s)->text();
194 RS_DEBUG->print("ApplicationWindow::slotRunScript: %s", script.toLatin1().data());
195 slotRunScript(script);
200 * Runs the script with the given name.
202 void ApplicationWindow::slotRunScript(const QString & name)
205 RS_DEBUG->print("ApplicationWindow::slotRunScript");
207 if (scripter == NULL)
209 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotRunScript: scripter not initialized");
213 statusBar()->showMessage(tr("Running script '%1'").arg(name), 2000);
215 QStringList scriptList = RS_SYSTEM->getScriptList();
216 scriptList.append(RS_SYSTEM->getHomeDir() + "/.qcad/" + name);
218 for (QStringList::Iterator it = scriptList.begin(); it!=scriptList.end(); ++it)
220 RS_DEBUG->print("ApplicationWindow::slotRunScript: checking script '%s'", (*it).toLatin1().data();
223 if (fi.exists() && fi.fileName() == name)
225 RS_DEBUG->print("ApplicationWindow::slotRunScript: running '%s'", (*it).toLatin1().data());
226 scripter->runScript(*it, "main");
233 * Called from toolbar buttons that were added by scripts to
236 void ApplicationWindow::slotInsertBlock()
238 const QObject * s = sender();
242 QString block = ((QAction *)s)->text();
243 RS_DEBUG->print("ApplicationWindow::slotInsertBlock: %s", block.toLatin1().data());
244 slotInsertBlock(block);
249 * Called to insert blocks.
251 void ApplicationWindow::slotInsertBlock(const QString & name)
253 RS_DEBUG->print("ApplicationWindow::slotInsertBlock: '%s'", name.toLatin1().data());
255 statusBar()->showMessage(tr("Inserting block '%1'").arg(name), 2000);
257 GraphicView * graphicView = getGraphicView();
258 RS_Document * document = getDocument();
260 if (graphicView && document)
262 RS_ActionLibraryInsert * action = new RS_ActionLibraryInsert(*document, *graphicView);
263 action->setFile(name);
264 graphicView->setCurrentAction(action);
269 * Shows the main application window and a splash screen.
271 void ApplicationWindow::show()
273 #ifdef QSPLASHSCREEN_H
280 #ifdef QSPLASHSCREEN_H
284 qApp->processEvents();
285 splash->clearMessage();
286 # ifdef QC_DELAYED_SPLASH_SCREEN
287 QTimer::singleShot(1000 * 2, this, SLOT(finishSplashScreen()));
289 finishSplashScreen();
296 * Called when the splash screen has to terminate.
298 void ApplicationWindow::finishSplashScreen()
300 #ifdef QSPLASHSCREEN_H
303 splash->finish(this);
311 * Close Event. Called when the user tries to close the app.
313 void ApplicationWindow::closeEvent(QCloseEvent * /*ce*/)
315 RS_DEBUG->print("ApplicationWindow::closeEvent()");
317 RS_DEBUG->print("ApplicationWindow::closeEvent(): OK");
321 * Handles right-clicks for moving back to the last cad tool bar.
323 void ApplicationWindow::mouseReleaseEvent(QMouseEvent * e)
325 if (e->button() == Qt::RightButton && cadToolBar != NULL)
326 cadToolBar->showToolBarMain();
332 * Initializes the MDI workspace.
334 void ApplicationWindow::initMDI()
336 RS_DEBUG->print("ApplicationWindow::initMDI() begin");
338 /* Could use QVBoxLayout instead of Q3VBox, but do we even need to? */
339 // Q3VBox * vb = new Q3VBox(this);
340 // vb->setFrameStyle(Q3Frame::StyledPanel | Q3Frame::Sunken);
341 // workspace = new QMdiArea(vb);
342 workspace = new QMdiArea(this);
343 // workspace->setScrollBarsEnabled(true);
344 // setCentralWidget(vb);
345 setCentralWidget(workspace);//JLH:hmm. (Yes, it works! \o/)
346 RS_DEBUG->print("ApplicationWindow::initMDI(): workspace=%08X", workspace);
348 //#warning "Object::connect: No such signal QMdiArea::windowActivated(QWidget *)"
349 // connect(workspace, SIGNAL(windowActivated(QWidget *)), this, SLOT(slotWindowActivated(QWidget *)));
350 connect(workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this,
351 SLOT(slotWindowActivated(QMdiSubWindow *)));
353 RS_DEBUG->print("ApplicationWindow::initMDI() end");
357 * Initializes all QActions of the application.
358 * (Actually, it creates all application menus & toolbars. All actions are
359 * created in CreateQtActions() and simply referenced here.)
361 void ApplicationWindow::initActions()
363 RS_DEBUG->print("ApplicationWindow::initActions()");
368 QMenu * menu = new QMenu(tr("&File"), this);
369 QToolBar * tb = fileToolBar;
370 tb->setWindowTitle("File");
371 // tb->setCloseMode(Q3DockWindow::Undocked);
373 menu->addAction(actionFileNew);
374 tb->addAction(actionFileNew);
375 connect(actionFileNew, SIGNAL(activated()), this, SLOT(slotFileNew()));
376 menu->addAction(actionFileOpen);
377 tb->addAction(actionFileOpen);
378 connect(actionFileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen()));
379 menu->addAction(actionFileSave);
380 tb->addAction(actionFileSave);
381 connect(actionFileSave, SIGNAL(activated()), this, SLOT(slotFileSave()));
382 connect(this, SIGNAL(windowsChanged(bool)), actionFileSave, SLOT(setEnabled(bool)));
383 menu->addAction(actionFileSaveAs);
384 connect(actionFileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs()));
385 connect(this, SIGNAL(windowsChanged(bool)), actionFileSaveAs, SLOT(setEnabled(bool)));
386 menu->addAction(actionFileExport);
387 connect(actionFileExport, SIGNAL(activated()), this, SLOT(slotFileExport()));
388 connect(this, SIGNAL(windowsChanged(bool)), actionFileExport, SLOT(setEnabled(bool)));
390 menu->addSeparator();
392 menu->addAction(actionFileClose);
393 connect(actionFileClose, SIGNAL(activated()), this, SLOT(slotFileClose()));
394 connect(this, SIGNAL(windowsChanged(bool)), actionFileClose, SLOT(setEnabled(bool)));
396 menu->addSeparator();
398 menu->addAction(actionFilePrint);
399 tb->addAction(actionFilePrint);
400 connect(actionFilePrint, SIGNAL(activated()), this, SLOT(slotFilePrint()));
401 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrint, SLOT(setEnabled(bool)));
402 menu->addAction(actionFilePrintPreview);
403 tb->addAction(actionFilePrintPreview);
404 connect(actionFilePrintPreview, SIGNAL(toggled(bool)), this, SLOT(slotFilePrintPreview(bool)));
405 connect(this, SIGNAL(printPreviewChanged(bool)), actionFilePrintPreview, SLOT(setOn(bool)));
406 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrintPreview, SLOT(setEnabled(bool)));
408 menu->addSeparator();
410 menu->addAction(actionFileQuit);
411 connect(actionFileQuit, SIGNAL(activated()), this, SLOT(slotFileQuit()));
413 menu->addSeparator();
415 menuBar()->addMenu(menu);
416 addToolBar(Qt::TopToolBarArea, tb);
422 menu = new QMenu(tr("&Edit"), this);
424 tb->setWindowTitle("Edit");
425 // tb->setCloseMode(Q3DockWindow::Undocked);
427 // action = actionFactory.createAction(RS2::ActionEditUndo, actionHandler);
428 menu->addAction(actionEditUndo);
429 tb->addAction(actionEditUndo);
430 connect(actionEditUndo, SIGNAL(activated()), actionHandler, SLOT(slotEditUndo()));
431 connect(this, SIGNAL(windowsChanged(bool)), actionEditUndo, SLOT(setEnabled(bool)));
432 // action = actionFactory.createAction(RS2::ActionEditRedo, actionHandler);
433 menu->addAction(actionEditRedo);
434 tb->addAction(actionEditRedo);
435 connect(actionEditRedo, SIGNAL(activated()), actionHandler, SLOT(slotEditRedo()));
436 connect(this, SIGNAL(windowsChanged(bool)), actionEditRedo, SLOT(setEnabled(bool)));
439 menu->addSeparator();
441 // action = actionFactory.createAction(RS2::ActionEditCut, actionHandler);
442 menu->addAction(actionEditCut);
443 tb->addAction(actionEditCut);
444 connect(actionEditCut, SIGNAL(activated()), actionHandler, SLOT(slotEditCut()));
445 connect(this, SIGNAL(windowsChanged(bool)), actionEditCut, SLOT(setEnabled(bool)));
446 // action = actionFactory.createAction(RS2::ActionEditCopy, actionHandler);
447 menu->addAction(actionEditCopy);
448 tb->addAction(actionEditCopy);
449 connect(actionEditCopy, SIGNAL(activated()), actionHandler, SLOT(slotEditCopy()));
450 connect(this, SIGNAL(windowsChanged(bool)), actionEditCopy, SLOT(setEnabled(bool)));
451 // action = actionFactory.createAction(RS2::ActionEditPaste, actionHandler);
452 menu->addAction(actionEditPaste);
453 tb->addAction(actionEditPaste);
454 connect(actionEditPaste, SIGNAL(activated()), actionHandler, SLOT(slotEditPaste()));
455 connect(this, SIGNAL(windowsChanged(bool)), actionEditPaste, SLOT(setEnabled(bool)));
457 menu->addSeparator();
459 menu->addAction(actionOptionsGeneral);
460 connect(actionOptionsGeneral, SIGNAL(activated()), this, SLOT(slotOptionsGeneral()));
461 menu->addAction(actionOptionsDrawing);
462 connect(actionOptionsDrawing, SIGNAL(activated()), actionHandler, SLOT(slotOptionsDrawing()));
463 connect(this, SIGNAL(windowsChanged(bool)), actionOptionsDrawing, SLOT(setEnabled(bool)));
465 menuBar()->addMenu(menu);
466 addToolBar(Qt::TopToolBarArea, tb);
470 //menu = new QPopupMenu(this);
471 //menuBar()->insertItem(tr("&Options"), menu);
473 // Viewing / Zooming actions:
475 // menu = new Q3PopupMenu(this);
476 menu = new QMenu(tr("&View"), this);
477 //obsolete: menu->setCheckable(true);
479 tb->setWindowTitle("View");
480 // tb->setCloseMode(Q3DockWindow::Undocked);
482 // action = actionFactory.createAction(RS2::ActionViewGrid, this);
483 menu->addAction(actionViewGrid);
484 tb->addAction(actionViewGrid);
485 actionViewGrid->setChecked(true);
486 connect(actionViewGrid, SIGNAL(toggled(bool)), this, SLOT(slotViewGrid(bool)));
487 connect(this, SIGNAL(gridChanged(bool)), actionViewGrid, SLOT(setOn(bool)));
488 connect(this, SIGNAL(windowsChanged(bool)), actionViewGrid, SLOT(setEnabled(bool)));
490 settings.beginGroup("Appearance");
491 bool draftMode = settings.value("DraftMode", false).toBool();
494 // action = actionFactory.createAction(RS2::ActionViewDraft, this);
495 menu->addAction(actionViewDraft);
496 tb->addAction(actionViewDraft);
497 actionViewDraft->setChecked(draftMode);
498 connect(actionViewDraft, SIGNAL(toggled(bool)), this, SLOT(slotViewDraft(bool)));
499 connect(this, SIGNAL(draftChanged(bool)), actionViewDraft, SLOT(setOn(bool)));
500 connect(this, SIGNAL(windowsChanged(bool)), actionViewDraft, SLOT(setEnabled(bool)));
503 action = actionFactory.createAction(RS2::ActionViewLayerList, this);
505 action->setChecked(true);
506 action = actionFactory.createAction(RS2::ActionViewBlockList, this);
508 action->setChecked(true);
509 action = actionFactory.createAction(RS2::ActionViewOptionToolbar, this);
511 action->setChecked(true);
512 action = actionFactory.createAction(RS2::ActionViewCommandLine, this);
514 action->setChecked(true);*/
516 // action = actionFactory.createAction(RS2::ActionZoomRedraw, actionHandler);
517 menu->addAction(actionZoomRedraw);
518 tb->addAction(actionZoomRedraw);
519 connect(actionZoomRedraw, SIGNAL(activated()), actionHandler, SLOT(slotZoomRedraw()));
520 connect(this, SIGNAL(windowsChanged(bool)), actionZoomRedraw, SLOT(setEnabled(bool)));
521 // action = actionFactory.createAction(RS2::ActionZoomIn, actionHandler);
522 menu->addAction(actionZoomIn);
523 tb->addAction(actionZoomIn);
524 connect(actionZoomIn, SIGNAL(activated()), actionHandler, SLOT(slotZoomIn()));
525 connect(this, SIGNAL(windowsChanged(bool)), actionZoomIn, SLOT(setEnabled(bool)));
526 // action = actionFactory.createAction(RS2::ActionZoomOut, actionHandler);
527 menu->addAction(actionZoomOut);
528 tb->addAction(actionZoomOut);
529 connect(actionZoomOut, SIGNAL(activated()), actionHandler, SLOT(slotZoomOut()));
530 connect(this, SIGNAL(windowsChanged(bool)), actionZoomOut, SLOT(setEnabled(bool)));
531 // action = actionFactory.createAction(RS2::ActionZoomAuto, actionHandler);
532 menu->addAction(actionZoomAuto);
533 tb->addAction(actionZoomAuto);
534 connect(actionZoomAuto, SIGNAL(activated()), actionHandler, SLOT(slotZoomAuto()));
535 connect(this, SIGNAL(windowsChanged(bool)), actionZoomAuto, SLOT(setEnabled(bool)));
536 // action = actionFactory.createAction(RS2::ActionZoomPrevious, actionHandler);
537 menu->addAction(actionZoomPrevious);
538 tb->addAction(actionZoomPrevious);
539 connect(actionZoomPrevious, SIGNAL(activated()), actionHandler, SLOT(slotZoomPrevious()));
540 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPrevious, SLOT(setEnabled(bool)));
541 // action = actionFactory.createAction(RS2::ActionZoomWindow, actionHandler);
542 menu->addAction(actionZoomWindow);
543 tb->addAction(actionZoomWindow);
544 connect(actionZoomWindow, SIGNAL(activated()), actionHandler, SLOT(slotZoomWindow()));
545 connect(this, SIGNAL(windowsChanged(bool)), actionZoomWindow, SLOT(setEnabled(bool)));
546 // action = actionFactory.createAction(RS2::ActionZoomPan, actionHandler);
547 menu->addAction(actionZoomPan);
548 tb->addAction(actionZoomPan);
549 connect(actionZoomPan, SIGNAL(activated()), actionHandler, SLOT(slotZoomPan()));
550 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPan, SLOT(setEnabled(bool)));
552 menu->addSeparator();
554 // action = actionFactory.createAction(RS2::ActionViewStatusBar, this);
555 menu->addAction(actionViewStatusbar);
556 actionViewStatusbar->setChecked(true);
557 connect(actionViewStatusbar, SIGNAL(toggled(bool)), this, SLOT(slotViewStatusBar(bool)));
560 menu->insertItem(tr("Vie&ws"), createDockWindowMenu(NoToolBars));
561 menu->insertItem(tr("Tool&bars"), createDockWindowMenu(OnlyToolBars));
563 //Actually, this isn't really needed... This crap is maintained by Qt...
564 //#warning "!!! More stuff to port to Qt4 !!!"
567 menu->addAction(actionFocusCommandLine);
568 connect(actionFocusCommandLine, SIGNAL(activated()), this, SLOT(slotFocusCommandLine()));
569 connect(this, SIGNAL(windowsChanged(bool)), actionFocusCommandLine, SLOT(setEnabled(bool)));
570 menuBar()->addMenu(menu);
571 //addToolBar(tb, tr("View"));
572 // addDockWindow(tb, tr("View"), Qt::DockTop);
573 addToolBar(Qt::TopToolBarArea, tb);
575 // Selecting actions:
577 menu = new QMenu(tr("&Select"), this);
578 // action = actionFactory.createAction(RS2::ActionDeselectAll, actionHandler);
579 menu->addAction(actionDeselectAll);
580 connect(actionDeselectAll, SIGNAL(activated()), actionHandler, SLOT(slotDeselectAll()));
581 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectAll, SLOT(setEnabled(bool)));
582 // action = actionFactory.createAction(RS2::ActionSelectAll, actionHandler);
583 menu->addAction(actionSelectAll);
584 connect(actionSelectAll, SIGNAL(activated()), actionHandler, SLOT(slotSelectAll()));
585 connect(this, SIGNAL(windowsChanged(bool)), actionSelectAll, SLOT(setEnabled(bool)));
586 // action = actionFactory.createAction(RS2::ActionSelectSingle, actionHandler);
587 menu->addAction(actionSelectSingle);
588 connect(actionSelectSingle, SIGNAL(activated()), actionHandler, SLOT(slotSelectSingle()));
589 connect(this, SIGNAL(windowsChanged(bool)), actionSelectSingle, SLOT(setEnabled(bool)));
590 // action = actionFactory.createAction(RS2::ActionSelectContour, actionHandler);
591 menu->addAction(actionSelectContour);
592 connect(actionSelectContour, SIGNAL(activated()), actionHandler, SLOT(slotSelectContour()));
593 connect(this, SIGNAL(windowsChanged(bool)), actionSelectContour, SLOT(setEnabled(bool)));
594 // action = actionFactory.createAction(RS2::ActionDeselectWindow, actionHandler);
595 menu->addAction(actionDeselectWindow);
596 connect(actionDeselectWindow, SIGNAL(activated()), actionHandler, SLOT(slotDeselectWindow()));
597 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectWindow, SLOT(setEnabled(bool)));
598 // action = actionFactory.createAction(RS2::ActionSelectWindow, actionHandler);
599 menu->addAction(actionSelectWindow);
600 connect(actionSelectWindow, SIGNAL(activated()), actionHandler, SLOT(slotSelectWindow()));
601 connect(this, SIGNAL(windowsChanged(bool)), actionSelectWindow, SLOT(setEnabled(bool)));
602 // action = actionFactory.createAction(RS2::ActionSelectInvert, actionHandler);
603 menu->addAction(actionSelectInvert);
604 connect(actionSelectInvert, SIGNAL(activated()), actionHandler, SLOT(slotSelectInvert()));
605 connect(this, SIGNAL(windowsChanged(bool)), actionSelectInvert, SLOT(setEnabled(bool)));
606 // action = actionFactory.createAction(RS2::ActionSelectIntersected, actionHandler);
607 menu->addAction(actionSelectIntersected);
608 connect(actionSelectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotSelectIntersected()));
609 connect(this, SIGNAL(windowsChanged(bool)), actionSelectIntersected, SLOT(setEnabled(bool)));
610 // action = actionFactory.createAction(RS2::ActionDeselectIntersected, actionHandler);
611 menu->addAction(actionDeselectIntersected);
612 connect(actionDeselectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotDeselectIntersected()));
613 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectIntersected, SLOT(setEnabled(bool)));
614 // action = actionFactory.createAction(RS2::ActionSelectLayer, actionHandler);
615 menu->addAction(actionSelectLayer);
616 connect(actionSelectLayer, SIGNAL(activated()), actionHandler, SLOT(slotSelectLayer()));
617 connect(this, SIGNAL(windowsChanged(bool)), actionSelectLayer, SLOT(setEnabled(bool)));
618 menuBar()->addMenu(menu);
622 menu = new QMenu(tr("&Draw"), this);
625 QMenu * subMenu = new QMenu(tr("&Point"), this);
626 // action = actionFactory.createAction(RS2::ActionDrawPoint, actionHandler);
627 subMenu->addAction(actionDrawPoint);
628 connect(actionDrawPoint, SIGNAL(activated()), actionHandler, SLOT(slotDrawPoint()));
629 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPoint, SLOT(setEnabled(bool)));
630 menu->addMenu(subMenu);
633 subMenu = new QMenu(tr("&Line"), this);
634 // action = actionFactory.createAction(RS2::ActionDrawLine, actionHandler);
635 subMenu->addAction(actionDrawLine);
636 connect(actionDrawLine, SIGNAL(activated()), actionHandler, SLOT(slotDrawLine()));
637 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLine, SLOT(setEnabled(bool)));
638 // action = actionFactory.createAction(RS2::ActionDrawLineAngle, actionHandler);
639 subMenu->addAction(actionDrawLineAngle);
640 connect(actionDrawLineAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineAngle()));
641 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineAngle, SLOT(setEnabled(bool)));
642 // action = actionFactory.createAction(RS2::ActionDrawLineHorizontal, actionHandler);
643 subMenu->addAction(actionDrawLineHorizontal);
644 connect(actionDrawLineHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineHorizontal()));
645 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineHorizontal, SLOT(setEnabled(bool)));
646 // action = actionFactory.createAction(RS2::ActionDrawLineVertical, actionHandler);
647 subMenu->addAction(actionDrawLineVertical);
648 connect(actionDrawLineVertical, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineVertical()));
649 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineVertical, SLOT(setEnabled(bool)));
650 // action = actionFactory.createAction(RS2::ActionDrawLineRectangle, actionHandler);
651 subMenu->addAction(actionDrawLineRectangle);
652 connect(actionDrawLineRectangle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRectangle()));
653 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRectangle, SLOT(setEnabled(bool)));
654 // action = actionFactory.createAction(RS2::ActionDrawLineParallel, actionHandler);
655 subMenu->addAction(actionDrawLineParallel);
656 connect(actionDrawLineParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallel()));
657 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallel, SLOT(setEnabled(bool)));
658 // action = actionFactory.createAction(RS2::ActionDrawLineParallelThrough, actionHandler);
659 subMenu->addAction(actionDrawLineParallelThrough);
660 connect(actionDrawLineParallelThrough, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallelThrough()));
661 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallelThrough, SLOT(setEnabled(bool)));
662 // action = actionFactory.createAction(RS2::ActionDrawLineBisector, actionHandler);
663 subMenu->addAction(actionDrawLineBisector);
664 connect(actionDrawLineBisector, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineBisector()));
665 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineBisector, SLOT(setEnabled(bool)));
666 // action = actionFactory.createAction(RS2::ActionDrawLineTangent1, actionHandler);
667 subMenu->addAction(actionDrawLineTangent1);
668 connect(actionDrawLineTangent1, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent1()));
669 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent1, SLOT(setEnabled(bool)));
670 // action = actionFactory.createAction(RS2::ActionDrawLineTangent2, actionHandler);
671 subMenu->addAction(actionDrawLineTangent2);
672 connect(actionDrawLineTangent2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent2()));
673 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent2, SLOT(setEnabled(bool)));
674 // action = actionFactory.createAction(RS2::ActionDrawLineOrthogonal, actionHandler);
675 subMenu->addAction(actionDrawLineOrthogonal);
676 connect(actionDrawLineOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineOrthogonal()));
677 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineOrthogonal, SLOT(setEnabled(bool)));
678 // action = actionFactory.createAction(RS2::ActionDrawLineRelAngle, actionHandler);
679 subMenu->addAction(actionDrawLineRelAngle);
680 connect(actionDrawLineRelAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRelAngle()));
681 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRelAngle, SLOT(setEnabled(bool)));
682 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon, actionHandler);
683 subMenu->addAction(actionDrawLinePolygon);
684 connect(actionDrawLinePolygon, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon()));
685 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon, SLOT(setEnabled(bool)));
686 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon2, actionHandler);
687 subMenu->addAction(actionDrawLinePolygon2);
688 connect(actionDrawLinePolygon2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon2()));
689 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon2, SLOT(setEnabled(bool)));
690 // action = actionFactory.createAction(RS2::ActionDrawLineFree, actionHandler);
691 subMenu->addAction(actionDrawLineFree);
692 connect(actionDrawLineFree, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineFree()));
693 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineFree, SLOT(setEnabled(bool)));
694 menu->addMenu(subMenu);
697 subMenu = new QMenu(tr("&Arc"), this);
698 subMenu->addAction(actionDrawArc);
699 connect(actionDrawArc, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc()));
700 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc, SLOT(setEnabled(bool)));
701 subMenu->addAction(actionDrawArc3P);
702 connect(actionDrawArc3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc3P()));
703 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc3P, SLOT(setEnabled(bool)));
704 subMenu->addAction(actionDrawArcParallel);
705 connect(actionDrawArcParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcParallel()));
706 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcParallel, SLOT(setEnabled(bool)));
707 subMenu->addAction(actionDrawArcTangential);
708 connect(actionDrawArcTangential, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcTangential()));
709 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcTangential, SLOT(setEnabled(bool)));
710 menu->addMenu(subMenu);
713 subMenu = new QMenu(tr("&Circle"), this);
714 // action = actionFactory.createAction(RS2::ActionDrawCircle, actionHandler);
715 subMenu->addAction(actionDrawCircle);
716 connect(actionDrawCircle, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle()));
717 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle, SLOT(setEnabled(bool)));
718 // action = actionFactory.createAction(RS2::ActionDrawCircleCR, actionHandler);
719 subMenu->addAction(actionDrawCircleCR);
720 connect(actionDrawCircleCR, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleCR()));
721 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleCR, SLOT(setEnabled(bool)));
722 // action = actionFactory.createAction(RS2::ActionDrawCircle2P, actionHandler);
723 subMenu->addAction(actionDrawCircle2P);
724 connect(actionDrawCircle2P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle2P()));
725 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle2P, SLOT(setEnabled(bool)));
726 // action = actionFactory.createAction(RS2::ActionDrawCircle3P, actionHandler);
727 subMenu->addAction(actionDrawCircle3P);
728 connect(actionDrawCircle3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle3P()));
729 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle3P, SLOT(setEnabled(bool)));
730 // action = actionFactory.createAction(RS2::ActionDrawCircleParallel, actionHandler);
731 subMenu->addAction(actionDrawCircleParallel);
732 connect(actionDrawCircleParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleParallel()));
733 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleParallel, SLOT(setEnabled(bool)));
734 menu->addMenu(subMenu);
737 subMenu = new QMenu(tr("&Ellipse"), this);
738 // action = actionFactory.createAction(RS2::ActionDrawEllipseAxis, actionHandler);
739 subMenu->addAction(actionDrawEllipseAxis);
740 connect(actionDrawEllipseAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseAxis()));
741 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseAxis, SLOT(setEnabled(bool)));
742 // action = actionFactory.createAction(RS2::ActionDrawEllipseArcAxis, actionHandler);
743 subMenu->addAction(actionDrawEllipseArcAxis);
744 connect(actionDrawEllipseArcAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseArcAxis()));
745 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseArcAxis, SLOT(setEnabled(bool)));
746 menu->addMenu(subMenu);
749 subMenu = new QMenu(tr("&Spline"), this);
750 // action = actionFactory.createAction(RS2::ActionDrawSpline, actionHandler);
751 subMenu->addAction(actionDrawSpline);
752 connect(actionDrawSpline, SIGNAL(activated()), actionHandler, SLOT(slotDrawSpline()));
753 connect(this, SIGNAL(windowsChanged(bool)), actionDrawSpline, SLOT(setEnabled(bool)));
754 menu->addMenu(subMenu);
757 subMenu = new QMenu(tr("&Polyline"), this);
758 // action = actionFactory.createAction(RS2::ActionDrawPolyline, actionHandler);
759 subMenu->addAction(actionDrawPolyline);
760 connect(actionDrawPolyline, SIGNAL(activated()), actionHandler, SLOT(slotDrawPolyline()));
761 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPolyline, SLOT(setEnabled(bool)));
762 // action = actionFactory.createAction(RS2::ActionPolylineAdd, actionHandler);
763 subMenu->addAction(actionPolylineAdd);
764 connect(actionPolylineAdd, SIGNAL(activated()), actionHandler, SLOT(slotPolylineAdd()));
765 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineAdd, SLOT(setEnabled(bool)));
766 // action = actionFactory.createAction(RS2::ActionPolylineDel, actionHandler);
767 subMenu->addAction(actionPolylineDel);
768 connect(actionPolylineDel, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDel()));
769 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDel, SLOT(setEnabled(bool)));
770 // action = actionFactory.createAction(RS2::ActionPolylineDelBetween, actionHandler);
771 subMenu->addAction(actionPolylineDelBetween);
772 connect(actionPolylineDelBetween, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDelBetween()));
773 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDelBetween, SLOT(setEnabled(bool)));
774 // action = actionFactory.createAction(RS2::ActionPolylineTrim, actionHandler);
775 subMenu->addAction(actionPolylineTrim);
776 connect(actionPolylineTrim, SIGNAL(activated()), actionHandler, SLOT(slotPolylineTrim()));
777 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineTrim, SLOT(setEnabled(bool)));
778 menu->addMenu(subMenu);
781 // action = actionFactory.createAction(RS2::ActionDrawText, actionHandler);
782 menu->addAction(actionDrawText);
783 connect(actionDrawText, SIGNAL(activated()), actionHandler, SLOT(slotDrawText()));
784 connect(this, SIGNAL(windowsChanged(bool)), actionDrawText, SLOT(setEnabled(bool)));
786 // action = actionFactory.createAction(RS2::ActionDrawHatch, actionHandler);
787 menu->addAction(actionDrawHatch);
788 connect(actionDrawHatch, SIGNAL(activated()), actionHandler, SLOT(slotDrawHatch()));
789 connect(this, SIGNAL(windowsChanged(bool)), actionDrawHatch, SLOT(setEnabled(bool)));
791 // action = actionFactory.createAction(RS2::ActionDrawImage, actionHandler);
792 menu->addAction(actionDrawImage);
793 connect(actionDrawImage, SIGNAL(activated()), actionHandler, SLOT(slotDrawImage()));
794 connect(this, SIGNAL(windowsChanged(bool)), actionDrawImage, SLOT(setEnabled(bool)));
795 // menuBar()->insertItem(tr("&Draw"), menu);
796 menuBar()->addMenu(menu);
798 // Dimensioning actions:
804 menu = new QMenu(tr("&Dimension"), this);
805 // action = actionFactory.createAction(RS2::ActionDimAligned, actionHandler);
806 menu->addAction(actionDimAligned);
807 connect(actionDimAligned, SIGNAL(activated()), actionHandler, SLOT(slotDimAligned()));
808 connect(this, SIGNAL(windowsChanged(bool)), actionDimAligned, SLOT(setEnabled(bool)));
809 // action = actionFactory.createAction(RS2::ActionDimLinear, actionHandler);
810 menu->addAction(actionDimLinear);
811 connect(actionDimLinear, SIGNAL(activated()), actionHandler, SLOT(slotDimLinear()));
812 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinear, SLOT(setEnabled(bool)));
813 // action = actionFactory.createAction(RS2::ActionDimLinearHor, actionHandler);
814 menu->addAction(actionDimLinearHor);
815 connect(actionDimLinearHor, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearHor()));
816 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearHor, SLOT(setEnabled(bool)));
817 // action = actionFactory.createAction(RS2::ActionDimLinearVer, actionHandler);
818 menu->addAction(actionDimLinearVer);
819 connect(actionDimLinearVer, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearVer()));
820 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearVer, SLOT(setEnabled(bool)));
821 // action = actionFactory.createAction(RS2::ActionDimRadial, actionHandler);
822 menu->addAction(actionDimRadial);
823 connect(actionDimRadial, SIGNAL(activated()), actionHandler, SLOT(slotDimRadial()));
824 connect(this, SIGNAL(windowsChanged(bool)), actionDimRadial, SLOT(setEnabled(bool)));
825 // action = actionFactory.createAction(RS2::ActionDimDiametric, actionHandler);
826 menu->addAction(actionDimDiametric);
827 connect(actionDimDiametric, SIGNAL(activated()), actionHandler, SLOT(slotDimDiametric()));
828 connect(this, SIGNAL(windowsChanged(bool)), actionDimDiametric, SLOT(setEnabled(bool)));
829 // action = actionFactory.createAction(RS2::ActionDimAngular, actionHandler);
830 menu->addAction(actionDimAngular);
831 connect(actionDimAngular, SIGNAL(activated()), actionHandler, SLOT(slotDimAngular()));
832 connect(this, SIGNAL(windowsChanged(bool)), actionDimAngular, SLOT(setEnabled(bool)));
833 // action = actionFactory.createAction(RS2::ActionDimLeader, actionHandler);
834 menu->addAction(actionDimLeader);
835 connect(actionDimLeader, SIGNAL(activated()), actionHandler, SLOT(slotDimLeader()));
836 connect(this, SIGNAL(windowsChanged(bool)), actionDimLeader, SLOT(setEnabled(bool)));
838 m->insertItem(tr("&Dimension"), menu);
840 menuBar()->addMenu(menu);
843 // Modifying actions:
845 menu = new QMenu(tr("&Modify"), this);
846 // action = actionFactory.createAction(RS2::ActionModifyMove, actionHandler);
847 menu->addAction(actionModifyMove);
848 connect(actionModifyMove, SIGNAL(activated()), actionHandler, SLOT(slotModifyMove()));
849 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMove, SLOT(setEnabled(bool)));
850 // action = actionFactory.createAction(RS2::ActionModifyRotate, actionHandler);
851 menu->addAction(actionModifyRotate);
852 connect(actionModifyRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate()));
853 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate, SLOT(setEnabled(bool)));
854 // action = actionFactory.createAction(RS2::ActionModifyScale, actionHandler);
855 menu->addAction(actionModifyScale);
856 connect(actionModifyScale, SIGNAL(activated()), actionHandler, SLOT(slotModifyScale()));
857 connect(this, SIGNAL(windowsChanged(bool)), actionModifyScale, SLOT(setEnabled(bool)));
858 // action = actionFactory.createAction(RS2::ActionModifyMirror, actionHandler);
859 menu->addAction(actionModifyMirror);
860 connect(actionModifyMirror, SIGNAL(activated()), actionHandler, SLOT(slotModifyMirror()));
861 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMirror, SLOT(setEnabled(bool)));
862 // action = actionFactory.createAction(RS2::ActionModifyMoveRotate, actionHandler);
863 menu->addAction(actionModifyMoveRotate);
864 connect(actionModifyMoveRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyMoveRotate()));
865 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMoveRotate, SLOT(setEnabled(bool)));
866 // action = actionFactory.createAction(RS2::ActionModifyRotate2, actionHandler);
867 menu->addAction(actionModifyRotate2);
868 connect(actionModifyRotate2, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate2()));
869 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate2, SLOT(setEnabled(bool)));
870 // action = actionFactory.createAction(RS2::ActionModifyTrim, actionHandler);
871 menu->addAction(actionModifyTrim);
872 connect(actionModifyTrim, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim()));
873 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim, SLOT(setEnabled(bool)));
874 // action = actionFactory.createAction(RS2::ActionModifyTrim2, actionHandler);
875 menu->addAction(actionModifyTrim2);
876 connect(actionModifyTrim2, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim2()));
877 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim2, SLOT(setEnabled(bool)));
878 // action = actionFactory.createAction(RS2::ActionModifyTrimAmount, actionHandler);
879 menu->addAction(actionModifyTrimAmount);
880 connect(actionModifyTrimAmount, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrimAmount()));
881 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrimAmount, SLOT(setEnabled(bool)));
882 // action = actionFactory.createAction(RS2::ActionModifyBevel, actionHandler);
883 menu->addAction(actionModifyBevel);
884 connect(actionModifyBevel, SIGNAL(activated()), actionHandler, SLOT(slotModifyBevel()));
885 connect(this, SIGNAL(windowsChanged(bool)), actionModifyBevel, SLOT(setEnabled(bool)));
886 // action = actionFactory.createAction(RS2::ActionModifyRound, actionHandler);
887 menu->addAction(actionModifyRound);
888 connect(actionModifyRound, SIGNAL(activated()), actionHandler, SLOT(slotModifyRound()));
889 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRound, SLOT(setEnabled(bool)));
890 // action = actionFactory.createAction(RS2::ActionModifyCut, actionHandler);
891 menu->addAction(actionModifyCut);
892 connect(actionModifyCut, SIGNAL(activated()), actionHandler, SLOT(slotModifyCut()));
893 connect(this, SIGNAL(windowsChanged(bool)), actionModifyCut, SLOT(setEnabled(bool)));
894 // action = actionFactory.createAction(RS2::ActionModifyStretch, actionHandler);
895 menu->addAction(actionModifyStretch);
896 connect(actionModifyStretch, SIGNAL(activated()), actionHandler, SLOT(slotModifyStretch()));
897 connect(this, SIGNAL(windowsChanged(bool)), actionModifyStretch, SLOT(setEnabled(bool)));
898 // action = actionFactory.createAction(RS2::ActionModifyEntity, actionHandler);
899 menu->addAction(actionModifyEntity);
900 connect(actionModifyEntity, SIGNAL(activated()), actionHandler, SLOT(slotModifyEntity()));
901 connect(this, SIGNAL(windowsChanged(bool)), actionModifyEntity, SLOT(setEnabled(bool)));
902 // action = actionFactory.createAction(RS2::ActionModifyAttributes, actionHandler);
903 menu->addAction(actionModifyAttributes);
904 connect(actionModifyAttributes, SIGNAL(activated()), actionHandler, SLOT(slotModifyAttributes()));
905 connect(this, SIGNAL(windowsChanged(bool)), actionModifyAttributes, SLOT(setEnabled(bool)));
906 // action = actionFactory.createAction(RS2::ActionModifyDelete, actionHandler);
907 menu->addAction(actionModifyDelete);
908 connect(actionModifyDelete, SIGNAL(activated()), actionHandler, SLOT(slotModifyDelete()));
909 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDelete, SLOT(setEnabled(bool)));
910 // action = actionFactory.createAction(RS2::ActionModifyDeleteQuick, actionHandler);
911 menu->addAction(actionModifyDeleteQuick);
912 connect(actionModifyDeleteQuick, SIGNAL(activated()), actionHandler, SLOT(slotModifyDeleteQuick()));
913 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDeleteQuick, SLOT(setEnabled(bool)));
914 // action = actionFactory.createAction(RS2::ActionModifyExplodeText, actionHandler);
915 menu->addAction(actionModifyExplodeText);
916 connect(actionModifyExplodeText, SIGNAL(activated()), actionHandler, SLOT(slotModifyExplodeText()));
917 connect(this, SIGNAL(windowsChanged(bool)), actionModifyExplodeText, SLOT(setEnabled(bool)));
918 //// action = actionFactory.createAction(RS2::ActionModifyDeleteFree, actionHandler);
919 //// menu->addAction(action);
920 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
921 menu->addAction(actionBlocksExplode);
922 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
923 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
924 menuBar()->addMenu(menu);
928 menu = new QMenu(tr("&Snap"), this);
929 // action = actionFactory.createAction(RS2::ActionSnapFree, actionHandler);
930 menu->addAction(actionSnapFree);
931 actionHandler->setActionSnapFree(actionSnapFree); // ???Why???
932 connect(actionSnapFree, SIGNAL(activated()), actionHandler, SLOT(slotSnapFree()));
933 connect(this, SIGNAL(windowsChanged(bool)), actionSnapFree, SLOT(setEnabled(bool)));
934 actionSnapFree->setChecked(true);
935 // action = actionFactory.createAction(RS2::ActionSnapGrid, actionHandler);
936 menu->addAction(actionSnapGrid);
937 actionHandler->setActionSnapGrid(actionSnapGrid); // ???Why???
938 connect(actionSnapGrid, SIGNAL(activated()), actionHandler, SLOT(slotSnapGrid()));
939 connect(this, SIGNAL(windowsChanged(bool)), actionSnapGrid, SLOT(setEnabled(bool)));
940 // action = actionFactory.createAction(RS2::ActionSnapEndpoint, actionHandler);
941 menu->addAction(actionSnapEndpoint);
942 actionHandler->setActionSnapEndpoint(actionSnapEndpoint); // ???Why???
943 connect(actionSnapEndpoint, SIGNAL(activated()), actionHandler, SLOT(slotSnapEndpoint()));
944 connect(this, SIGNAL(windowsChanged(bool)), actionSnapEndpoint, SLOT(setEnabled(bool)));
945 // action = actionFactory.createAction(RS2::ActionSnapOnEntity, actionHandler);
946 menu->addAction(actionSnapOnEntity);
947 actionHandler->setActionSnapOnEntity(actionSnapOnEntity); // ???Why???
948 connect(actionSnapOnEntity, SIGNAL(activated()), actionHandler, SLOT(slotSnapOnEntity()));
949 connect(this, SIGNAL(windowsChanged(bool)), actionSnapOnEntity, SLOT(setEnabled(bool)));
950 // action = actionFactory.createAction(RS2::ActionSnapCenter, actionHandler);
951 menu->addAction(actionSnapCenter);
952 actionHandler->setActionSnapCenter(actionSnapCenter); // ???Why???
953 connect(actionSnapCenter, SIGNAL(activated()), actionHandler, SLOT(slotSnapCenter()));
954 connect(this, SIGNAL(windowsChanged(bool)), actionSnapCenter, SLOT(setEnabled(bool)));
955 // action = actionFactory.createAction(RS2::ActionSnapMiddle, actionHandler);
956 menu->addAction(actionSnapMiddle);
957 actionHandler->setActionSnapMiddle(actionSnapMiddle); // ???Why???
958 connect(actionSnapMiddle, SIGNAL(activated()), actionHandler, SLOT(slotSnapMiddle()));
959 connect(this, SIGNAL(windowsChanged(bool)), actionSnapMiddle, SLOT(setEnabled(bool)));
960 // action = actionFactory.createAction(RS2::ActionSnapDist, actionHandler);
961 menu->addAction(actionSnapDist);
962 actionHandler->setActionSnapDist(actionSnapDist); // ???Why???
963 connect(actionSnapDist, SIGNAL(activated()), actionHandler, SLOT(slotSnapDist()));
964 connect(this, SIGNAL(windowsChanged(bool)), actionSnapDist, SLOT(setEnabled(bool)));
965 // action = actionFactory.createAction(RS2::ActionSnapIntersection, actionHandler);
966 menu->addAction(actionSnapIntersection);
967 actionHandler->setActionSnapIntersection(actionSnapIntersection); // ???Why???
968 connect(actionSnapIntersection, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersection()));
969 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersection, SLOT(setEnabled(bool)));
970 // action = actionFactory.createAction(RS2::ActionSnapIntersectionManual, actionHandler);
971 menu->addAction(actionSnapIntersectionManual);
972 actionHandler->setActionSnapIntersectionManual(actionSnapIntersectionManual); // ???Why???
973 connect(actionSnapIntersectionManual, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersectionManual()));
974 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersectionManual, SLOT(setEnabled(bool)));
976 menu->addSeparator();
978 // action = actionFactory.createAction(RS2::ActionRestrictNothing, actionHandler);
979 menu->addAction(actionRestrictNothing);
980 actionHandler->setActionRestrictNothing(actionRestrictNothing); // ???WHY???
981 connect(actionRestrictNothing, SIGNAL(activated()), actionHandler, SLOT(slotRestrictNothing()));
982 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictNothing, SLOT(setEnabled(bool)));
983 actionRestrictNothing->setChecked(true);
984 // action = actionFactory.createAction(RS2::ActionRestrictOrthogonal, actionHandler);
985 menu->addAction(actionRestrictOrthogonal);
986 actionHandler->setActionRestrictOrthogonal(actionRestrictOrthogonal); // ???WHY???
987 connect(actionRestrictOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictOrthogonal()));
988 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictOrthogonal, SLOT(setEnabled(bool)));
989 // action = actionFactory.createAction(RS2::ActionRestrictHorizontal, actionHandler);
990 menu->addAction(actionRestrictHorizontal);
991 actionHandler->setActionRestrictHorizontal(actionRestrictHorizontal); // ???WHY???
992 connect(actionRestrictHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictHorizontal()));
993 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictHorizontal, SLOT(setEnabled(bool)));
994 // action = actionFactory.createAction(RS2::ActionRestrictVertical, actionHandler);
995 menu->addAction(actionRestrictVertical);
996 actionHandler->setActionRestrictVertical(actionRestrictVertical); // ???WHY???
997 connect(actionRestrictVertical, SIGNAL(activated()), actionHandler, SLOT(slotRestrictVertical()));
998 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictVertical, SLOT(setEnabled(bool)));
1000 menu->addSeparator();
1002 // action = actionFactory.createAction(RS2::ActionSetRelativeZero, actionHandler);
1003 menu->addAction(actionSetRelativeZero);
1004 connect(actionSetRelativeZero, SIGNAL(activated()), actionHandler, SLOT(slotSetRelativeZero()));
1005 connect(this, SIGNAL(windowsChanged(bool)), actionSetRelativeZero, SLOT(setEnabled(bool)));
1006 // action = actionFactory.createAction(RS2::ActionLockRelativeZero, actionHandler);
1007 menu->addAction(actionLockRelativeZero);
1008 actionHandler->setActionLockRelativeZero(actionLockRelativeZero);
1009 connect(actionLockRelativeZero, SIGNAL(toggled(bool)), actionHandler, SLOT(slotLockRelativeZero(bool))); // ???WHY???
1010 connect(this, SIGNAL(windowsChanged(bool)), actionLockRelativeZero, SLOT(setEnabled(bool)));
1011 menuBar()->addMenu(menu);
1016 menu = new QMenu(tr("&Info"), this);
1017 //action = actionFactory.createAction(RS2::ActionInfoInside, actionHandler);
1018 //menu->addAction(action);
1019 menu->addAction(actionInfoDist);
1020 connect(actionInfoDist, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist()));
1021 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist, SLOT(setEnabled(bool)));
1022 menu->addAction(actionInfoDist2);
1023 connect(actionInfoDist2, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist2()));
1024 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist2, SLOT(setEnabled(bool)));
1025 menu->addAction(actionInfoAngle);
1026 connect(actionInfoAngle, SIGNAL(activated()), actionHandler, SLOT(slotInfoAngle()));
1027 connect(this, SIGNAL(windowsChanged(bool)), actionInfoAngle, SLOT(setEnabled(bool)));
1028 menu->addAction(actionInfoTotalLength);
1029 connect(actionInfoTotalLength, SIGNAL(activated()), actionHandler, SLOT(slotInfoTotalLength()));
1030 connect(this, SIGNAL(windowsChanged(bool)), actionInfoTotalLength, SLOT(setEnabled(bool)));
1031 menu->addAction(actionInfoArea);
1032 connect(actionInfoArea, SIGNAL(activated()), actionHandler, SLOT(slotInfoArea()));
1033 connect(this, SIGNAL(windowsChanged(bool)), actionInfoArea, SLOT(setEnabled(bool)));
1034 menuBar()->addMenu(menu);
1039 menu = new QMenu(tr("&Layer"), this);
1040 // action = actionFactory.createAction(RS2::ActionLayersDefreezeAll, actionHandler);
1041 menu->addAction(actionLayersDefreezeAll);
1042 connect(actionLayersDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersDefreezeAll()));
1043 connect(this, SIGNAL(windowsChanged(bool)), actionLayersDefreezeAll, SLOT(setEnabled(bool)));
1044 // action = actionFactory.createAction(RS2::ActionLayersFreezeAll, actionHandler);
1045 menu->addAction(actionLayersFreezeAll);
1046 connect(actionLayersFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersFreezeAll()));
1047 connect(this, SIGNAL(windowsChanged(bool)), actionLayersFreezeAll, SLOT(setEnabled(bool)));
1048 // action = actionFactory.createAction(RS2::ActionLayersAdd, actionHandler);
1049 menu->addAction(actionLayersAdd);
1050 connect(actionLayersAdd, SIGNAL(activated()), actionHandler, SLOT(slotLayersAdd()));
1051 connect(this, SIGNAL(windowsChanged(bool)), actionLayersAdd, SLOT(setEnabled(bool)));
1052 // action = actionFactory.createAction(RS2::ActionLayersRemove, actionHandler);
1053 menu->addAction(actionLayersRemove);
1054 connect(actionLayersRemove, SIGNAL(activated()), actionHandler, SLOT(slotLayersRemove()));
1055 connect(this, SIGNAL(windowsChanged(bool)), actionLayersRemove, SLOT(setEnabled(bool)));
1056 // action = actionFactory.createAction(RS2::ActionLayersEdit, actionHandler);
1057 menu->addAction(actionLayersEdit);
1058 connect(actionLayersEdit, SIGNAL(activated()), actionHandler, SLOT(slotLayersEdit()));
1059 connect(this, SIGNAL(windowsChanged(bool)), actionLayersEdit, SLOT(setEnabled(bool)));
1060 // action = actionFactory.createAction(RS2::ActionLayersToggleView, actionHandler);
1061 menu->addAction(actionLayersToggleView);
1062 connect(actionLayersToggleView, SIGNAL(activated()), actionHandler, SLOT(slotLayersToggleView()));
1063 connect(this, SIGNAL(windowsChanged(bool)), actionLayersToggleView, SLOT(setEnabled(bool)));
1064 menuBar()->addMenu(menu);
1068 menu = new QMenu(tr("&Block"), this);
1069 // action = actionFactory.createAction(RS2::ActionBlocksDefreezeAll, actionHandler);
1070 menu->addAction(actionBlocksDefreezeAll);
1071 connect(actionBlocksDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksDefreezeAll()));
1072 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksDefreezeAll, SLOT(setEnabled(bool)));
1073 // action = actionFactory.createAction(RS2::ActionBlocksFreezeAll, actionHandler);
1074 menu->addAction(actionBlocksFreezeAll);
1075 connect(actionBlocksFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksFreezeAll()));
1076 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksFreezeAll, SLOT(setEnabled(bool)));
1077 // action = actionFactory.createAction(RS2::ActionBlocksAdd, actionHandler);
1078 menu->addAction(actionBlocksAdd);
1079 connect(actionBlocksAdd, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAdd()));
1080 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAdd, SLOT(setEnabled(bool)));
1081 // action = actionFactory.createAction(RS2::ActionBlocksRemove, actionHandler);
1082 menu->addAction(actionBlocksRemove);
1083 connect(actionBlocksRemove, SIGNAL(activated()), actionHandler, SLOT(slotBlocksRemove()));
1084 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksRemove, SLOT(setEnabled(bool)));
1085 // action = actionFactory.createAction(RS2::ActionBlocksAttributes, actionHandler);
1086 menu->addAction(actionBlocksAttributes);
1087 connect(actionBlocksAttributes, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAttributes()));
1088 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAttributes, SLOT(setEnabled(bool)));
1089 // action = actionFactory.createAction(RS2::ActionBlocksInsert, actionHandler);
1090 menu->addAction(actionBlocksInsert);
1091 connect(actionBlocksInsert, SIGNAL(activated()), actionHandler, SLOT(slotBlocksInsert()));
1092 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksInsert, SLOT(setEnabled(bool)));
1093 // action = actionFactory.createAction(RS2::ActionBlocksEdit, actionHandler);
1094 menu->addAction(actionBlocksEdit);
1095 connect(actionBlocksEdit, SIGNAL(activated()), actionHandler, SLOT(slotBlocksEdit()));
1096 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksEdit, SLOT(setEnabled(bool)));
1097 // action = actionFactory.createAction(RS2::ActionBlocksCreate, actionHandler);
1098 menu->addAction(actionBlocksCreate);
1099 connect(actionBlocksCreate, SIGNAL(activated()), actionHandler, SLOT(slotBlocksCreate()));
1100 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksCreate, SLOT(setEnabled(bool)));
1101 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
1102 menu->addAction(actionBlocksExplode);
1103 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
1104 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
1105 menuBar()->addMenu(menu);
1107 //will *this* make a toolbar break for us???
1108 addToolBarBreak(Qt::TopToolBarArea);
1109 // addDockWindow(penToolBar, tr("Pen"), Qt::DockTop);
1110 // addDockWindow(optionWidget, tr("Tool Options"), Qt::DockTop, true);
1111 addToolBar(Qt::TopToolBarArea, (QToolBar *)penToolBar); // hmm.
1112 addToolBar(Qt::TopToolBarArea, optionWidget);
1117 scriptMenu = new QMenu(this);
1118 scriptOpenIDE = actionFactory.createAction(RS2::ActionScriptOpenIDE, this);
1119 scriptOpenIDE->addTo(scriptMenu);
1120 scriptRun = actionFactory.createAction(RS2::ActionScriptRun, this);
1121 scriptRun->addTo(scriptMenu);
1124 scriptOpenIDE = NULL;
1130 menu = new QMenu(tr("&CAM"), this);
1131 action = actionFactory.createAction(RS2::ActionCamExportAuto, actionHandler);
1132 menu->addAction(action);
1133 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1134 action = actionFactory.createAction(RS2::ActionCamReorder, actionHandler);
1135 menu->addAction(action);
1136 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1137 menuBar()->addMenu(menu);
1142 helpAboutApp = new QAction(QIcon(QC_APP_ICON16), tr("&About Architektonas"), this);
1143 // helpAboutApp = new QAction(tr("About"), qPixmapFromMimeSource(QC_APP_ICON16), tr("&About %1").arg(QC_APPNAME), 0, this);
1144 helpAboutApp->setStatusTip(tr("About the application"));
1145 //helpAboutApp->setWhatsThis(tr("About\n\nAbout the application"));
1146 connect(helpAboutApp, SIGNAL(activated()), this, SLOT(slotHelpAbout()));
1148 helpManual = new QAction(QIcon(":/res/contents.png"), tr("&Manual"), this);
1149 helpManual->setShortcut(Qt::Key_F1);
1150 // helpManual = new QAction(qPixmapFromMimeSource("contents.png"), tr("&Manual"), Qt::Key_F1, this);
1151 helpManual->setStatusTip(tr("Launch the online manual"));
1152 connect(helpManual, SIGNAL(activated()), this, SLOT(slotHelpManual()));
1154 testDumpEntities = new QAction("Dump &Entities", this);
1155 // testDumpEntities = new QAction("Dump Entities", "Dump &Entities", 0, this);
1156 connect(testDumpEntities, SIGNAL(activated()), this, SLOT(slotTestDumpEntities()));
1158 testDumpUndo = new QAction("Undo Info", this);
1159 // testDumpUndo = new QAction("Dump Undo Info", "Undo Info", 0, this);
1160 connect(testDumpUndo, SIGNAL(activated()), this, SLOT(slotTestDumpUndo()));
1162 testUpdateInserts = new QAction("&Update Inserts", this);
1163 // testUpdateInserts = new QAction("Update Inserts", "&Update Inserts", 0, this);
1164 connect(testUpdateInserts, SIGNAL(activated()), this, SLOT(slotTestUpdateInserts()));
1166 testDrawFreehand = new QAction("Draw Freehand", this);
1167 // testDrawFreehand = new QAction("Draw Freehand", "Draw Freehand", 0, this);
1168 connect(testDrawFreehand, SIGNAL(activated()), this, SLOT(slotTestDrawFreehand()));
1170 testInsertBlock = new QAction("Insert Block", this);
1171 // testInsertBlock = new QAction("Insert Block", "Insert Block", 0, this);
1172 connect(testInsertBlock, SIGNAL(activated()), this, SLOT(slotTestInsertBlock()));
1174 testInsertText = new QAction("Insert Text", this);
1175 // testInsertText = new QAction("Insert Text", "Insert Text", 0, this);
1176 connect(testInsertText, SIGNAL(activated()), this, SLOT(slotTestInsertText()));
1178 testInsertImage = new QAction("Insert Image", this);
1179 // testInsertImage = new QAction("Insert Image", "Insert Image", 0, this);
1180 connect(testInsertImage, SIGNAL(activated()), this, SLOT(slotTestInsertImage()));
1182 testUnicode = new QAction("Unicode", this);
1183 // testUnicode = new QAction("Unicode", "Unicode", 0, this);
1184 connect(testUnicode, SIGNAL(activated()), this, SLOT(slotTestUnicode()));
1186 testInsertEllipse = new QAction("Insert Ellipse", this);
1187 // testInsertEllipse = new QAction("Insert Ellipse", "Insert Ellipse", 0, this);
1188 connect(testInsertEllipse, SIGNAL(activated()), this, SLOT(slotTestInsertEllipse()));
1190 testMath01 = new QAction("Math01", this);
1191 // testMath01 = new QAction("Math01", "Math01", 0, this);
1192 connect(testMath01, SIGNAL(activated()), this, SLOT(slotTestMath01()));
1194 testResize640 = new QAction("Resize 1", this);
1195 // testResize640 = new QAction("Resize to 640x480", "Resize 1", 0, this);
1196 connect(testResize640, SIGNAL(activated()), this, SLOT(slotTestResize640()));
1198 testResize800 = new QAction("Resize 2", this);
1199 // testResize800 = new QAction("Resize to 800x600", "Resize 2", 0, this);
1200 connect(testResize800, SIGNAL(activated()), this, SLOT(slotTestResize800()));
1202 testResize1024 = new QAction("Resize 3", this);
1203 // testResize1024 = new QAction("Resize to 1024x768", "Resize 3", 0, this);
1204 connect(testResize1024, SIGNAL(activated()), this, SLOT(slotTestResize1024()));
1208 * Initializes the menu bar.
1210 void ApplicationWindow::initMenuBar()
1212 RS_DEBUG->print("ApplicationWindow::initMenuBar()");
1214 // menuBar entry windowsMenu
1215 windowsMenu = new QMenu(tr("&Window"), this);
1216 //according to docs, this is obsolete: windowsMenu->setCheckable(true);
1217 connect(windowsMenu, SIGNAL(aboutToShow()), this, SLOT(slotWindowsMenuAboutToShow()));
1219 // menuBar entry scriptMenu
1220 //scriptMenu = new QPopupMenu(this);
1221 //scriptMenu->setCheckable(true);
1222 //scriptOpenIDE->addTo(scriptMenu);
1223 //scriptRun->addTo(scriptMenu);
1224 //connect(scriptMenu, SIGNAL(aboutToShow()), this, SLOT(slotScriptMenuAboutToShow()));
1226 // menuBar entry helpMenu
1227 helpMenu = new QMenu(tr("&Help"), this);
1228 helpMenu->addAction(helpManual);//helpManual->addTo(helpMenu);
1230 // helpMenu->insertSeparator(helpManual);
1231 helpMenu->addSeparator();
1233 helpMenu->addAction(helpAboutApp);//helpAboutApp->addTo(helpMenu);
1235 // menuBar entry test menu
1236 testMenu = new QMenu(tr("De&bugging"), this);
1237 testMenu->addAction(testDumpEntities);//testDumpEntities->addTo(testMenu);
1238 testMenu->addAction(testDumpUndo);//testDumpUndo->addTo(testMenu);
1239 testMenu->addAction(testUpdateInserts);//testUpdateInserts->addTo(testMenu);
1240 testMenu->addAction(testDrawFreehand);//testDrawFreehand->addTo(testMenu);
1241 testMenu->addAction(testInsertBlock);//testInsertBlock->addTo(testMenu);
1242 testMenu->addAction(testInsertText);//testInsertText->addTo(testMenu);
1243 testMenu->addAction(testInsertImage);//testInsertImage->addTo(testMenu);
1244 testMenu->addAction(testInsertEllipse);//testInsertEllipse->addTo(testMenu);
1245 testMenu->addAction(testUnicode);//testUnicode->addTo(testMenu);
1246 testMenu->addAction(testMath01);//testMath01->addTo(testMenu);
1247 testMenu->addAction(testResize640);//testResize640->addTo(testMenu);
1248 testMenu->addAction(testResize800);//testResize800->addTo(testMenu);
1249 testMenu->addAction(testResize1024);//testResize1024->addTo(testMenu);
1251 // menuBar configuration
1253 // menuBar()->insertItem(tr("&Scripts"), scriptMenu);
1254 menuBar()->addMenu(scriptMenu);
1256 // menuBar()->insertItem(tr("&Window"), windowsMenu);
1257 menuBar()->addMenu(windowsMenu);
1259 // menuBar()->insertSeparator();
1260 // menuBar()->insertItem(tr("&Help"), helpMenu);
1261 menuBar()->addMenu(helpMenu);
1264 // menuBar()->insertItem(tr("De&bugging"), testMenu);
1265 menuBar()->addMenu(testMenu);
1267 recentFiles = new RecentFiles(this, fileMenu);
1271 * Initializes the tool bars (file tool bar and pen tool bar).
1273 void ApplicationWindow::initToolBar()
1275 RS_DEBUG->print("ApplicationWindow::initToolBar()");
1277 // fileToolBar = new Q3ToolBar(this, "File Operations");
1278 fileToolBar = addToolBar(tr("File Operations"));
1279 fileToolBar->setObjectName("file");
1280 // editToolBar = new Q3ToolBar(this, "Edit Operations");
1281 editToolBar = addToolBar(tr("Edit Operations"));
1282 editToolBar->setObjectName("edit");
1283 // zoomToolBar = new Q3ToolBar(this, "Zoom Operations");
1284 zoomToolBar = addToolBar(tr("Zoom Operations"));
1285 zoomToolBar->setObjectName("zoom");
1286 penToolBar = new QG_PenToolBar(this, "Pen Selection");
1287 penToolBar->setObjectName("pen");
1289 connect(penToolBar, SIGNAL(penChanged(RS_Pen)), this, SLOT(slotPenChanged(RS_Pen)));
1291 // optionWidget = new Q3ToolBar(this, "Tool Options");
1292 //addToolBarBreak() does nothing...
1293 #warning "!!! add/insertToolBarBreak() does nothing !!!"
1294 // addToolBarBreak(Qt::TopToolBarArea);
1295 optionWidget = addToolBar(tr("Tool Options"));
1296 optionWidget->setObjectName("tooloptions");
1297 optionWidget->setMinimumHeight(26);
1298 optionWidget->setMaximumHeight(26);
1299 #warning "!!! No analogue found for setHorizontallyStretchable yet !!!"
1300 //Maybe sizePolicy or somesuch??
1301 optionWidget->setMinimumWidth(150);
1302 optionWidget->setMaximumWidth(800);
1303 #warning "Following line commented out..."
1304 // optionWidget->setFixedExtentHeight(26);
1305 // optionWidget->setHorizontallyStretchable(true);
1306 // addDockWindow(optionWidget, DockTop, true);
1308 // CAD toolbar left:
1309 // Q3ToolBar * t = new Q3ToolBar(this, "CAD Tools");
1310 QToolBar * t = addToolBar(tr("CAD Tools"));
1311 t->setObjectName("cadtools");
1312 #warning "Following two lines commented out..."
1313 // t->setFixedExtentWidth(59);
1314 t->setMinimumWidth(59);
1315 t->setMaximumWidth(59);
1316 // t->setVerticallyStretchable(true);
1317 // addDockWindow(t, Qt::DockLeft, false);
1318 addToolBar(Qt::LeftToolBarArea, t);
1320 cadToolBar = new CadToolBar(t);//, "CAD Tools");
1321 cadToolBar->createSubToolBars(actionHandler);
1323 connect(cadToolBar, SIGNAL(signalBack()), this, SLOT(slotBack()));
1324 connect(this, SIGNAL(windowsChanged(bool)), cadToolBar, SLOT(setEnabled(bool)));
1326 // QG_CadToolBarMain * cadToolBarMain = new QG_CadToolBarMain(cadToolBar);
1327 //No, no break inserted here either...
1328 // insertToolBarBreak(optionWidget);
1332 * Initializes the status bar at the bottom.
1334 void ApplicationWindow::initStatusBar()
1336 RS_DEBUG->print("ApplicationWindow::initStatusBar()");
1338 statusBar()->setMinimumHeight(32);
1339 coordinateWidget = new CoordinateWidget(statusBar());//, "coordinates");
1340 statusBar()->addWidget(coordinateWidget);
1341 mouseWidget = new MouseWidget(statusBar());//, "mouse info");
1342 statusBar()->addWidget(mouseWidget);
1343 selectionWidget = new SelectionWidget(statusBar());//, "selections");
1344 statusBar()->addWidget(selectionWidget);
1348 * Initializes the global application settings from the
1349 * config file (unix, mac) or registry (windows).
1351 void ApplicationWindow::initSettings()
1353 RS_DEBUG->print("ApplicationWindow::initSettings()");
1354 settings.beginGroup("RecentFiles");
1356 for(int i=0; i<recentFiles->Maximum(); ++i)
1358 QString filename = settings.value(QString("File") + QString::number(i + 1)).toString();
1360 if (!filename.isEmpty())
1361 // recentFiles->add(filename);
1362 recentFiles->add(filename);
1365 settings.endGroup();
1367 if (recentFiles->count() > 0)
1368 // updateRecentFilesMenu();
1369 recentFiles->UpdateGUI();
1371 settings.beginGroup("Geometry");
1372 QSize windowSize = settings.value("WindowSize", QSize(950, 700)).toSize();
1373 QPoint windowPos = settings.value("WindowPos", QPoint(0, 30)).toPoint();
1374 restoreState(settings.value("DockWindows").toByteArray());
1375 settings.endGroup();
1378 // if (windowY < 30)
1380 if (windowSize.y() < 30)
1381 windowSize.y() = 30;
1389 * Stores the global application settings to file or registry.
1391 void ApplicationWindow::storeSettings()
1393 RS_DEBUG->print("ApplicationWindow::storeSettings()");
1395 settings.beginGroup("RecentFiles");
1397 for(int i=0; i<recentFiles->count(); ++i)
1398 settings.setValue(QString("File") + QString::number(i + 1), recentFiles->get(i));
1400 settings.endGroup();
1402 settings.beginGroup("Geometry");
1403 settings.setValue("WindowSize", size());
1404 settings.setValue("WindowPos", pos());
1405 settings.setValue("DockWindows", saveState());
1406 settings.endGroup();
1408 RS_DEBUG->print("ApplicationWindow::storeSettings(): OK");
1412 * Initializes the view.
1414 void ApplicationWindow::initView()
1416 RS_DEBUG->print("ApplicationWindow::initView()");
1418 RS_DEBUG->print("init view..");
1422 libraryWidget = NULL;
1423 commandWidget = NULL;
1425 simulationControls = NULL;
1429 RS_DEBUG->print(" simulation widget..");
1430 dw = new QDockWidget(QDockWidget::InDock, this, "Simulation");
1431 simulationControls = new RS_SimulationControls(dw, "Simulation");
1432 simulationControls->setFocusPolicy(Qt::NoFocus);
1433 connect(simulationControls, SIGNAL(escape()), this, SLOT(slotFocus()));
1434 connect(this, SIGNAL(windowsChanged(bool)), simulationControls, SLOT(setEnabled(bool)));
1435 dw->setWidget(simulationControls);
1436 dw->resize(240, 80);
1437 dw->setResizeEnabled(true);
1438 dw->setFixedExtentWidth(120);
1439 dw->setFixedHeight(80);
1440 dw->setCaption(tr("Simulation Controls"));
1441 dw->setCloseMode(Q3DockWindow::Always);
1442 addDockWindow(dw, Qt::DockRight);
1443 simulationDockWindow = dw;
1444 //simulationDockWindow->hide();
1447 RS_DEBUG->print(" layer widget..");
1448 // dw = new QDockWidget(QDockWidget::InDock, this, "Layer");
1449 dw = new QDockWidget(tr("Layer List"), this);
1450 dw->setObjectName("layer");
1451 layerWidget = new QG_LayerWidget(actionHandler, dw, "Layer");
1452 layerWidget->setFocusPolicy(Qt::NoFocus);
1453 connect(layerWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1454 connect(this, SIGNAL(windowsChanged(bool)), layerWidget, SLOT(setEnabled(bool)));
1455 dw->setWidget(layerWidget);
1456 #warning "following four lines commented out..."
1457 // dw->setFixedExtentWidth(120);
1458 // dw->setResizeEnabled(true);
1459 // dw->setCloseMode(Q3DockWindow::Always);
1460 // dw->setCaption(tr("Layer List"));
1461 addDockWidget(Qt::RightDockWidgetArea, dw);
1462 layerDockWindow = dw;
1464 RS_DEBUG->print(" block widget..");
1465 // dw = new QDockWidget(QDockWidget::InDock, this, "Block");
1466 dw = new QDockWidget(tr("Block List"), this);
1467 dw->setObjectName("block");
1468 blockWidget = new QG_BlockWidget(actionHandler, dw, "Block");
1469 blockWidget->setFocusPolicy(Qt::NoFocus);
1470 connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1471 connect(this, SIGNAL(windowsChanged(bool)), blockWidget, SLOT(setEnabled(bool)));
1472 dw->setWidget(blockWidget);
1473 #warning "following four lines commented out..."
1474 // dw->setFixedExtentWidth(120);
1475 // dw->setResizeEnabled(true);
1476 // dw->setCloseMode(Q3DockWindow::Always);
1477 // dw->setCaption(tr("Block List"));
1478 addDockWidget(Qt::RightDockWidgetArea, dw);
1479 blockDockWindow = dw;
1481 RS_DEBUG->print(" library widget..");
1482 // dw = new QDockWidget(QDockWidget::OutsideDock, this, "Library");
1483 dw = new QDockWidget(tr("Library Browser"), this);
1484 dw->setObjectName("library");
1485 libraryWidget = new LibraryWidget(dw);//WAS:, "Library");
1486 libraryWidget->setActionHandler(actionHandler);
1487 libraryWidget->setFocusPolicy(Qt::NoFocus);
1488 connect(libraryWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1490 // connect(this, SIGNAL(windowsChanged(bool)), (QObject *)libraryWidget->bInsert, SLOT(setEnabled(bool)));
1491 dw->setWidget(libraryWidget);
1492 dw->resize(240, 400);
1493 #warning "following three lines commented out..."
1494 // dw->setResizeEnabled(true);
1495 // dw->setCloseMode(Q3DockWindow::Always);
1496 // dw->setCaption(tr("Library Browser"));
1497 //not sure how to fix this one
1498 #warning "QMainWindow::addDockWidget: invalid 'area' argument"
1499 addDockWidget(Qt::NoDockWidgetArea, dw);
1500 libraryDockWindow = dw;
1501 libraryDockWindow->hide();
1503 RS_DEBUG->print(" command widget..");
1504 // dw = new QDockWidget(QDockWidget::InDock, this, "Command");
1505 dw = new QDockWidget(tr("Command line"), this);
1506 dw->setObjectName("command");
1507 commandWidget = new CommandWidget(dw);//WAS:, "Command");
1508 commandWidget->setActionHandler(actionHandler);
1509 // commandWidget->redirectStderr();
1510 // std::cerr << "Ready.\n";
1511 // commandWidget->processStderr();
1512 connect(this, SIGNAL(windowsChanged(bool)), commandWidget, SLOT(setEnabled(bool)));
1513 dw->setWidget(commandWidget);
1514 #warning "following four lines commented out..."
1515 // dw->setFixedExtentHeight(45);
1516 // dw->setResizeEnabled(true);
1517 // dw->setCloseMode(QDockWidget::Always);
1518 // dw->setCaption(tr("Command line"));
1519 commandDockWindow = dw;
1520 addDockWidget(Qt::BottomDockWidgetArea, dw);
1522 RS_DEBUG->print(" done");
1526 * Creates a new toolbar.
1527 * Implementation from QG_MainWindowInterface.
1528 * Can be called from scripts to add individual GUI elements.
1530 /*QToolBar* ApplicationWindow::createToolBar(const QString& name) {
1531 QToolBar* tb = new QToolBar(this, name);
1537 * Creates a new button in the given tool bar for running a script.
1539 /*void ApplicationWindow::addToolBarButton(QToolBar* tb) {
1541 QAction* action = new QAction("Blah",
1542 QPixmap::fromMimeSource("zoomwindow.png"),
1543 "&Blah", QKeySequence(), NULL);
1544 action->setStatusTip("Blah blah");
1550 * Goes back to the previous menu or one step in the current action.
1552 void ApplicationWindow::slotBack()
1554 GraphicView * graphicView = getGraphicView();
1557 graphicView->back();
1561 cadToolBar->showToolBar(RS2::ToolBarMain);
1566 * Goes one step further in the current action.
1568 void ApplicationWindow::slotEnter()
1570 if (!commandWidget || !commandWidget->checkFocus())
1573 cadToolBar->forceNext();
1576 GraphicView * graphicView = getGraphicView();
1579 graphicView->enter();
1585 * Sets the keyboard focus on the command line.
1587 void ApplicationWindow::slotFocusCommandLine()
1589 if (commandWidget->isVisible())
1590 commandWidget->setFocus();
1594 * Shows the given error on the command line.
1596 void ApplicationWindow::slotError(const QString & msg)
1598 commandWidget->appendHistory(msg);
1602 * Hands focus back to the application window. In the rare event
1603 * of a escape press from the layer widget (e.g after switching desktops
1606 void ApplicationWindow::slotFocus()
1608 //QG_GraphicView* graphicView = getGraphicView();
1609 /*if (graphicView!=NULL) {
1610 graphicView->setFocus();
1618 * Called when a document window was activated.
1620 void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/)
1622 RS_DEBUG->print("ApplicationWindow::slotWindowActivated begin");
1624 //the following does: return (MDIWindow *)workspace->activeSubWindow();
1625 //which means the subwindow is NOT being activated!!!
1626 MDIWindow * m = getMDIWindow();
1627 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m=%08X", m);
1629 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m->getDoc=%08X", m->getDocument());
1631 if (m && m->getDocument())
1633 //m->setWindowState(WindowMaximized);
1635 RS_DEBUG->print("ApplicationWindow::slotWindowActivated: document: %d", m->getDocument()->getId());
1637 bool showByBlock = m->getDocument()->rtti() == RS2::EntityBlock;
1638 layerWidget->setLayerList(m->getDocument()->getLayerList(), showByBlock);
1639 coordinateWidget->setGraphic(m->getGraphic());
1642 simulationControls->setGraphicView(m->getGraphicView());
1645 // Only graphics show blocks. (blocks don't)
1646 if (m->getDocument()->rtti() == RS2::EntityGraphic)
1647 blockWidget->setBlockList(m->getDocument()->getBlockList());
1649 blockWidget->setBlockList(NULL);
1651 // Update all inserts in this graphic (blocks might have changed):
1652 m->getDocument()->updateInserts();
1653 m->getGraphicView()->redraw();
1655 // set snapmode from snapping menu
1656 actionHandler->updateSnapMode();
1658 // set pen from pen toolbar
1659 slotPenChanged(penToolBar->getPen());
1661 // update toggle button status:
1662 if (m->getGraphic() != NULL)
1664 emit(gridChanged(m->getGraphic()->isGridOn()));
1665 emit(printPreviewChanged(m->getGraphicView()->isPrintPreview()));
1669 //Seems to work now.
1670 //#warning "This is failing... !!! FIX !!!"
1671 // Disable/Enable menu and toolbar items
1672 emit windowsChanged(m != NULL && m->getDocument() != NULL);
1674 RS_DEBUG->print("ApplicationWindow::slotWindowActivated end");
1678 * Called when the menu 'windows' is about to be shown.
1679 * This is used to update the window list in the menu.
1681 void ApplicationWindow::slotWindowsMenuAboutToShow()
1683 RS_DEBUG->print("ApplicationWindow::slotWindowsMenuAboutToShow");
1685 windowsMenu->clear();
1687 int cascadeId = windowsMenu->insertItem(tr("&Cascade"), workspace, SLOT(cascade()));
1688 int tileId = windowsMenu->insertItem(tr("&Tile"), this, SLOT(slotTileVertical()));
1689 int horTileId = windowsMenu->insertItem(tr("Tile &Horizontally"), this, SLOT(slotTileHorizontal()));
1691 if (workspace->subWindowList().isEmpty())
1693 windowsMenu->setItemEnabled(cascadeId, false);
1694 windowsMenu->setItemEnabled(tileId, false);
1695 windowsMenu->setItemEnabled(horTileId, false);
1698 windowsMenu->insertSeparator();
1700 #warning "!!! Qt4 implementation of insertItem is vastly different from Qt3--FIX !!!"
1702 QList<QMdiSubWindow *> windows = workspace->subWindowList();
1704 //#warning "Need to add window numbers underlined so can access windows via keyboard. !!! FIX !!!"
1706 for(int i=0; i<int(windows.count()); ++i)
1708 // int id = windowsMenu->insertItem(windows.at(i)->caption(), this, SLOT(slotWindowsMenuActivated(int)));
1709 //For some reason the triggered() signal created here is type bool... Dunno why...
1710 //It's signalling using the QAction signal, which is type bool (checked or not).
1712 QString actionName = QString("&%1 %2").arg(i + 1).arg(windows.at(i)->windowTitle());
1713 // QAction * action = new QAction(windows.at(i)->windowTitle(), this);
1714 QAction * action = new QAction(actionName, this);
1715 action->setCheckable(true);
1717 action->setChecked(workspace->activeSubWindow() == windows.at(i));
1718 windowsMenu->addAction(action);
1719 connect(windowsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotWindowsMenuActivated(QAction *)));
1720 // connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1722 QAction * id = windowsMenu->addAction(windows.at(i)->windowTitle(), this,
1723 // SLOT(slotWindowsMenuActivated(int)));
1724 SLOT(slotWindowsMenuActivated(QAction *)));
1726 // windowsMenu->setItemParameter(id, i);
1727 // windowsMenu->setItemChecked(id, workspace->activeSubWindow() == windows.at(i));
1729 id->setChecked(workspace->activeSubWindow() == windows.at(i));
1735 * Called when the user selects a document window from the
1738 void ApplicationWindow::slotWindowsMenuActivated(QAction * id)
1740 RS_DEBUG->print("ApplicationWindow::slotWindowsMenuActivated");
1742 // QMdiSubWindow * w = workspace->subWindowList().at(id);
1743 QMdiSubWindow * w = workspace->subWindowList().at(id->data().toInt());
1751 * Tiles MDI windows horizontally.
1753 void ApplicationWindow::slotTileHorizontal()
1755 RS_DEBUG->print("ApplicationWindow::slotTileHorizontal");
1758 // primitive horizontal tiling
1759 QWidgetList windows = workspace->windowList();
1761 if (windows.count() == 0)
1764 int heightForEach = workspace->height() / windows.count();
1767 for(int i=0; i<int(windows.count()); ++i)
1769 QWidget * window = windows.at(i);
1771 #warning "Need to port to Qt4... !!! FIX !!!"
1773 if (window->testWState(WState_Maximized))
1777 window->showNormal();
1781 int preferredHeight = window->minimumHeight() + window->parentWidget()->baseSize().height();
1782 int actHeight = QMAX(heightForEach, preferredHeight);
1784 // window->parentWidget()->resize(workspace->width(), actHeight);
1785 window->parentWidget()->setGeometry(0, y, workspace->width(), actHeight);
1789 workspace->tileSubWindows();
1794 * Tiles MDI windows vertically.
1796 void ApplicationWindow::slotTileVertical()
1802 QWidgetList windows = workspace->windowList();
1803 if (windows.count()==0) {
1807 //int heightForEach = workspace->height() / windows.count();
1809 for (int i=0; i<int(windows.count()); ++i) {
1810 QWidget *window = windows.at(i);
1811 if (window->testWState(WState_Maximized)) {
1814 window->showNormal();
1816 //int preferredHeight = window->minimumHeight()
1817 // + window->parentWidget()->baseSize().height();
1818 //int actHeight = QMAX(heightForEach, preferredHeight);
1820 //window->parentWidget()->setGeometry(0, y,
1821 // workspace->width(), actHeight);
1822 //window->parentWidget()->resize(window->parentWidget()->width(),
1823 // window->parentWidget()->height());
1824 //window->resize(window->width(), window->height());
1829 workspace->tileSubWindows();
1838 void ApplicationWindow::slotCamExportAuto() {
1839 printf("CAM export..\n");
1841 RS_Document* d = getDocument();
1843 Drawing* graphic = (Drawing*)d;
1845 RS_CamDialog dlg(graphic, this);
1853 * Called when something changed in the pen tool bar
1854 * (e.g. color, width, style).
1856 void ApplicationWindow::slotPenChanged(RS_Pen pen)
1858 RS_DEBUG->print("ApplicationWindow::slotPenChanged() begin");
1859 RS_DEBUG->print("Setting active pen...");
1860 MDIWindow * m = getMDIWindow();
1863 m->slotPenChanged(pen);
1865 RS_DEBUG->print("ApplicationWindow::slotPenChanged() end");
1869 * Creates a new MDI window with the given document or a new
1870 * document if 'doc' is NULL.
1872 MDIWindow * ApplicationWindow::slotFileNew(RS_Document * doc)
1874 RS_DEBUG->print("ApplicationWindow::slotFileNew() begin");
1879 statusBar()->showMessage(tr("Creating new file..."));
1881 #warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible"
1882 RS_DEBUG->print(" creating MDI window");
1883 // MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::WA_DeleteOnClose);
1884 MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::SubWindow);
1885 w->setAttribute(Qt::WA_DeleteOnClose);
1886 // w->setWindowState(WindowMaximized);
1887 connect(w, SIGNAL(signalClosing()), this, SLOT(slotFileClosing()));
1889 if (w->getDocument()->rtti() == RS2::EntityBlock)
1890 // w->setCaption(tr("Block '%1'").arg(((RS_Block *)(w->getDocument()))->getName()));
1891 w->setWindowTitle(tr("Block '%1'").arg(((RS_Block *)(w->getDocument()))->getName()));
1893 // w->setCaption(tr("unnamed document %1").arg(id));
1894 w->setWindowTitle(tr("unnamed document %1").arg(id));
1896 // w->setIcon(qPixmapFromMimeSource("document.png"));
1897 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
1898 w->setWindowIcon(QIcon(":/res/document.png"));
1900 // only graphics offer block lists, blocks don't
1901 RS_DEBUG->print(" adding listeners");
1902 Drawing * graphic = w->getDocument()->getGraphic();
1904 if (graphic != NULL)
1906 // Link the graphic's layer list to the pen tool bar
1907 graphic->addLayerListListener(penToolBar);
1908 // Link the layer list to the layer widget
1909 graphic->addLayerListListener(layerWidget);
1910 // Link the block list to the block widget
1911 graphic->addBlockListListener(blockWidget);
1914 // Link the dialog factory to the mouse widget:
1915 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
1916 // Link the dialog factory to the coordinate widget:
1917 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
1918 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
1919 // Link the dialog factory to the option widget:
1920 // QG_DIALOGFACTORY->setOptionWidget(optionWidget);
1921 // Link the dialog factory to the cad tool bar:
1922 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
1923 // Link the dialog factory to the command widget:
1924 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
1925 // Link the dialog factory to the main app window:
1926 QG_DIALOGFACTORY->setMainWindow(this);
1928 #if 1 //bugfix for Qt3->4 conversion
1929 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotFileNew: adding window to workspace...");
1930 // workspace->addWindow(w);
1931 workspace->addSubWindow(w);
1934 RS_DEBUG->print(" showing MDI window");
1937 #warning "w->showMaximized() doesn't seem to do anything here..."
1938 //but then again, the subWindowList isn't going to be empty at this point either...
1939 if (workspace->subWindowList().isEmpty())
1945 #warning "!!! SubWindow is not being activated !!!"
1946 //neither of these is working... Is the event being eaten somewhere???
1947 // workspace->activateNextSubWindow();
1949 //printf("--> ApplicationWindow::slotFileNew(): w %s focus...\n", (w->hasFocus() ? "has" : "DOES NOT HAVE"));
1952 #warning "!!! Parameter to slotWindowActivated() is ignored !!!"
1953 slotWindowActivated(w);
1954 statusBar()->showMessage(tr("New Drawing created."), 2000);
1956 RS_DEBUG->print("ApplicationWindow::slotFileNew() OK");
1963 * Menu file -> open.
1965 void ApplicationWindow::slotFileOpen()
1967 RS_DEBUG->print("ApplicationWindow::slotFileOpen()");
1969 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 001");
1970 RS2::FormatType type = RS2::FormatUnknown;
1971 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 002");
1972 QString fileName = QG_FileDialog::getOpenFileName(this, &type);
1973 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 003");
1974 slotFileOpen(fileName, type);
1975 RS_DEBUG->print("ApplicationWindow::slotFileOpen(): OK");
1979 * Called when a recently opened file is chosen from the list in the
1982 void ApplicationWindow::slotFileOpenRecent(void)
1985 RS_DEBUG->print("ApplicationWindow::slotFileOpenRecent()");
1987 statusBar()->showMessage(tr("Opening recent file..."));
1988 QString fileName = recentFiles->get(id);
1990 if (fileName.endsWith(" (DXF 1)"))
1991 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
1993 slotFileOpen(fileName, RS2::FormatUnknown);
1995 statusBar()->showMessage(tr("Opening recent file..."));
1997 QAction * action = qobject_cast<QAction *>(sender());
2002 QString fileName = action->data().toString();
2004 if (fileName.endsWith(" (DXF 1)"))
2005 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
2007 slotFileOpen(fileName, RS2::FormatUnknown);
2012 * Menu file -> open.
2014 void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType type)
2016 RS_DEBUG->print("ApplicationWindow::slotFileOpen(..)");
2018 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2020 if (!fileName.isEmpty())
2022 RS_DEBUG->print("ApplicationWindow::slotFileOpen: creating new doc window");
2023 // Create new document window:
2024 MDIWindow * w = slotFileNew();
2025 // RS_APP->processEvents(1000);
2026 //Really, is this needed???
2027 // RS_APP->processEvents(QEventLoop::AllEvents, 1000);
2029 RS_DEBUG->print("ApplicationWindow::slotFileOpen: linking layer list");
2030 // link the layer widget to the new document:
2031 layerWidget->setLayerList(w->getDocument()->getLayerList(), false);
2032 // link the block widget to the new document:
2033 blockWidget->setBlockList(w->getDocument()->getBlockList());
2034 // link coordinate widget to graphic
2035 coordinateWidget->setGraphic(w->getGraphic());
2037 // link the layer widget to the new document:
2038 simulationControls->setGraphicView(w->getGraphicView());
2041 RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file");
2043 // RS_APP->processEvents(1000);
2044 //We no longer try to do Qt better than the Qt folks...
2045 // RS_APP->processEvents(QEventLoop::AllEvents, 1000);
2047 // open the file in the new view:
2048 if (w->slotFileOpen(fileName, type) == false)
2051 QApplication::restoreOverrideCursor();
2052 QMessageBox::information(this, QMessageBox::tr("Warning"),
2053 tr("Cannot open the file\n%1\nPlease check the permissions.") .arg(fileName), QMessageBox::Ok);
2054 w->setForceClosing(true);
2059 RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file: OK");
2060 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 1");
2062 // update recent files menu:
2063 if (type == RS2::FormatDXF1)
2064 recentFiles->add(fileName + " (DXF 1)");
2066 recentFiles->add(fileName);
2068 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 2");
2069 // updateRecentFilesMenu();
2070 recentFiles->UpdateGUI();
2072 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: OK");
2074 RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption");
2076 // w->setCaption(fileName);
2077 w->setWindowTitle(fileName);
2078 RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption: OK");
2080 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget");
2081 // update coordinate widget format:
2082 RS_DIALOGFACTORY->updateCoordinateWidget(Vector(0.0, 0.0), Vector(0.0, 0.0), true);
2083 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget: OK");
2085 // show output of filter (if any):
2086 // commandWidget->processStderr();
2087 QString message = tr("Loaded document: ") + fileName;
2088 commandWidget->appendHistory(message);
2089 statusBar()->showMessage(message, 2000);
2093 statusBar()->showMessage(tr("Opening aborted"), 2000);
2096 QApplication::restoreOverrideCursor();
2097 RS_DEBUG->print("ApplicationWindow::slotFileOpen(..) OK");
2101 * Menu file -> save.
2103 void ApplicationWindow::slotFileSave()
2105 RS_DEBUG->print("ApplicationWindow::slotFileSave()");
2107 statusBar()->showMessage(tr("Saving drawing..."));
2109 MDIWindow * w = getMDIWindow();
2114 if (w->getDocument()->getFilename().isEmpty())
2120 if (w->slotFileSave(cancelled))
2124 name = w->getDocument()->getFilename();
2125 statusBar()->showMessage(tr("Saved drawing: %1").arg(name), 2000);
2131 QMessageBox::information(this, QMessageBox::tr("Warning"),
2132 tr("Cannot save the file\n%1\nPlease check the permissions.")
2133 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2140 * Menu file -> save as.
2142 void ApplicationWindow::slotFileSaveAs()
2144 RS_DEBUG->print("ApplicationWindow::slotFileSaveAs()");
2146 statusBar()->showMessage(tr("Saving drawing under new filename..."));
2148 MDIWindow * w = getMDIWindow();
2155 if (w->slotFileSaveAs(cancelled))
2159 name = w->getDocument()->getFilename();
2160 recentFiles->add(name);
2161 w->setWindowTitle(name);
2167 QMessageBox::information(this, QMessageBox::tr("Warning"),
2168 tr("Cannot save the file\n%1\nPlease check the permissions.")
2169 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2173 // updateRecentFilesMenu();
2174 recentFiles->UpdateGUI();
2176 QString message = tr("Saved drawing: %1").arg(name);
2177 statusBar()->showMessage(message, 2000);
2178 commandWidget->appendHistory(message);
2182 * Menu file -> export.
2184 void ApplicationWindow::slotFileExport()
2186 RS_DEBUG->print("ApplicationWindow::slotFileExport()");
2188 statusBar()->showMessage(tr("Exporting drawing..."));
2190 MDIWindow * w = getMDIWindow();
2195 // read default settings:
2196 settings.beginGroup("Paths");
2197 QString defDir = settings.value("ExportImage", RS_SYSTEM->getHomeDir()).toString();
2198 QString defFilter = settings.value("ExportImageFilter", "Portable Network Graphic (*.png)").toString();
2199 settings.endGroup();
2201 bool cancel = false;
2203 // Q3FileDialog fileDlg(NULL, "", true);
2204 QFileDialog fileDlg(NULL, "", "", "");
2206 #warning "Need to port to Qt4... !!! FIX !!!"
2208 Q3StrList f = QImageIO::outputFormats();
2209 QStringList formats = QStringList::fromStrList(f);
2210 QStringList filters;
2213 for (QStringList::Iterator it = formats.begin();
2214 it!=formats.end(); ++it)
2219 st = QString("%1 (*.%2 *.jpg)")
2220 .arg(QG_DialogFactory::extToFormat(*it))
2221 .arg(QString(*it).lower());
2225 st = QString("%1 (*.%2)")
2226 .arg(QG_DialogFactory::extToFormat(*it))
2227 .arg(QString(*it).lower());
2232 //if (!all.isEmpty()) {
2235 //all += QString("*.%1").arg(QString(*it).lower());
2238 QStringList filters;
2241 fileDlg.setFilters(filters);
2242 // fileDlg.setMode(Q3FileDialog::AnyFile);
2243 fileDlg.setFileMode(QFileDialog::AnyFile);
2244 // fileDlg.setCaption(QObject::tr("Export Image"));
2245 fileDlg.setWindowTitle(QObject::tr("Export Image"));
2246 // fileDlg.setDir(defDir);
2247 fileDlg.setDirectory(defDir);
2248 fileDlg.selectNameFilter(defFilter);
2250 if (fileDlg.exec() == QDialog::Accepted)
2252 // fn = fileDlg.selectedFile();
2253 QStringList files = fileDlg.selectedFiles();
2255 if (!files.isEmpty())
2263 // store new default settings:
2266 settings.beginGroup("Paths");
2267 // settings.writeEntry("/ExportImage", QFileInfo(fn).dirPath(true));
2268 settings.setValue("ExportImage", QFileInfo(fn).absolutePath());
2269 settings.setValue("ExportImageFilter", fileDlg.selectedFilter());
2270 settings.endGroup();
2272 // find out extension:
2273 QString filter = fileDlg.selectedFilter();
2274 QString format = "";
2275 // int i = filter.find("(*.");
2276 int i = filter.indexOf("(*.");
2280 // int i2 = filter.find(QRegExp("[) ]"), i);
2281 int i2 = filter.indexOf(QRegExp("[) ]"), i);
2282 format = filter.mid(i + 3, i2 - (i + 3));
2283 format = format.toUpper();
2286 // append extension to file:
2287 if (!QFileInfo(fn).fileName().contains("."))
2288 fn.append("." + format.toLower());
2290 // show options dialog:
2291 ImageOptionsDialog dlg(this);
2292 dlg.setGraphicSize(w->getGraphic()->getSize());
2296 bool ret = slotFileExport(fn, format, dlg.getSize(), dlg.isBackgroundBlack());
2300 QString message = tr("Exported: %1").arg(fn);
2301 statusBar()->showMessage(message, 2000);
2302 commandWidget->appendHistory(message);
2310 * Exports the drawing as a bitmap.
2312 * @param name File name.
2313 * @param format File format (e.g. "png")
2314 * @param size Size of the bitmap in pixel
2315 * @param black true: Black background, false: white
2316 * @param bw true: black/white export, false: color
2318 bool ApplicationWindow::slotFileExport(const QString & name, const QString & format, QSize size, bool black, bool bw)
2320 MDIWindow * w = getMDIWindow();
2324 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no window opened");
2328 Drawing * graphic = w->getDocument()->getGraphic();
2330 if (graphic == NULL)
2332 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no graphic");
2336 statusBar()->showMessage(tr("Exporting..."));
2337 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2340 QPixmap * buffer = new QPixmap(size);
2341 // RS_PainterQt * painter = new RS_PainterQt(buffer);
2342 QPainter qpntr(buffer);
2343 PaintInterface * painter = new PaintInterface(&qpntr);
2345 // black background:
2347 // painter->setBackgroundColor(RS_Color(0, 0, 0));
2348 // qpntr.setBackgroundColor(RS_Color(0, 0, 0));
2349 qpntr.setBackground(QBrush(QColor(0, 0, 0)));
2350 // white background:
2352 // painter->setBackgroundColor(RS_Color(255, 255, 255));
2353 // qpntr.setBackgroundColor(RS_Color(255, 255, 255));
2354 qpntr.setBackground(QBrush(QColor(255, 255, 255)));
2358 painter->setDrawingMode(RS2::ModeBW);
2360 // painter->eraseRect(0, 0, size.width(), size.height());
2361 qpntr.eraseRect(0, 0, size.width(), size.height());
2363 RS_StaticGraphicView gv(size.width(), size.height(), painter);
2366 gv.setBackground(RS_Color(0, 0, 0));
2368 gv.setBackground(RS_Color(255, 255, 255));
2370 gv.setContainer(graphic);
2372 gv.drawEntity(graphic, true);
2379 iio.setFileName(name);
2380 iio.setFormat(format);
2387 #warning "Need to port to Qt4... !!! FIX !!!"
2390 QApplication::restoreOverrideCursor();
2392 // GraphicView deletes painter
2399 statusBar()->showMessage(tr("Export complete"), 2000);
2401 statusBar()->showMessage(tr("Export failed!"), 2000);
2407 * Menu file -> close.
2409 void ApplicationWindow::slotFileClose()
2411 RS_DEBUG->print("ApplicationWindow::slotFileClose()");
2413 MDIWindow * m = getMDIWindow();
2422 //m->showMaximized();
2423 m->setWindowState(WindowMaximized);
2429 * Called when a MDI window is actually about to close. Used to
2430 * detach widgets from the document.
2432 void ApplicationWindow::slotFileClosing()
2434 RS_DEBUG->print("ApplicationWindow::slotFileClosing()");
2436 RS_DEBUG->print("detaching lists");
2437 layerWidget->setLayerList(NULL, false);
2438 blockWidget->setBlockList(NULL);
2439 coordinateWidget->setGraphic(NULL);
2441 simulationControls->setGraphicView(NULL);
2446 * Menu file -> print.
2448 void ApplicationWindow::slotFilePrint()
2450 RS_DEBUG->print("ApplicationWindow::slotFilePrint()");
2452 MDIWindow * w = getMDIWindow();
2456 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no window opened");
2460 Drawing * graphic = w->getDocument()->getGraphic();
2462 if (graphic == NULL)
2464 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no graphic");
2468 statusBar()->showMessage(tr("Printing..."));
2469 QPrinter * printer = new QPrinter(QPrinter::HighResolution);
2470 bool landscape = false;
2471 printer->setPageSize(RS2::rsToQtPaperFormat(graphic->getPaperFormat(&landscape)));
2474 printer->setOrientation(QPrinter::Landscape);
2476 printer->setOrientation(QPrinter::Portrait);
2478 settings.beginGroup("Print");
2479 printer->setOutputFileName(settings.value("FileName", "").toString());
2480 printer->setColorMode((QPrinter::ColorMode)settings.value("/ColorMode", (int)QPrinter::Color).toInt());
2481 #warning "!!! Need to port QPrinter::setOutputToFile() to Qt4 !!!"
2482 // printer->setOutputToFile((bool)RS_SETTINGS->readNumEntry("/PrintToFile", 0));
2483 settings.endGroup();
2486 // if (printer->setup(this))
2487 QPrintDialog dialog(printer, this);
2490 //printer->setOutputToFile(true);
2491 //printer->setOutputFileName(outputFile);
2493 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2494 printer->setFullPage(true);
2495 //Can call these functions directly from the QPaintDevice...
2496 // Q3PaintDeviceMetrics metr(printer);
2498 // RS_PainterQt * painter = new RS_PainterQt(printer);
2499 QPainter qpntr(printer);
2500 PaintInterface * painter = new PaintInterface(&qpntr);
2501 painter->setDrawingMode(w->getGraphicView()->getDrawingMode());
2503 // RS_StaticGraphicView gv(metr.width(), metr.height(), painter);
2504 RS_StaticGraphicView gv(printer->width(), printer->height(), painter);
2505 gv.setPrinting(true);
2506 gv.setBorders(0, 0, 0, 0);
2508 // double fx = (double)metr.width() / metr.widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2509 // double fy = (double)metr.height() / metr.heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2510 double fx = (double)printer->width() / printer->widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2511 double fy = (double)printer->height() / printer->heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2512 double f = (fx + fy) / 2;
2513 double scale = graphic->getPaperScale();
2515 gv.setOffset((int)(graphic->getPaperInsertionBase().x * f),
2516 (int)(graphic->getPaperInsertionBase().y * f));
2517 gv.setFactor(f * scale);
2518 gv.setContainer(graphic);
2519 gv.drawEntity(graphic, true);
2521 // GraphicView deletes painter
2526 settings.beginGroup("Print");
2527 #warning "!!! Need to port QPrinter::outputToFile() to Qt4 !!!"
2528 // settings.writeEntry("/PrintToFile", (int)printer->outputToFile());
2529 settings.setValue("ColorMode", (int)printer->colorMode());
2530 settings.setValue("FileName", printer->outputFileName());
2531 settings.endGroup();
2532 QApplication::restoreOverrideCursor();
2537 statusBar()->showMessage(tr("Printing complete"), 2000);
2541 * Menu file -> print preview.
2543 void ApplicationWindow::slotFilePrintPreview(bool on)
2545 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview()");
2547 RS_DEBUG->print(" creating MDI window");
2548 MDIWindow * parent = getMDIWindow();
2552 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrintPreview: no window opened");
2556 // close print preview:
2559 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): off");
2561 if (parent->getGraphicView()->isPrintPreview())
2563 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): close");
2567 // open print preview:
2570 // look for an existing print preview:
2571 MDIWindow * ppv = parent->getPrintPreview();
2575 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): show existing");
2576 slotWindowActivated(ppv);
2581 if (!parent->getGraphicView()->isPrintPreview())
2583 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): create");
2585 MDIWindow * w = new MDIWindow(parent->getDocument(), workspace, 0, Qt::SubWindow);
2586 w->setAttribute(Qt::WA_DeleteOnClose);
2587 parent->addChildWindow(w);
2588 //connect(w, SIGNAL(signalClosing()),
2589 // this, SLOT(slotFileClosing()));
2591 // w->setCaption(tr("Print preview for %1").arg(parent->caption()));
2592 w->setWindowTitle(tr("Print preview for %1").arg(parent->windowTitle()));
2593 // w->setIcon(qPixmapFromMimeSource("document.png"));
2594 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
2595 w->setWindowIcon(QIcon(":/res/document.png"));
2596 w->getGraphicView()->setPrintPreview(true);
2597 w->getGraphicView()->setBackground(RS_Color(255, 255, 255));
2598 w->getGraphicView()->setDefaultAction(new RS_ActionPrintPreview(*w->getDocument(), *w->getGraphicView()));
2600 // only graphics offer block lists, blocks don't
2601 RS_DEBUG->print(" adding listeners");
2602 Drawing * graphic = w->getDocument()->getGraphic();
2604 if (graphic != NULL)
2606 // Link the layer list to the pen tool bar
2607 graphic->addLayerListListener(penToolBar);
2608 // Link the layer list to the layer widget
2609 graphic->addLayerListListener(layerWidget);
2610 // Link the block list to the block widget
2611 graphic->addBlockListListener(blockWidget);
2612 // Center by default:
2613 graphic->centerToPage();
2616 // Link the graphic view to the mouse widget:
2617 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
2618 // Link the graphic view to the coordinate widget:
2619 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
2620 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
2621 // Link the graphic view to the option widget:
2622 //QG_DIALOGFACTORY->setOptionWidget(optionWidget);
2623 // Link the graphic view to the cad tool bar:
2624 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
2625 // Link the graphic view to the command widget:
2626 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
2628 RS_DEBUG->print(" showing MDI window");
2630 if (workspace->subWindowList().isEmpty())
2635 w->getGraphicView()->zoomPage();
2638 slotWindowActivated(w);
2645 * Menu file -> quit.
2647 void ApplicationWindow::slotFileQuit()
2649 RS_DEBUG->print("ApplicationWindow::slotFileQuit()");
2651 statusBar()->showMessage(tr("Exiting application..."));
2653 if (queryExit(false))
2658 * Forces termination of QCad (demo version).
2660 void ApplicationWindow::slotFileDemoQuit()
2662 statusBar()->showMessage(tr("Exiting application..."));
2669 * Shows / hides the grid.
2671 * @param toggle true: show, false: hide.
2673 void ApplicationWindow::slotViewGrid(bool toggle)
2675 RS_DEBUG->print("ApplicationWindow::slotViewGrid()");
2677 MDIWindow * m = getMDIWindow();
2681 Drawing * g = m->getGraphic();
2684 g->setGridOn(toggle);
2690 RS_DEBUG->print("ApplicationWindow::slotViewGrid() OK");
2694 * Enables / disables the draft mode.
2696 * @param toggle true: enable, false: disable.
2698 void ApplicationWindow::slotViewDraft(bool toggle)
2700 RS_DEBUG->print("ApplicationWindow::slotViewDraft()");
2702 /*MDIWindow* m = getMDIWindow();
2704 Drawing* g = m->getGraphic();
2706 g->setDraftOn(toggle);
2710 settings.beginGroup("Appearance");
2711 settings.setValue("DraftMode", toggle);
2712 settings.endGroup();
2718 * Redraws all mdi windows.
2720 void ApplicationWindow::redrawAll()
2724 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2726 for(int i=0; i<int(windows.count()); ++i)
2728 MDIWindow * m = (MDIWindow *)windows.at(i);
2732 QG_GraphicView * gv = m->getGraphicView();
2742 * Updates all grids of all graphic views.
2744 void ApplicationWindow::updateGrids()
2748 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2750 for(int i=0; i<int(windows.count()); ++i)
2752 MDIWindow * m = (MDIWindow *)windows.at(i);
2756 QG_GraphicView * gv = m->getGraphicView();
2766 * Shows / hides the status bar.
2768 * @param showSB true: show, false: hide.
2770 void ApplicationWindow::slotViewStatusBar(bool showSB)
2772 RS_DEBUG->print("ApplicationWindow::slotViewStatusBar()");
2775 statusBar()->show();
2777 statusBar()->hide();
2781 * Shows / hides the layer list.
2783 * @param toggle true: show, false: hide.
2785 /*void ApplicationWindow::slotViewLayerList(bool toggle) {
2786 RS_DEBUG->print("ApplicationWindow::slotViewLayerList()");
2788 if (toggle==false) {
2789 layerDockWindow->hide();
2791 layerDockWindow->show();
2797 * Shows / hides the block list.
2799 * @param toggle true: show, false: hide.
2802 void ApplicationWindow::slotViewBlockList(bool toggle) {
2803 RS_DEBUG->print("ApplicationWindow::slotViewBlockList()");
2805 if (toggle==false) {
2806 blockDockWindow->hide();
2808 blockDockWindow->show();
2814 * Shows / hides the command line.
2816 * @param toggle true: show, false: hide.
2819 void ApplicationWindow::slotViewCommandLine(bool toggle) {
2820 RS_DEBUG->print("ApplicationWindow::slotViewCommandLine()");
2822 if (toggle==false) {
2823 commandDockWindow->hide();
2824 //QG_GraphicView* graphicView = getGraphicView();
2825 //if (graphicView!=NULL) {
2826 //graphicView->setFocus();
2830 commandDockWindow->show();
2836 * Shows / hides the option toolbar.
2838 * @param toggle true: show, false: hide.
2841 void ApplicationWindow::slotViewOptionToolbar(bool toggle) {
2842 RS_DEBUG->print("ApplicationWindow::slotViewOptionToolbar()");
2844 if (toggle==false) {
2845 optionWidget->hide();
2847 optionWidget->show();
2853 * Creates a new MDI window for editing the selected block.
2856 void ApplicationWindow::slotBlocksEdit() {
2857 RS_DEBUG->print("ApplicationWindow::slotBlocksEdit()");
2859 MDIWindow* parent = getMDIWindow();
2861 RS_BlockList* blist = blockWidget->getBlockList();
2863 RS_Block* blk = blist->getActiveBlock();
2865 MDIWindow* w = slotFileNew(blk);
2866 // the parent needs a pointer to the block window and
2868 parent->addChildWindow(w);
2869 w->getGraphicView()->zoomAuto();
2877 * Shows the dialog for general application preferences.
2879 void ApplicationWindow::slotOptionsGeneral()
2881 RS_DIALOGFACTORY->requestOptionsGeneralDialog();
2883 // update background color of all open drawings:
2884 settings.beginGroup("Appearance");
2885 QColor color(settings.value("BackgroundColor", "#000000").toString());
2886 QColor gridColor(settings.value("GridColor", "Gray").toString());
2887 QColor metaGridColor(settings.value("MetaGridColor", "Darkgray").toString());
2888 QColor selectedColor(settings.value("SelectedColor", "#A54747").toString());
2889 QColor highlightedColor(settings.value("HighlightedColor", "#739373").toString());
2890 settings.endGroup();
2892 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2894 for(int i=0; i<int(windows.count()); ++i)
2896 MDIWindow * m = (MDIWindow *)windows.at(i);
2900 QG_GraphicView * gv = m->getGraphicView();
2904 gv->setBackground(color);
2905 gv->setGridColor(gridColor);
2906 gv->setMetaGridColor(metaGridColor);
2907 gv->setSelectedColor(selectedColor);
2908 gv->setHighlightedColor(highlightedColor);
2917 * Menu script -> show ide
2919 void ApplicationWindow::slotScriptOpenIDE()
2922 scripter->openIDE();
2927 * Menu script -> run
2929 void ApplicationWindow::slotScriptRun()
2932 scripter->runScript();
2937 * Menu help -> about.
2939 void ApplicationWindow::slotHelpAbout()
2941 RS_DEBUG->print("ApplicationWindow::slotHelpAbout()");
2942 QStringList modules;
2949 modules += "Scripting";
2952 QString modulesString;
2954 if (modules.empty() == false)
2955 modulesString = modules.join(", ");
2957 modulesString = tr("None");
2959 QMessageBox box(this);
2960 box.setWindowTitle(tr("About..."));
2961 box.setText(QString("<qt>") + // no center for main stream QCad
2962 #ifdef QC_ABOUT_HEADER
2963 QString("<center>") +
2964 QString(QC_ABOUT_HEADER) +
2966 //FAIL "<h2>"+ QC_APPNAME+ "</h2>" +
2967 "<h2>Architektonas</h2>" +
2969 tr("Version: %1").arg("1.0.0") + "<br>" +
2970 tr("Date: %1").arg(__DATE__) + "<br>" +
2971 QString("© 2010 Underground Software,<br>James Hammons") +
2973 #ifdef QC_ABOUT_ADD_COMPANY
2974 + QString("<br>") + QC_ABOUT_ADD_COMPANY
2976 + QString("</center>")
2978 #ifndef QC_ABOUT_HEADER
2979 #warning "Failure..."
2980 // box.setIcon(qPixmapFromMimeSource(QC_APP_ICON));
2981 box.setFixedWidth(340);
2982 box.setFixedHeight(250);
2988 * Menu help -> help.
2990 void ApplicationWindow::slotHelpManual()
2992 #warning "No help system ported to Qt4... !!! FIX !!!"
2994 RS_DEBUG->print("ApplicationWindow::slotHelpManual()");
2996 if (assistant == NULL)
2998 RS_DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
2999 RS_DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
3000 assistant = new QAssistantClient(RS_SYSTEM->getAppDir()+"/bin", this);
3001 connect(assistant, SIGNAL(error(const QString&)), this, SLOT(slotError(const QString&)));
3004 args << QDir::convertSeparators(RS_SYSTEM->getDocPath() + "/qcaddoc.adp");
3005 // args << QString("doc") + QDir::separator() + QString("qcaddoc.adp");
3007 #if QT_VERSION>=0x030200
3008 assistant->setArguments(args);
3011 assistant->openAssistant();
3012 //assistant->showPage("index.html");
3019 void ApplicationWindow::slotTestDumpEntities(RS_EntityContainer * d)
3021 RS_DEBUG->print("ApplicationWindow::slotTestDumpEntities()");
3022 static int level = 0;
3023 std::ofstream dumpFile;
3028 dumpFile.open("debug_entities.html");
3033 dumpFile.open("debug_entities.html", std::ios::app);
3041 dumpFile << "<html>\n";
3042 dumpFile << "<body>\n";
3045 for (RS_Entity* e=d->firstEntity();
3050 dumpFile << "<table border=\"1\">\n";
3051 dumpFile << "<tr><td>Entity: " << e->getId()
3055 << "<tr><td><table><tr>"
3056 << "<td>VIS:" << e->isVisible() << "</td>"
3057 << "<td>UND:" << e->isUndone() << "</td>"
3058 << "<td>SEL:" << e->isSelected() << "</td>"
3059 << "<td>TMP:" << e->getFlag(RS2::FlagTemp) << "</td>";
3060 QString lay = "NULL";
3061 if (e->getLayer()!=NULL) {
3062 lay = e->getLayer()->getName();
3065 //fail << "<td>Layer: " << lay << "</td>"
3066 << "<td>Width: " << (int)e->getPen(false).getWidth() << "</td>"
3067 << "<td>Parent: " << e->getParent()->getId() << "</td>"
3075 case RS2::EntityPoint:
3077 RS_Point* p = (RS_Point*)e;
3079 << "<table><tr><td>"
3091 case RS2::EntityLine:
3093 RS_Line* l = (RS_Line*)e;
3095 << "<table><tr><td>"
3101 << l->getStartpoint()
3110 case RS2::EntityArc: {
3111 RS_Arc* a = (RS_Arc*)e;
3113 << "<table><tr><td>"
3130 << "<td>Startpoint: "
3131 << a->getStartpoint()
3137 << (int)a->isReversed()
3143 case RS2::EntityCircle: {
3144 RS_Circle* c = (RS_Circle*)e;
3146 << "<table><tr><td>"
3161 case RS2::EntityDimAligned: {
3162 RS_DimAligned* d = (RS_DimAligned*)e;
3164 << "<table><tr><td>"
3165 << "<b>Dimension / Aligned:</b>"
3170 << d->getDefinitionPoint()
3173 << d->getExtensionPoint1()
3176 << d->getExtensionPoint2()
3179 << d->getText().toLatin1().data()
3182 << d->getLabel().toLatin1().data()
3188 case RS2::EntityDimLinear:
3190 RS_DimLinear* d = (RS_DimLinear*)e;
3192 << "<table><tr><td>"
3193 << "<b>Dimension / Linear:</b>"
3198 << d->getDefinitionPoint()
3201 << d->getExtensionPoint1()
3204 << d->getExtensionPoint2()
3207 //fail << d->getText()
3210 //fail << d->getLabel()
3216 case RS2::EntityInsert: {
3217 RS_Insert* i = (RS_Insert*)e;
3219 << "<table><tr><td>"
3224 << "<td>Insertion point:"
3225 << i->getInsertionPoint()
3231 case RS2::EntityText: {
3232 RS_Text* t = (RS_Text*)e;
3234 << "<table><tr><td>"
3240 << t->getText().toLatin1().data()
3249 case RS2::EntityHatch: {
3250 RS_Hatch* h = (RS_Hatch*)e;
3252 << "<table><tr><td>"
3258 << h->getPattern().toLatin1().data()
3264 << (int)h->isSolid()
3273 << "<b>Unknown Entity: " << e->rtti() << "</b>"
3278 if (e->isContainer() || e->rtti()==RS2::EntityHatch) {
3279 RS_EntityContainer* ec = (RS_EntityContainer*)e;
3280 dumpFile << "<table><tr><td valign=\"top\"> Contents:</td><td>\n";
3282 slotTestDumpEntities(ec);
3283 dumpFile.open("debug_entities.html", std::ios::app);
3284 dumpFile << "</td></tr></table>\n";
3294 dumpFile << "</body>\n";
3295 dumpFile << "</html>\n";
3305 void ApplicationWindow::slotTestDumpUndo()
3307 RS_DEBUG->print("ApplicationWindow::slotTestDumpUndo()");
3309 RS_Document * d = getDocument();
3313 std::cout << *(RS_Undo*)d;
3314 std::cout << std::endl;
3321 void ApplicationWindow::slotTestUpdateInserts()
3323 RS_DEBUG->print("ApplicationWindow::slotTestUpdateInserts()");
3325 RS_Document * d = getDocument();
3334 void ApplicationWindow::slotTestDrawFreehand()
3336 RS_DEBUG->print("ApplicationWindow::slotTestDrawFreehand()");
3338 //Drawing* g = document->getMarking();
3341 RS_ActionDrawLineFree* action =
3342 new RS_ActionDrawLineFree(*document->getGraphic(),
3345 for (int i=0; i<100; ++i) {
3347 int posx = (random()%600);
3348 int posy = (random()%400);
3350 //RS_MouseEvent rsm1(posx, posy, LEFT);
3351 RS_MouseEvent rsm1(QEvent::MouseButtonPress,
3355 action->mousePressEvent(&rsm1);
3360 for (int k=0; k<100; ++k) {
3361 int accx = (random()%40)-20;
3362 int accy = (random()%40)-20;
3370 //RS_MouseEvent rsm2(posx, posy, LEFT);
3372 RS_MouseEvent rsm2(QEvent::MouseMove,
3376 action->mouseMoveEvent(&rsm2);
3379 action->mouseReleaseEvent(NULL);
3391 void ApplicationWindow::slotTestInsertBlock()
3393 RS_DEBUG->print("ApplicationWindow::slotTestInsertBlock()");
3395 RS_Document * d = getDocument();
3397 if (d != NULL && d->rtti() == RS2::EntityGraphic)
3399 Drawing * graphic = (Drawing *)d;
3401 if (graphic == NULL)
3404 graphic->addLayer(new RS_Layer("default"));
3405 RS_Block * block = new RS_Block(graphic, RS_BlockData("debugblock", Vector(0.0, 0.0), true));
3411 // Add one red line:
3412 line = new RS_Line(block, RS_LineData(Vector(0.0, 0.0), Vector(50.0, 0.0)));
3413 line->setLayerToActive();
3414 line->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3415 block->addEntity(line);
3417 // Add one line with attributes from block:
3418 line = new RS_Line(block, RS_LineData(Vector(50.0, 0.0), Vector(50.0, 50.0)));
3419 line->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3420 block->addEntity(line);
3422 // Add one arc with attributes from block:
3423 RS_ArcData d(Vector(50.0, 0.0), 50.0, M_PI / 2.0, M_PI, false);
3424 arc = new RS_Arc(block, d);
3425 arc->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3426 block->addEntity(arc);
3428 // Add one blue circle:
3429 RS_CircleData circleData(Vector(20.0, 15.0), 12.5);
3430 circle = new RS_Circle(block, circleData);
3431 circle->setLayerToActive();
3432 circle->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width01, RS2::SolidLine));
3433 block->addEntity(circle);
3435 graphic->addBlock(block);
3438 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);
3440 // insert one magenta instance of the block (original):
3441 ins = new RS_Insert(graphic, insData);
3442 ins->setLayerToActive();
3443 ins->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width02, RS2::SolidLine));
3445 graphic->addEntity(ins);
3447 // insert one green instance of the block (rotate):
3448 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);
3449 ins = new RS_Insert(graphic, insData);
3450 ins->setLayerToActive();
3451 ins->setPen(RS_Pen(RS_Color(0, 255, 0), RS2::Width02, RS2::SolidLine));
3453 graphic->addEntity(ins);
3455 // insert one cyan instance of the block (move):
3456 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);
3457 ins = new RS_Insert(graphic, insData);
3458 ins->setLayerToActive();
3459 ins->setPen(RS_Pen(RS_Color(0, 255, 255), RS2::Width02, RS2::SolidLine));
3461 graphic->addEntity(ins);
3463 // insert one blue instance of the block:
3464 for(double a=0.0; a<360.0; a+=45.0)
3466 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);
3467 ins = new RS_Insert(graphic, insData);
3468 ins->setLayerToActive();
3469 ins->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width05, RS2::SolidLine));
3471 graphic->addEntity(ins);
3474 // insert an array of yellow instances of the block:
3475 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);
3476 ins = new RS_Insert(graphic, insData);
3477 ins->setLayerToActive();
3478 ins->setPen(RS_Pen(RS_Color(255, 255, 0), RS2::Width01, RS2::SolidLine));
3480 graphic->addEntity(ins);
3482 GraphicView * v = getGraphicView();
3492 void ApplicationWindow::slotTestInsertEllipse()
3494 RS_DEBUG->print("ApplicationWindow::slotTestInsertEllipse()");
3496 RS_Document * d = getDocument();
3500 Drawing * graphic = (Drawing *)d;
3502 if (graphic == NULL)
3505 RS_Ellipse * ellipse;
3508 for (double a=0.0; a<2*M_PI; a+=0.1)
3511 v.setPolar(50.0, a);
3512 double xp = 1000.0*a;
3514 RS_EllipseData ellipseData(Vector(xp, 0.0), v, 0.5, 0.0, 2 * M_PI, false);
3515 ellipse = new RS_Ellipse(graphic, ellipseData);
3517 ellipse->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width01, RS2::SolidLine));
3519 graphic->addEntity(ellipse);
3520 //graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3521 //graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3523 line = new RS_Line(graphic, RS_LineData(Vector(xp, 0.0), Vector(xp, 0.0) + v));
3524 line->setPen(RS_Pen(RS_Color(128, 128, 128), RS2::Width01, RS2::SolidLine));
3525 graphic->addEntity(line);
3528 for (double mx=-60.0; mx<60.0; mx+=1.0) {
3529 //for (double mx=0.0; mx<1.0; mx+=2.5) {
3530 VectorSolutions sol = ellipse->mapX(xp + mx);
3531 //graphic->addEntity(new RS_Point(graphic,
3532 // sol.vector2 + Vector(a*500.0, 0.0)));
3533 //graphic->addEntity(new RS_Point(graphic,
3534 // sol.vector3 + Vector(a*500.0, 0.0)));
3535 //graphic->addEntity(new RS_Point(graphic,
3536 // sol.vector4 + Vector(a*500.0, 0.0)));
3538 line = new RS_Line(graphic,
3539 RS_LineData(Vector(xp+mx,-50.0),
3540 Vector(xp+mx,50.0)));
3541 line->setPen(RS_Pen(RS_Color(60, 60, 60),
3544 graphic->addEntity(line);
3546 graphic->addEntity(new RS_Point(graphic,
3552 // different minor/minor relations
3555 for (y=-250.0; y<=250.0; y+=50.0) {
3556 for (x=-250.0; x<=250.0; x+=50.0) {
3559 ellipse = new RS_Ellipse(graphic,
3561 Vector((x/5+50.0)/2.0, 0.0),
3566 ellipse->setPen(RS_Pen(RS_Color(255, 255, 0),
3570 graphic->addEntity(ellipse);
3571 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3572 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3574 ellipse = new RS_Ellipse(graphic,
3575 v + Vector(750.0, 0.0),
3576 Vector((x/5+50.0)/2.0, 0.0),
3581 graphic->addEntity(ellipse);
3582 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3583 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3589 // different rotation angles:
3591 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3592 ellipse = new RS_Ellipse(graphic,
3593 Vector(rot*200, 500.0),
3594 Vector(50.0, 0.0).rotate(rot),
3598 graphic->addEntity(ellipse);
3599 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3600 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3604 // different arc angles:
3606 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3607 for (a1=0.0; a1<=2*M_PI+0.1; a1+=(M_PI/8)) {
3608 for (a2=a1+M_PI/8; a2<=2*M_PI+a1+0.1; a2+=(M_PI/8)) {
3609 ellipse = new RS_Ellipse(graphic,
3610 Vector(-500.0-a1*200.0-5000.0*rot,
3612 Vector(50.0, 0.0).rotate(rot),
3616 graphic->addEntity(ellipse);
3617 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3618 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3624 GraphicView * v = getGraphicView();
3634 void ApplicationWindow::slotTestInsertText()
3636 RS_DEBUG->print("ApplicationWindow::slotTestInsertText()");
3638 RS_Document * d = getDocument();
3642 Drawing * graphic = (Drawing *)d;
3644 if (graphic == NULL)
3648 RS_TextData textData;
3650 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);
3651 text = new RS_Text(graphic, textData);
3652 text->setLayerToActive();
3653 text->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3654 graphic->addEntity(text);
3658 for (y=-250.0; y<=250.0; y+=50.0) {
3659 for (x=-250.0; x<=250.0; x+=50.0) {
3662 textData = RS_TextData(v,
3673 text = new RS_Text(graphic, textData);
3675 text->setLayerToActive();
3676 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3679 graphic->addEntity(text);
3684 for (x=0.0; x<M_PI*2.0; x+=0.2) {
3685 Vector v(600.0+cos(x)*50.0, 0.0+sin(x)*50.0);
3687 line = new RS_Line(graphic,
3688 RS_LineData(Vector(600.0,0.0),
3690 line->setLayerToActive();
3691 line->setPenToActive();
3692 graphic->addEntity(line);
3694 textData = RS_TextData(v,
3705 text = new RS_Text(graphic, textData);
3707 text->setLayerToActive();
3708 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3711 graphic->addEntity(text);
3714 RS_SolidData solidData = RS_SolidData(Vector(5.0, 10.0),
3716 Vector(15.0, 30.0));
3718 RS_Solid* s = new RS_Solid(graphic, solidData);
3720 s->setLayerToActive();
3721 s->setPen(RS_Pen(RS_Color(255, 255, 0),
3724 graphic->addEntity(s);
3726 GraphicView* v = getGraphicView();
3737 void ApplicationWindow::slotTestInsertImage()
3739 RS_DEBUG->print("ApplicationWindow::slotTestInsertImage()");
3741 RS_Document * d = getDocument();
3745 Drawing * graphic = (Drawing *)d;
3747 if (graphic == NULL)
3751 RS_ImageData imageData;
3753 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);
3754 image = new RS_Image(graphic, imageData);
3756 image->setLayerToActive();
3757 image->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3758 graphic->addEntity(image);
3765 void ApplicationWindow::slotTestUnicode()
3767 RS_DEBUG->print("ApplicationWindow::slotTestUnicode()");
3769 slotFileOpen("./fonts/unicode.cxf", RS2::FormatCXF);
3770 RS_Document* d = getDocument();
3772 Drawing* graphic = (Drawing*)d;
3773 if (graphic==NULL) {
3781 QChar uCode; // e.g. 65 (or 'A')
3782 QString strCode; // unicde as string e.g. '[0041] A'
3784 graphic->setAutoUpdateBorders(false);
3786 for (col=0x0000; col<=0xFFF0; col+=0x10) {
3787 printf("col: %X\n", col);
3788 for (row=0x0; row<=0xF; row++) {
3789 //printf(" row: %X\n", row);
3791 uCode = QChar(col+row);
3792 //printf(" code: %X\n", uCode.unicode());
3794 strCode.setNum(uCode.unicode(), 16);
3795 while (strCode.length()<4) {
3796 strCode="0"+strCode;
3798 strCode = "[" + strCode + "] " + uCode;
3800 if (graphic->findBlock(strCode)!=NULL) {
3801 RS_InsertData d(strCode,
3802 Vector(col/0x10*20.0,row*20.0),
3803 Vector(1.0,1.0), 0.0,
3804 1, 1, Vector(0.0, 0.0),
3805 NULL, RS2::NoUpdate);
3806 ins = new RS_Insert(graphic, d);
3807 ins->setLayerToActive();
3808 ins->setPen(RS_Pen(RS_Color(255, 255, 255),
3812 graphic->addEntity(ins);
3816 graphic->setAutoUpdateBorders(true);
3817 graphic->calculateBorders();
3824 void ApplicationWindow::slotTestMath01()
3826 RS_DEBUG->print("ApplicationWindow::slotTestMath01()");
3828 RS_Document* d = getDocument();
3830 Drawing* graphic = (Drawing*)d;
3831 if (graphic==NULL) {
3836 graphic->addEntity(new RS_Line(graphic,
3837 RS_LineData(Vector(0.0,0.0),
3838 Vector(2*M_PI,0.0))));
3839 graphic->addEntity(new RS_Line(graphic,
3840 RS_LineData(Vector(0.0,-1.0),
3845 double x = 59.0/ARAD;
3846 double x_0 = 60.0/ARAD;
3847 for (a=0.01; a<2*M_PI; a+=0.01) {
3849 RS_Line* line = new RS_Line(graphic,
3850 RS_LineData(Vector(a-0.01, cos(a-0.01)),
3851 Vector(a, cos(a))));
3852 graphic->addEntity(line);
3855 graphic->addEntity(new RS_Line(graphic,
3856 RS_LineData(Vector(a-0.01,cos(x_0)-sin(x_0)*(a-0.01-x_0)),
3857 Vector(a,cos(x_0)-sin(x_0)*(a-x_0)))));
3861 graphic->addEntity(new RS_Line(graphic,
3862 RS_LineData(Vector(x,0.0),
3866 graphic->addEntity(new RS_Line(graphic,
3867 RS_LineData(Vector(x_0,0.0),
3871 //graphic->addEntity(new RS_Line(graphic,
3872 // Vector(0.0,cos(x_0)-sin(x_0)*(0.0-x_0)),
3873 // Vector(6.0,cos(x_0)-sin(x_0)*(6.0-x_0))));
3876 GraphicView* v = getGraphicView();
3886 void ApplicationWindow::slotTestResize640()
3888 RS_DEBUG->print("ApplicationWindow::slotTestResize640()");
3896 void ApplicationWindow::slotTestResize800()
3898 RS_DEBUG->print("ApplicationWindow::slotTestResize800()");
3906 void ApplicationWindow::slotTestResize1024()
3908 RS_DEBUG->print("ApplicationWindow::slotTestResize1024()");
3914 * overloaded for Message box on last window exit.
3916 bool ApplicationWindow::queryExit(bool force)
3918 RS_DEBUG->print("ApplicationWindow::queryExit()");
3925 QMessageBox::information(this, QMessageBox::tr("Warning"),
3926 tr("This is a %1 version "
3927 "which terminates\n"
3928 "automatically after 10min. This software is\n"
3929 "not intended for production use. Please buy\n"
3930 "a full version of the application from\n%2.\n"
3931 "You can save your work now.")
3932 //FAIL .arg(QC_APPNAME)
3933 .arg("Architektonas")
3934 #ifdef QC_CUSTOM_VENDOR
3935 .arg(QC_CUSTOM_VENDOR),
3937 .arg("RibbonSoft, http://www.ribbonsoft.com"),
3942 QList<QMdiSubWindow *> list = workspace->subWindowList();
3944 // for(QWidget * w=list.first(); w!=NULL; w=list.next())
3945 for(int i=0; i<list.size(); i++)
3947 succ = ((MDIWindow *)list[i])->closeMDI(force);
3956 RS_DEBUG->print("ApplicationWindow::queryExit(): OK");
3962 * Handle hotkeys. Don't let it to the default handler of Qt.
3963 * it will consume them also if a text field is active
3964 * which means it's impossible to enter a command.
3966 void ApplicationWindow::keyPressEvent(QKeyEvent * e)
3968 #warning "!!! keyPressEvent(): Do we need this anymore? !!!"
3970 static QTime ts = QTime();
3971 static QString firstKey = "";
3973 // single key codes:
3977 case Qt::Key_Control:
3980 case Qt::Key_CapsLock:
3982 QMainWindow::keyPressEvent(e);
3984 // forward to actions:
3985 GraphicView * graphicView = getGraphicView();
3988 graphicView->keyPressEvent(e);
3994 case Qt::Key_Escape:
4000 case Qt::Key_Return:
4001 if (firstKey.isEmpty())
4009 if (firstKey.isEmpty())
4011 actionHandler->slotZoomIn();
4017 if (firstKey.isEmpty())
4019 actionHandler->slotZoomOut();
4029 if (e->isAccepted())
4032 QTime now = QTime::currentTime();
4035 if (ts.msecsTo(now) < 2000)
4037 QString code = QString("%1%2").arg(firstKey).arg(QChar(e->key())).toLower();
4039 if (actionHandler->keycode(code) == false)
4043 if (QChar(e->key()).isPrint())
4044 firstKey += e->key();
4053 if (QChar(e->key()).isPrint())
4054 firstKey = e->key();
4057 // Q3MainWindow::keyPressEvent(e);
4058 QMainWindow::keyPressEvent(e);
4061 void ApplicationWindow::keyReleaseEvent(QKeyEvent * e)
4066 case Qt::Key_Control:
4069 case Qt::Key_CapsLock:
4071 // Q3MainWindow::keyReleaseEvent(e);
4072 QMainWindow::keyReleaseEvent(e);
4074 // forward to actions:
4075 GraphicView * graphicView = getGraphicView();
4078 graphicView->keyReleaseEvent(e);
4085 // Q3MainWindow::keyPressEvent(e);
4086 QMainWindow::keyPressEvent(e);
4090 * @return Pointer to application window.
4092 /*static*/ ApplicationWindow * ApplicationWindow::getAppWindow()
4098 * @return Pointer to workspace.
4100 QMdiArea * ApplicationWindow::getWorkspace()
4106 * @return Pointer to the currently active MDI Window or NULL if no
4107 * MDI Window is active.
4109 MDIWindow * ApplicationWindow::getMDIWindow()
4111 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::getMDIWindow: workspace=%08X", workspace);
4115 RS_DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=%08X", workspace->activeSubWindow());
4116 return (MDIWindow *)workspace->activeSubWindow();
4119 RS_DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=??? (workspace == NULL)");
4124 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4126 * @return Pointer to the graphic view of the currently active document
4127 * window or NULL if no window is available.
4129 /*virtual*/ GraphicView * ApplicationWindow::getGraphicView()
4131 MDIWindow * m = getMDIWindow();
4133 return (m ? m->getGraphicView() : NULL);
4137 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4139 * @return Pointer to the graphic document of the currently active document
4140 * window or NULL if no window is available.
4142 /*virtual*/ RS_Document * ApplicationWindow::getDocument()
4144 MDIWindow * m = getMDIWindow();
4146 return (m ? m->getDocument() : NULL);
4150 * Creates a new document. Implementation from RS_MainWindowInterface.
4152 /*virtual*/ void ApplicationWindow::createNewDocument(const QString & fileName/*= QString::null*/,
4153 RS_Document * doc/*= NULL*/)
4157 if (fileName != QString::null && getDocument())
4158 getDocument()->setFilename(fileName);
4162 * Implementation from QG_MainWindowInterface.
4164 * @return Pointer to this.
4166 /*virtual*/ QMainWindow * ApplicationWindow::GetMainWindow()
4172 * @return Pointer to action handler. Implementation from QG_MainWindowInterface.
4174 /*virtual*/ QG_ActionHandler * ApplicationWindow::getActionHandler()
4176 return actionHandler;
4180 * Implementation from QG_MainWindowInterface.
4182 /*virtual*/ void ApplicationWindow::showSimulationControls()
4185 simulationDockWindow->show();
4191 * @return Pointer to the qsa object.
4193 QSProject * ApplicationWindow::getQSAProject()
4195 if (scripter != NULL)
4196 return scripter->getQSAProject();
4203 * Implementation from QG_MainWindowInterface.
4205 /*virtual*/ void ApplicationWindow::setFocus2()