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 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/17/2010 Added this text. :-)
15 // JLH 05/27/2010 Finished refactoring old Qt3 based action handling code to
16 // Qt4's much more sensible action handling
19 #include "applicationwindow.h"
22 #include "actiondrawlinefree.h"
23 #include "actionlibraryinsert.h"
24 #include "actionprintpreview.h"
25 #include "rs_creation.h"
26 #include "rs_dialogfactory.h"
27 #include "rs_dimaligned.h"
28 #include "rs_dimlinear.h"
29 #include "rs_dimradial.h"
30 #include "rs_ellipse.h"
31 #include "rs_fileio.h"
33 #include "rs_insert.h"
35 #include "paintinterface.h"
36 #include "rs_script.h"
37 #include "rs_scriptlist.h"
40 #include "rs_staticgraphicview.h"
41 #include "rs_system.h"
46 #include "rs_camdialog.h"
47 #include "rs_simulationcontrols.h"
51 #include "filedialog.h"
52 #include "pentoolbar.h"
53 #include "recentfiles.h"
54 #include "cadtoolbar.h"
55 #include "cadtoolbarmain.h"
56 #include "coordinatewidget.h"
57 #include "dlgimageoptions.h"
58 #include "mousewidget.h"
59 #include "selectionwidget.h"
61 #include "createqtactions.h"
62 #include "qc_dialogfactory.h"
63 #include "qg_graphicview.h"
65 #include "mdiwindow.h"
67 ApplicationWindow * ApplicationWindow::appWindow = NULL;
70 # define QC_APP_ICON "qcad.png"
73 # define QC_APP_ICON16 "qcad16.png"
76 extern QSplashScreen * splash;
79 * Constructor. Initializes the app.
81 ApplicationWindow::ApplicationWindow():
82 // Q3MainWindow(0, "", Qt::WDestructiveClose), QG_MainWindowInterface()
83 QMainWindow((QWidget *)NULL/*,this is not a Qt::WindowFlags --> Qt::WA_DeleteOnClose*/), QG_MainWindowInterface()
85 RS_DEBUG->print("ApplicationWindow::ApplicationWindow");
88 //no assistant = NULL;
91 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: setting icon");
92 // setIcon(qPixmapFromMimeSource(QC_APP_ICON));
93 // setWindowIcon(qPixmapFromMimeSource(QC_APP_ICON));
94 setWindowIcon(QIcon(":/res/" QC_APP_ICON));
95 CreateQtActions(this);
97 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler");
98 actionHandler = new ActionHandler(this);
99 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler: OK");
102 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating scripter");
103 scripter = new QS_Scripter(this, this);
104 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating scripter: OK");
107 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init view");
109 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init toolbar");
111 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init actions");
113 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init menu bar");
115 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init status bar");
118 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory");
119 dialogFactory = new QC_DialogFactory(this, optionWidget);
120 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory: OK");
121 RS_DEBUG->print("setting dialog factory object");
123 if (RS_DialogFactory::instance() == NULL)
124 RS_DEBUG->print("no RS_DialogFactory instance");
126 RS_DEBUG->print("got RS_DialogFactory instance");
128 RS_DialogFactory::instance()->setFactoryObject(dialogFactory);
129 RS_DEBUG->print("setting dialog factory object: OK");
131 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init settings");
134 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init MDI");
137 // Disable menu and toolbar items
138 emit windowsChanged(FALSE);
140 //FAIL statusBar()->showMessage(QC_APPNAME " Ready", 2000);
141 statusBar()->showMessage("Architektonas Ready", 2000);
142 //setFocusPolicy(WheelFocus);
148 ApplicationWindow::~ApplicationWindow()
150 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow");
152 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting scripter");
154 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting scripter: OK");
157 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting action handler");
158 delete actionHandler;
159 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting action handler: OK");
161 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory");
162 delete dialogFactory;
163 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory: OK");
165 //no RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: "
166 // "deleting assistant..");
167 // if (assistant!=NULL) {
170 // RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: "
171 // "deleting assistant: OK");
172 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: OK");
176 * Runs the start script if scripting is available.
178 void ApplicationWindow::slotRunStartScript()
180 slotRunScript("autostart.qs");
184 * Runs a script. The action that triggers this slot has to carry the
185 * name of the script file.
187 void ApplicationWindow::slotRunScript()
189 RS_DEBUG->print("ApplicationWindow::slotRunScript");
191 const QObject * s = sender();
195 QString script = ((QAction *)s)->text();
196 RS_DEBUG->print("ApplicationWindow::slotRunScript: %s", script.toLatin1().data());
197 slotRunScript(script);
202 * Runs the script with the given name.
204 void ApplicationWindow::slotRunScript(const QString & name)
207 RS_DEBUG->print("ApplicationWindow::slotRunScript");
209 if (scripter == NULL)
211 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotRunScript: scripter not initialized");
215 statusBar()->showMessage(tr("Running script '%1'").arg(name), 2000);
217 QStringList scriptList = RS_SYSTEM->getScriptList();
218 scriptList.append(RS_SYSTEM->getHomeDir() + "/.qcad/" + name);
220 for (QStringList::Iterator it = scriptList.begin(); it!=scriptList.end(); ++it)
222 RS_DEBUG->print("ApplicationWindow::slotRunScript: checking script '%s'", (*it).toLatin1().data();
225 if (fi.exists() && fi.fileName() == name)
227 RS_DEBUG->print("ApplicationWindow::slotRunScript: running '%s'", (*it).toLatin1().data());
228 scripter->runScript(*it, "main");
235 * Called from toolbar buttons that were added by scripts to
238 void ApplicationWindow::slotInsertBlock()
240 const QObject * s = sender();
244 QString block = ((QAction *)s)->text();
245 RS_DEBUG->print("ApplicationWindow::slotInsertBlock: %s", block.toLatin1().data());
246 slotInsertBlock(block);
251 * Called to insert blocks.
253 void ApplicationWindow::slotInsertBlock(const QString & name)
255 RS_DEBUG->print("ApplicationWindow::slotInsertBlock: '%s'", name.toLatin1().data());
257 statusBar()->showMessage(tr("Inserting block '%1'").arg(name), 2000);
259 GraphicView * graphicView = getGraphicView();
260 RS_Document * document = getDocument();
262 if (graphicView && document)
264 ActionLibraryInsert * action = new ActionLibraryInsert(*document, *graphicView);
265 action->setFile(name);
266 graphicView->setCurrentAction(action);
271 * Shows the main application window and a splash screen.
273 void ApplicationWindow::show()
275 #ifdef QSPLASHSCREEN_H
282 #ifdef QSPLASHSCREEN_H
286 qApp->processEvents();
287 splash->clearMessage();
288 # ifdef QC_DELAYED_SPLASH_SCREEN
289 QTimer::singleShot(1000 * 2, this, SLOT(finishSplashScreen()));
291 finishSplashScreen();
298 * Called when the splash screen has to terminate.
300 void ApplicationWindow::finishSplashScreen()
302 #ifdef QSPLASHSCREEN_H
305 splash->finish(this);
313 * Close Event. Called when the user tries to close the app.
315 void ApplicationWindow::closeEvent(QCloseEvent * /*ce*/)
317 RS_DEBUG->print("ApplicationWindow::closeEvent()");
319 RS_DEBUG->print("ApplicationWindow::closeEvent(): OK");
323 * Handles right-clicks for moving back to the last cad tool bar.
325 void ApplicationWindow::mouseReleaseEvent(QMouseEvent * e)
327 if (e->button() == Qt::RightButton && cadToolBar != NULL)
328 cadToolBar->showToolBarMain();
334 * Initializes the MDI workspace.
336 void ApplicationWindow::initMDI()
338 RS_DEBUG->print("ApplicationWindow::initMDI() begin");
340 /* Could use QVBoxLayout instead of Q3VBox, but do we even need to? */
341 // Q3VBox * vb = new Q3VBox(this);
342 // vb->setFrameStyle(Q3Frame::StyledPanel | Q3Frame::Sunken);
343 // workspace = new QMdiArea(vb);
344 workspace = new QMdiArea(this);
345 // workspace->setScrollBarsEnabled(true);
346 // setCentralWidget(vb);
347 setCentralWidget(workspace);//JLH:hmm. (Yes, it works! \o/)
348 RS_DEBUG->print("ApplicationWindow::initMDI(): workspace=%08X", workspace);
350 //#warning "Object::connect: No such signal QMdiArea::windowActivated(QWidget *)"
351 // connect(workspace, SIGNAL(windowActivated(QWidget *)), this, SLOT(slotWindowActivated(QWidget *)));
352 connect(workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this,
353 SLOT(slotWindowActivated(QMdiSubWindow *)));
355 RS_DEBUG->print("ApplicationWindow::initMDI() end");
359 * Initializes all QActions of the application.
360 * (Actually, it creates all application menus & toolbars. All actions are
361 * created in CreateQtActions() and simply referenced here.)
363 void ApplicationWindow::initActions()
365 RS_DEBUG->print("ApplicationWindow::initActions()");
370 QMenu * menu = new QMenu(tr("&File"), this);
371 QToolBar * tb = fileToolBar;
372 tb->setWindowTitle("File");
373 // tb->setCloseMode(Q3DockWindow::Undocked);
375 menu->addAction(actionFileNew);
376 tb->addAction(actionFileNew);
377 connect(actionFileNew, SIGNAL(activated()), this, SLOT(slotFileNew()));
378 menu->addAction(actionFileOpen);
379 tb->addAction(actionFileOpen);
380 connect(actionFileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen()));
381 menu->addAction(actionFileSave);
382 tb->addAction(actionFileSave);
383 connect(actionFileSave, SIGNAL(activated()), this, SLOT(slotFileSave()));
384 connect(this, SIGNAL(windowsChanged(bool)), actionFileSave, SLOT(setEnabled(bool)));
385 menu->addAction(actionFileSaveAs);
386 connect(actionFileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs()));
387 connect(this, SIGNAL(windowsChanged(bool)), actionFileSaveAs, SLOT(setEnabled(bool)));
388 menu->addAction(actionFileExport);
389 connect(actionFileExport, SIGNAL(activated()), this, SLOT(slotFileExport()));
390 connect(this, SIGNAL(windowsChanged(bool)), actionFileExport, SLOT(setEnabled(bool)));
392 menu->addSeparator();
394 menu->addAction(actionFileClose);
395 connect(actionFileClose, SIGNAL(activated()), this, SLOT(slotFileClose()));
396 connect(this, SIGNAL(windowsChanged(bool)), actionFileClose, SLOT(setEnabled(bool)));
398 menu->addSeparator();
400 menu->addAction(actionFilePrint);
401 tb->addAction(actionFilePrint);
402 connect(actionFilePrint, SIGNAL(activated()), this, SLOT(slotFilePrint()));
403 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrint, SLOT(setEnabled(bool)));
404 menu->addAction(actionFilePrintPreview);
405 tb->addAction(actionFilePrintPreview);
406 connect(actionFilePrintPreview, SIGNAL(toggled(bool)), this, SLOT(slotFilePrintPreview(bool)));
407 connect(this, SIGNAL(printPreviewChanged(bool)), actionFilePrintPreview, SLOT(setOn(bool)));
408 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrintPreview, SLOT(setEnabled(bool)));
410 menu->addSeparator();
412 menu->addAction(actionFileQuit);
413 connect(actionFileQuit, SIGNAL(activated()), this, SLOT(slotFileQuit()));
415 menu->addSeparator();
417 menuBar()->addMenu(menu);
418 addToolBar(Qt::TopToolBarArea, tb);
424 menu = new QMenu(tr("&Edit"), this);
426 tb->setWindowTitle("Edit");
427 // tb->setCloseMode(Q3DockWindow::Undocked);
429 // action = actionFactory.createAction(RS2::ActionEditUndo, actionHandler);
430 menu->addAction(actionEditUndo);
431 tb->addAction(actionEditUndo);
432 connect(actionEditUndo, SIGNAL(activated()), actionHandler, SLOT(slotEditUndo()));
433 connect(this, SIGNAL(windowsChanged(bool)), actionEditUndo, SLOT(setEnabled(bool)));
434 // action = actionFactory.createAction(RS2::ActionEditRedo, actionHandler);
435 menu->addAction(actionEditRedo);
436 tb->addAction(actionEditRedo);
437 connect(actionEditRedo, SIGNAL(activated()), actionHandler, SLOT(slotEditRedo()));
438 connect(this, SIGNAL(windowsChanged(bool)), actionEditRedo, SLOT(setEnabled(bool)));
441 menu->addSeparator();
443 // action = actionFactory.createAction(RS2::ActionEditCut, actionHandler);
444 menu->addAction(actionEditCut);
445 tb->addAction(actionEditCut);
446 connect(actionEditCut, SIGNAL(activated()), actionHandler, SLOT(slotEditCut()));
447 connect(this, SIGNAL(windowsChanged(bool)), actionEditCut, SLOT(setEnabled(bool)));
448 // action = actionFactory.createAction(RS2::ActionEditCopy, actionHandler);
449 menu->addAction(actionEditCopy);
450 tb->addAction(actionEditCopy);
451 connect(actionEditCopy, SIGNAL(activated()), actionHandler, SLOT(slotEditCopy()));
452 connect(this, SIGNAL(windowsChanged(bool)), actionEditCopy, SLOT(setEnabled(bool)));
453 // action = actionFactory.createAction(RS2::ActionEditPaste, actionHandler);
454 menu->addAction(actionEditPaste);
455 tb->addAction(actionEditPaste);
456 connect(actionEditPaste, SIGNAL(activated()), actionHandler, SLOT(slotEditPaste()));
457 connect(this, SIGNAL(windowsChanged(bool)), actionEditPaste, SLOT(setEnabled(bool)));
459 menu->addSeparator();
461 menu->addAction(actionOptionsGeneral);
462 connect(actionOptionsGeneral, SIGNAL(activated()), this, SLOT(slotOptionsGeneral()));
463 menu->addAction(actionOptionsDrawing);
464 connect(actionOptionsDrawing, SIGNAL(activated()), actionHandler, SLOT(slotOptionsDrawing()));
465 connect(this, SIGNAL(windowsChanged(bool)), actionOptionsDrawing, SLOT(setEnabled(bool)));
467 menuBar()->addMenu(menu);
468 addToolBar(Qt::TopToolBarArea, tb);
472 //menu = new QPopupMenu(this);
473 //menuBar()->insertItem(tr("&Options"), menu);
475 // Viewing / Zooming actions:
477 // menu = new Q3PopupMenu(this);
478 menu = new QMenu(tr("&View"), this);
479 //obsolete: menu->setCheckable(true);
481 tb->setWindowTitle("View");
482 // tb->setCloseMode(Q3DockWindow::Undocked);
484 // action = actionFactory.createAction(RS2::ActionViewGrid, this);
485 menu->addAction(actionViewGrid);
486 tb->addAction(actionViewGrid);
487 actionViewGrid->setChecked(true);
488 connect(actionViewGrid, SIGNAL(toggled(bool)), this, SLOT(slotViewGrid(bool)));
489 connect(this, SIGNAL(gridChanged(bool)), actionViewGrid, SLOT(setOn(bool)));
490 connect(this, SIGNAL(windowsChanged(bool)), actionViewGrid, SLOT(setEnabled(bool)));
492 settings.beginGroup("Appearance");
493 bool draftMode = settings.value("DraftMode", false).toBool();
496 // action = actionFactory.createAction(RS2::ActionViewDraft, this);
497 menu->addAction(actionViewDraft);
498 tb->addAction(actionViewDraft);
499 actionViewDraft->setChecked(draftMode);
500 connect(actionViewDraft, SIGNAL(toggled(bool)), this, SLOT(slotViewDraft(bool)));
501 connect(this, SIGNAL(draftChanged(bool)), actionViewDraft, SLOT(setOn(bool)));
502 connect(this, SIGNAL(windowsChanged(bool)), actionViewDraft, SLOT(setEnabled(bool)));
505 action = actionFactory.createAction(RS2::ActionViewLayerList, this);
507 action->setChecked(true);
508 action = actionFactory.createAction(RS2::ActionViewBlockList, this);
510 action->setChecked(true);
511 action = actionFactory.createAction(RS2::ActionViewOptionToolbar, this);
513 action->setChecked(true);
514 action = actionFactory.createAction(RS2::ActionViewCommandLine, this);
516 action->setChecked(true);*/
518 // action = actionFactory.createAction(RS2::ActionZoomRedraw, actionHandler);
519 menu->addAction(actionZoomRedraw);
520 tb->addAction(actionZoomRedraw);
521 connect(actionZoomRedraw, SIGNAL(activated()), actionHandler, SLOT(slotZoomRedraw()));
522 connect(this, SIGNAL(windowsChanged(bool)), actionZoomRedraw, SLOT(setEnabled(bool)));
523 // action = actionFactory.createAction(RS2::ActionZoomIn, actionHandler);
524 menu->addAction(actionZoomIn);
525 tb->addAction(actionZoomIn);
526 connect(actionZoomIn, SIGNAL(activated()), actionHandler, SLOT(slotZoomIn()));
527 connect(this, SIGNAL(windowsChanged(bool)), actionZoomIn, SLOT(setEnabled(bool)));
528 // action = actionFactory.createAction(RS2::ActionZoomOut, actionHandler);
529 menu->addAction(actionZoomOut);
530 tb->addAction(actionZoomOut);
531 connect(actionZoomOut, SIGNAL(activated()), actionHandler, SLOT(slotZoomOut()));
532 connect(this, SIGNAL(windowsChanged(bool)), actionZoomOut, SLOT(setEnabled(bool)));
533 // action = actionFactory.createAction(RS2::ActionZoomAuto, actionHandler);
534 menu->addAction(actionZoomAuto);
535 tb->addAction(actionZoomAuto);
536 connect(actionZoomAuto, SIGNAL(activated()), actionHandler, SLOT(slotZoomAuto()));
537 connect(this, SIGNAL(windowsChanged(bool)), actionZoomAuto, SLOT(setEnabled(bool)));
538 // action = actionFactory.createAction(RS2::ActionZoomPrevious, actionHandler);
539 menu->addAction(actionZoomPrevious);
540 tb->addAction(actionZoomPrevious);
541 connect(actionZoomPrevious, SIGNAL(activated()), actionHandler, SLOT(slotZoomPrevious()));
542 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPrevious, SLOT(setEnabled(bool)));
543 // action = actionFactory.createAction(RS2::ActionZoomWindow, actionHandler);
544 menu->addAction(actionZoomWindow);
545 tb->addAction(actionZoomWindow);
546 connect(actionZoomWindow, SIGNAL(activated()), actionHandler, SLOT(slotZoomWindow()));
547 connect(this, SIGNAL(windowsChanged(bool)), actionZoomWindow, SLOT(setEnabled(bool)));
548 // action = actionFactory.createAction(RS2::ActionZoomPan, actionHandler);
549 menu->addAction(actionZoomPan);
550 tb->addAction(actionZoomPan);
551 connect(actionZoomPan, SIGNAL(activated()), actionHandler, SLOT(slotZoomPan()));
552 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPan, SLOT(setEnabled(bool)));
554 menu->addSeparator();
556 // action = actionFactory.createAction(RS2::ActionViewStatusBar, this);
557 menu->addAction(actionViewStatusbar);
558 actionViewStatusbar->setChecked(true);
559 connect(actionViewStatusbar, SIGNAL(toggled(bool)), this, SLOT(slotViewStatusBar(bool)));
562 menu->insertItem(tr("Vie&ws"), createDockWindowMenu(NoToolBars));
563 menu->insertItem(tr("Tool&bars"), createDockWindowMenu(OnlyToolBars));
565 //Actually, this isn't really needed... This crap is maintained by Qt...
566 //#warning "!!! More stuff to port to Qt4 !!!"
569 menu->addAction(actionFocusCommandLine);
570 connect(actionFocusCommandLine, SIGNAL(activated()), this, SLOT(slotFocusCommandLine()));
571 connect(this, SIGNAL(windowsChanged(bool)), actionFocusCommandLine, SLOT(setEnabled(bool)));
572 menuBar()->addMenu(menu);
573 //addToolBar(tb, tr("View"));
574 // addDockWindow(tb, tr("View"), Qt::DockTop);
575 addToolBar(Qt::TopToolBarArea, tb);
577 // Selecting actions:
579 menu = new QMenu(tr("&Select"), this);
580 // action = actionFactory.createAction(RS2::ActionDeselectAll, actionHandler);
581 menu->addAction(actionDeselectAll);
582 connect(actionDeselectAll, SIGNAL(activated()), actionHandler, SLOT(slotDeselectAll()));
583 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectAll, SLOT(setEnabled(bool)));
584 // action = actionFactory.createAction(RS2::ActionSelectAll, actionHandler);
585 menu->addAction(actionSelectAll);
586 connect(actionSelectAll, SIGNAL(activated()), actionHandler, SLOT(slotSelectAll()));
587 connect(this, SIGNAL(windowsChanged(bool)), actionSelectAll, SLOT(setEnabled(bool)));
588 // action = actionFactory.createAction(RS2::ActionSelectSingle, actionHandler);
589 menu->addAction(actionSelectSingle);
590 connect(actionSelectSingle, SIGNAL(activated()), actionHandler, SLOT(slotSelectSingle()));
591 connect(this, SIGNAL(windowsChanged(bool)), actionSelectSingle, SLOT(setEnabled(bool)));
592 // action = actionFactory.createAction(RS2::ActionSelectContour, actionHandler);
593 menu->addAction(actionSelectContour);
594 connect(actionSelectContour, SIGNAL(activated()), actionHandler, SLOT(slotSelectContour()));
595 connect(this, SIGNAL(windowsChanged(bool)), actionSelectContour, SLOT(setEnabled(bool)));
596 // action = actionFactory.createAction(RS2::ActionDeselectWindow, actionHandler);
597 menu->addAction(actionDeselectWindow);
598 connect(actionDeselectWindow, SIGNAL(activated()), actionHandler, SLOT(slotDeselectWindow()));
599 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectWindow, SLOT(setEnabled(bool)));
600 // action = actionFactory.createAction(RS2::ActionSelectWindow, actionHandler);
601 menu->addAction(actionSelectWindow);
602 connect(actionSelectWindow, SIGNAL(activated()), actionHandler, SLOT(slotSelectWindow()));
603 connect(this, SIGNAL(windowsChanged(bool)), actionSelectWindow, SLOT(setEnabled(bool)));
604 // action = actionFactory.createAction(RS2::ActionSelectInvert, actionHandler);
605 menu->addAction(actionSelectInvert);
606 connect(actionSelectInvert, SIGNAL(activated()), actionHandler, SLOT(slotSelectInvert()));
607 connect(this, SIGNAL(windowsChanged(bool)), actionSelectInvert, SLOT(setEnabled(bool)));
608 // action = actionFactory.createAction(RS2::ActionSelectIntersected, actionHandler);
609 menu->addAction(actionSelectIntersected);
610 connect(actionSelectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotSelectIntersected()));
611 connect(this, SIGNAL(windowsChanged(bool)), actionSelectIntersected, SLOT(setEnabled(bool)));
612 // action = actionFactory.createAction(RS2::ActionDeselectIntersected, actionHandler);
613 menu->addAction(actionDeselectIntersected);
614 connect(actionDeselectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotDeselectIntersected()));
615 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectIntersected, SLOT(setEnabled(bool)));
616 // action = actionFactory.createAction(RS2::ActionSelectLayer, actionHandler);
617 menu->addAction(actionSelectLayer);
618 connect(actionSelectLayer, SIGNAL(activated()), actionHandler, SLOT(slotSelectLayer()));
619 connect(this, SIGNAL(windowsChanged(bool)), actionSelectLayer, SLOT(setEnabled(bool)));
620 menuBar()->addMenu(menu);
624 menu = new QMenu(tr("&Draw"), this);
627 QMenu * subMenu = new QMenu(tr("&Point"), this);
628 // action = actionFactory.createAction(RS2::ActionDrawPoint, actionHandler);
629 subMenu->addAction(actionDrawPoint);
630 connect(actionDrawPoint, SIGNAL(activated()), actionHandler, SLOT(slotDrawPoint()));
631 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPoint, SLOT(setEnabled(bool)));
632 menu->addMenu(subMenu);
635 subMenu = new QMenu(tr("&Line"), this);
636 // action = actionFactory.createAction(RS2::ActionDrawLine, actionHandler);
637 subMenu->addAction(actionDrawLine);
638 connect(actionDrawLine, SIGNAL(activated()), actionHandler, SLOT(slotDrawLine()));
639 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLine, SLOT(setEnabled(bool)));
640 // action = actionFactory.createAction(RS2::ActionDrawLineAngle, actionHandler);
641 subMenu->addAction(actionDrawLineAngle);
642 connect(actionDrawLineAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineAngle()));
643 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineAngle, SLOT(setEnabled(bool)));
644 // action = actionFactory.createAction(RS2::ActionDrawLineHorizontal, actionHandler);
645 subMenu->addAction(actionDrawLineHorizontal);
646 connect(actionDrawLineHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineHorizontal()));
647 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineHorizontal, SLOT(setEnabled(bool)));
648 // action = actionFactory.createAction(RS2::ActionDrawLineVertical, actionHandler);
649 subMenu->addAction(actionDrawLineVertical);
650 connect(actionDrawLineVertical, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineVertical()));
651 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineVertical, SLOT(setEnabled(bool)));
652 // action = actionFactory.createAction(RS2::ActionDrawLineRectangle, actionHandler);
653 subMenu->addAction(actionDrawLineRectangle);
654 connect(actionDrawLineRectangle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRectangle()));
655 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRectangle, SLOT(setEnabled(bool)));
656 // action = actionFactory.createAction(RS2::ActionDrawLineParallel, actionHandler);
657 subMenu->addAction(actionDrawLineParallel);
658 connect(actionDrawLineParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallel()));
659 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallel, SLOT(setEnabled(bool)));
660 // action = actionFactory.createAction(RS2::ActionDrawLineParallelThrough, actionHandler);
661 subMenu->addAction(actionDrawLineParallelThrough);
662 connect(actionDrawLineParallelThrough, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallelThrough()));
663 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallelThrough, SLOT(setEnabled(bool)));
664 // action = actionFactory.createAction(RS2::ActionDrawLineBisector, actionHandler);
665 subMenu->addAction(actionDrawLineBisector);
666 connect(actionDrawLineBisector, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineBisector()));
667 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineBisector, SLOT(setEnabled(bool)));
668 // action = actionFactory.createAction(RS2::ActionDrawLineTangent1, actionHandler);
669 subMenu->addAction(actionDrawLineTangent1);
670 connect(actionDrawLineTangent1, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent1()));
671 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent1, SLOT(setEnabled(bool)));
672 // action = actionFactory.createAction(RS2::ActionDrawLineTangent2, actionHandler);
673 subMenu->addAction(actionDrawLineTangent2);
674 connect(actionDrawLineTangent2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent2()));
675 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent2, SLOT(setEnabled(bool)));
676 // action = actionFactory.createAction(RS2::ActionDrawLineOrthogonal, actionHandler);
677 subMenu->addAction(actionDrawLineOrthogonal);
678 connect(actionDrawLineOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineOrthogonal()));
679 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineOrthogonal, SLOT(setEnabled(bool)));
680 // action = actionFactory.createAction(RS2::ActionDrawLineRelAngle, actionHandler);
681 subMenu->addAction(actionDrawLineRelAngle);
682 connect(actionDrawLineRelAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRelAngle()));
683 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRelAngle, SLOT(setEnabled(bool)));
684 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon, actionHandler);
685 subMenu->addAction(actionDrawLinePolygon);
686 connect(actionDrawLinePolygon, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon()));
687 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon, SLOT(setEnabled(bool)));
688 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon2, actionHandler);
689 subMenu->addAction(actionDrawLinePolygon2);
690 connect(actionDrawLinePolygon2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon2()));
691 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon2, SLOT(setEnabled(bool)));
692 // action = actionFactory.createAction(RS2::ActionDrawLineFree, actionHandler);
693 subMenu->addAction(actionDrawLineFree);
694 connect(actionDrawLineFree, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineFree()));
695 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineFree, SLOT(setEnabled(bool)));
696 menu->addMenu(subMenu);
699 subMenu = new QMenu(tr("&Arc"), this);
700 subMenu->addAction(actionDrawArc);
701 connect(actionDrawArc, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc()));
702 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc, SLOT(setEnabled(bool)));
703 subMenu->addAction(actionDrawArc3P);
704 connect(actionDrawArc3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc3P()));
705 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc3P, SLOT(setEnabled(bool)));
706 subMenu->addAction(actionDrawArcParallel);
707 connect(actionDrawArcParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcParallel()));
708 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcParallel, SLOT(setEnabled(bool)));
709 subMenu->addAction(actionDrawArcTangential);
710 connect(actionDrawArcTangential, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcTangential()));
711 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcTangential, SLOT(setEnabled(bool)));
712 menu->addMenu(subMenu);
715 subMenu = new QMenu(tr("&Circle"), this);
716 // action = actionFactory.createAction(RS2::ActionDrawCircle, actionHandler);
717 subMenu->addAction(actionDrawCircle);
718 connect(actionDrawCircle, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle()));
719 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle, SLOT(setEnabled(bool)));
720 // action = actionFactory.createAction(RS2::ActionDrawCircleCR, actionHandler);
721 subMenu->addAction(actionDrawCircleCR);
722 connect(actionDrawCircleCR, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleCR()));
723 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleCR, SLOT(setEnabled(bool)));
724 // action = actionFactory.createAction(RS2::ActionDrawCircle2P, actionHandler);
725 subMenu->addAction(actionDrawCircle2P);
726 connect(actionDrawCircle2P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle2P()));
727 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle2P, SLOT(setEnabled(bool)));
728 // action = actionFactory.createAction(RS2::ActionDrawCircle3P, actionHandler);
729 subMenu->addAction(actionDrawCircle3P);
730 connect(actionDrawCircle3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle3P()));
731 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle3P, SLOT(setEnabled(bool)));
732 // action = actionFactory.createAction(RS2::ActionDrawCircleParallel, actionHandler);
733 subMenu->addAction(actionDrawCircleParallel);
734 connect(actionDrawCircleParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleParallel()));
735 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleParallel, SLOT(setEnabled(bool)));
736 menu->addMenu(subMenu);
739 subMenu = new QMenu(tr("&Ellipse"), this);
740 // action = actionFactory.createAction(RS2::ActionDrawEllipseAxis, actionHandler);
741 subMenu->addAction(actionDrawEllipseAxis);
742 connect(actionDrawEllipseAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseAxis()));
743 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseAxis, SLOT(setEnabled(bool)));
744 // action = actionFactory.createAction(RS2::ActionDrawEllipseArcAxis, actionHandler);
745 subMenu->addAction(actionDrawEllipseArcAxis);
746 connect(actionDrawEllipseArcAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseArcAxis()));
747 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseArcAxis, SLOT(setEnabled(bool)));
748 menu->addMenu(subMenu);
751 subMenu = new QMenu(tr("&Spline"), this);
752 // action = actionFactory.createAction(RS2::ActionDrawSpline, actionHandler);
753 subMenu->addAction(actionDrawSpline);
754 connect(actionDrawSpline, SIGNAL(activated()), actionHandler, SLOT(slotDrawSpline()));
755 connect(this, SIGNAL(windowsChanged(bool)), actionDrawSpline, SLOT(setEnabled(bool)));
756 menu->addMenu(subMenu);
759 subMenu = new QMenu(tr("&Polyline"), this);
760 // action = actionFactory.createAction(RS2::ActionDrawPolyline, actionHandler);
761 subMenu->addAction(actionDrawPolyline);
762 connect(actionDrawPolyline, SIGNAL(activated()), actionHandler, SLOT(slotDrawPolyline()));
763 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPolyline, SLOT(setEnabled(bool)));
764 // action = actionFactory.createAction(RS2::ActionPolylineAdd, actionHandler);
765 subMenu->addAction(actionPolylineAdd);
766 connect(actionPolylineAdd, SIGNAL(activated()), actionHandler, SLOT(slotPolylineAdd()));
767 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineAdd, SLOT(setEnabled(bool)));
768 // action = actionFactory.createAction(RS2::ActionPolylineDel, actionHandler);
769 subMenu->addAction(actionPolylineDel);
770 connect(actionPolylineDel, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDel()));
771 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDel, SLOT(setEnabled(bool)));
772 // action = actionFactory.createAction(RS2::ActionPolylineDelBetween, actionHandler);
773 subMenu->addAction(actionPolylineDelBetween);
774 connect(actionPolylineDelBetween, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDelBetween()));
775 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDelBetween, SLOT(setEnabled(bool)));
776 // action = actionFactory.createAction(RS2::ActionPolylineTrim, actionHandler);
777 subMenu->addAction(actionPolylineTrim);
778 connect(actionPolylineTrim, SIGNAL(activated()), actionHandler, SLOT(slotPolylineTrim()));
779 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineTrim, SLOT(setEnabled(bool)));
780 menu->addMenu(subMenu);
783 // action = actionFactory.createAction(RS2::ActionDrawText, actionHandler);
784 menu->addAction(actionDrawText);
785 connect(actionDrawText, SIGNAL(activated()), actionHandler, SLOT(slotDrawText()));
786 connect(this, SIGNAL(windowsChanged(bool)), actionDrawText, SLOT(setEnabled(bool)));
788 // action = actionFactory.createAction(RS2::ActionDrawHatch, actionHandler);
789 menu->addAction(actionDrawHatch);
790 connect(actionDrawHatch, SIGNAL(activated()), actionHandler, SLOT(slotDrawHatch()));
791 connect(this, SIGNAL(windowsChanged(bool)), actionDrawHatch, SLOT(setEnabled(bool)));
793 // action = actionFactory.createAction(RS2::ActionDrawImage, actionHandler);
794 menu->addAction(actionDrawImage);
795 connect(actionDrawImage, SIGNAL(activated()), actionHandler, SLOT(slotDrawImage()));
796 connect(this, SIGNAL(windowsChanged(bool)), actionDrawImage, SLOT(setEnabled(bool)));
797 // menuBar()->insertItem(tr("&Draw"), menu);
798 menuBar()->addMenu(menu);
800 // Dimensioning actions:
806 menu = new QMenu(tr("&Dimension"), this);
807 // action = actionFactory.createAction(RS2::ActionDimAligned, actionHandler);
808 menu->addAction(actionDimAligned);
809 connect(actionDimAligned, SIGNAL(activated()), actionHandler, SLOT(slotDimAligned()));
810 connect(this, SIGNAL(windowsChanged(bool)), actionDimAligned, SLOT(setEnabled(bool)));
811 // action = actionFactory.createAction(RS2::ActionDimLinear, actionHandler);
812 menu->addAction(actionDimLinear);
813 connect(actionDimLinear, SIGNAL(activated()), actionHandler, SLOT(slotDimLinear()));
814 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinear, SLOT(setEnabled(bool)));
815 // action = actionFactory.createAction(RS2::ActionDimLinearHor, actionHandler);
816 menu->addAction(actionDimLinearHor);
817 connect(actionDimLinearHor, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearHor()));
818 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearHor, SLOT(setEnabled(bool)));
819 // action = actionFactory.createAction(RS2::ActionDimLinearVer, actionHandler);
820 menu->addAction(actionDimLinearVer);
821 connect(actionDimLinearVer, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearVer()));
822 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearVer, SLOT(setEnabled(bool)));
823 // action = actionFactory.createAction(RS2::ActionDimRadial, actionHandler);
824 menu->addAction(actionDimRadial);
825 connect(actionDimRadial, SIGNAL(activated()), actionHandler, SLOT(slotDimRadial()));
826 connect(this, SIGNAL(windowsChanged(bool)), actionDimRadial, SLOT(setEnabled(bool)));
827 // action = actionFactory.createAction(RS2::ActionDimDiametric, actionHandler);
828 menu->addAction(actionDimDiametric);
829 connect(actionDimDiametric, SIGNAL(activated()), actionHandler, SLOT(slotDimDiametric()));
830 connect(this, SIGNAL(windowsChanged(bool)), actionDimDiametric, SLOT(setEnabled(bool)));
831 // action = actionFactory.createAction(RS2::ActionDimAngular, actionHandler);
832 menu->addAction(actionDimAngular);
833 connect(actionDimAngular, SIGNAL(activated()), actionHandler, SLOT(slotDimAngular()));
834 connect(this, SIGNAL(windowsChanged(bool)), actionDimAngular, SLOT(setEnabled(bool)));
835 // action = actionFactory.createAction(RS2::ActionDimLeader, actionHandler);
836 menu->addAction(actionDimLeader);
837 connect(actionDimLeader, SIGNAL(activated()), actionHandler, SLOT(slotDimLeader()));
838 connect(this, SIGNAL(windowsChanged(bool)), actionDimLeader, SLOT(setEnabled(bool)));
840 m->insertItem(tr("&Dimension"), menu);
842 menuBar()->addMenu(menu);
845 // Modifying actions:
847 menu = new QMenu(tr("&Modify"), this);
848 // action = actionFactory.createAction(RS2::ActionModifyMove, actionHandler);
849 menu->addAction(actionModifyMove);
850 connect(actionModifyMove, SIGNAL(activated()), actionHandler, SLOT(slotModifyMove()));
851 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMove, SLOT(setEnabled(bool)));
852 // action = actionFactory.createAction(RS2::ActionModifyRotate, actionHandler);
853 menu->addAction(actionModifyRotate);
854 connect(actionModifyRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate()));
855 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate, SLOT(setEnabled(bool)));
856 // action = actionFactory.createAction(RS2::ActionModifyScale, actionHandler);
857 menu->addAction(actionModifyScale);
858 connect(actionModifyScale, SIGNAL(activated()), actionHandler, SLOT(slotModifyScale()));
859 connect(this, SIGNAL(windowsChanged(bool)), actionModifyScale, SLOT(setEnabled(bool)));
860 // action = actionFactory.createAction(RS2::ActionModifyMirror, actionHandler);
861 menu->addAction(actionModifyMirror);
862 connect(actionModifyMirror, SIGNAL(activated()), actionHandler, SLOT(slotModifyMirror()));
863 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMirror, SLOT(setEnabled(bool)));
864 // action = actionFactory.createAction(RS2::ActionModifyMoveRotate, actionHandler);
865 menu->addAction(actionModifyMoveRotate);
866 connect(actionModifyMoveRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyMoveRotate()));
867 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMoveRotate, SLOT(setEnabled(bool)));
868 // action = actionFactory.createAction(RS2::ActionModifyRotate2, actionHandler);
869 menu->addAction(actionModifyRotate2);
870 connect(actionModifyRotate2, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate2()));
871 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate2, SLOT(setEnabled(bool)));
872 // action = actionFactory.createAction(RS2::ActionModifyTrim, actionHandler);
873 menu->addAction(actionModifyTrim);
874 connect(actionModifyTrim, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim()));
875 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim, SLOT(setEnabled(bool)));
876 // action = actionFactory.createAction(RS2::ActionModifyTrim2, actionHandler);
877 menu->addAction(actionModifyTrim2);
878 connect(actionModifyTrim2, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim2()));
879 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim2, SLOT(setEnabled(bool)));
880 // action = actionFactory.createAction(RS2::ActionModifyTrimAmount, actionHandler);
881 menu->addAction(actionModifyTrimAmount);
882 connect(actionModifyTrimAmount, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrimAmount()));
883 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrimAmount, SLOT(setEnabled(bool)));
884 // action = actionFactory.createAction(RS2::ActionModifyBevel, actionHandler);
885 menu->addAction(actionModifyBevel);
886 connect(actionModifyBevel, SIGNAL(activated()), actionHandler, SLOT(slotModifyBevel()));
887 connect(this, SIGNAL(windowsChanged(bool)), actionModifyBevel, SLOT(setEnabled(bool)));
888 // action = actionFactory.createAction(RS2::ActionModifyRound, actionHandler);
889 menu->addAction(actionModifyRound);
890 connect(actionModifyRound, SIGNAL(activated()), actionHandler, SLOT(slotModifyRound()));
891 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRound, SLOT(setEnabled(bool)));
892 // action = actionFactory.createAction(RS2::ActionModifyCut, actionHandler);
893 menu->addAction(actionModifyCut);
894 connect(actionModifyCut, SIGNAL(activated()), actionHandler, SLOT(slotModifyCut()));
895 connect(this, SIGNAL(windowsChanged(bool)), actionModifyCut, SLOT(setEnabled(bool)));
896 // action = actionFactory.createAction(RS2::ActionModifyStretch, actionHandler);
897 menu->addAction(actionModifyStretch);
898 connect(actionModifyStretch, SIGNAL(activated()), actionHandler, SLOT(slotModifyStretch()));
899 connect(this, SIGNAL(windowsChanged(bool)), actionModifyStretch, SLOT(setEnabled(bool)));
900 // action = actionFactory.createAction(RS2::ActionModifyEntity, actionHandler);
901 menu->addAction(actionModifyEntity);
902 connect(actionModifyEntity, SIGNAL(activated()), actionHandler, SLOT(slotModifyEntity()));
903 connect(this, SIGNAL(windowsChanged(bool)), actionModifyEntity, SLOT(setEnabled(bool)));
904 // action = actionFactory.createAction(RS2::ActionModifyAttributes, actionHandler);
905 menu->addAction(actionModifyAttributes);
906 connect(actionModifyAttributes, SIGNAL(activated()), actionHandler, SLOT(slotModifyAttributes()));
907 connect(this, SIGNAL(windowsChanged(bool)), actionModifyAttributes, SLOT(setEnabled(bool)));
908 // action = actionFactory.createAction(RS2::ActionModifyDelete, actionHandler);
909 menu->addAction(actionModifyDelete);
910 connect(actionModifyDelete, SIGNAL(activated()), actionHandler, SLOT(slotModifyDelete()));
911 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDelete, SLOT(setEnabled(bool)));
912 // action = actionFactory.createAction(RS2::ActionModifyDeleteQuick, actionHandler);
913 menu->addAction(actionModifyDeleteQuick);
914 connect(actionModifyDeleteQuick, SIGNAL(activated()), actionHandler, SLOT(slotModifyDeleteQuick()));
915 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDeleteQuick, SLOT(setEnabled(bool)));
916 // action = actionFactory.createAction(RS2::ActionModifyExplodeText, actionHandler);
917 menu->addAction(actionModifyExplodeText);
918 connect(actionModifyExplodeText, SIGNAL(activated()), actionHandler, SLOT(slotModifyExplodeText()));
919 connect(this, SIGNAL(windowsChanged(bool)), actionModifyExplodeText, SLOT(setEnabled(bool)));
920 //// action = actionFactory.createAction(RS2::ActionModifyDeleteFree, actionHandler);
921 //// menu->addAction(action);
922 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
923 menu->addAction(actionBlocksExplode);
924 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
925 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
926 menuBar()->addMenu(menu);
930 menu = new QMenu(tr("&Snap"), this);
931 // action = actionFactory.createAction(RS2::ActionSnapFree, actionHandler);
932 menu->addAction(actionSnapFree);
933 actionHandler->setActionSnapFree(actionSnapFree); // ???Why???
934 connect(actionSnapFree, SIGNAL(activated()), actionHandler, SLOT(slotSnapFree()));
935 connect(this, SIGNAL(windowsChanged(bool)), actionSnapFree, SLOT(setEnabled(bool)));
936 actionSnapFree->setChecked(true);
937 // action = actionFactory.createAction(RS2::ActionSnapGrid, actionHandler);
938 menu->addAction(actionSnapGrid);
939 actionHandler->setActionSnapGrid(actionSnapGrid); // ???Why???
940 connect(actionSnapGrid, SIGNAL(activated()), actionHandler, SLOT(slotSnapGrid()));
941 connect(this, SIGNAL(windowsChanged(bool)), actionSnapGrid, SLOT(setEnabled(bool)));
942 // action = actionFactory.createAction(RS2::ActionSnapEndpoint, actionHandler);
943 menu->addAction(actionSnapEndpoint);
944 actionHandler->setActionSnapEndpoint(actionSnapEndpoint); // ???Why???
945 connect(actionSnapEndpoint, SIGNAL(activated()), actionHandler, SLOT(slotSnapEndpoint()));
946 connect(this, SIGNAL(windowsChanged(bool)), actionSnapEndpoint, SLOT(setEnabled(bool)));
947 // action = actionFactory.createAction(RS2::ActionSnapOnEntity, actionHandler);
948 menu->addAction(actionSnapOnEntity);
949 actionHandler->setActionSnapOnEntity(actionSnapOnEntity); // ???Why???
950 connect(actionSnapOnEntity, SIGNAL(activated()), actionHandler, SLOT(slotSnapOnEntity()));
951 connect(this, SIGNAL(windowsChanged(bool)), actionSnapOnEntity, SLOT(setEnabled(bool)));
952 // action = actionFactory.createAction(RS2::ActionSnapCenter, actionHandler);
953 menu->addAction(actionSnapCenter);
954 actionHandler->setActionSnapCenter(actionSnapCenter); // ???Why???
955 connect(actionSnapCenter, SIGNAL(activated()), actionHandler, SLOT(slotSnapCenter()));
956 connect(this, SIGNAL(windowsChanged(bool)), actionSnapCenter, SLOT(setEnabled(bool)));
957 // action = actionFactory.createAction(RS2::ActionSnapMiddle, actionHandler);
958 menu->addAction(actionSnapMiddle);
959 actionHandler->setActionSnapMiddle(actionSnapMiddle); // ???Why???
960 connect(actionSnapMiddle, SIGNAL(activated()), actionHandler, SLOT(slotSnapMiddle()));
961 connect(this, SIGNAL(windowsChanged(bool)), actionSnapMiddle, SLOT(setEnabled(bool)));
962 // action = actionFactory.createAction(RS2::ActionSnapDist, actionHandler);
963 menu->addAction(actionSnapDist);
964 actionHandler->setActionSnapDist(actionSnapDist); // ???Why???
965 connect(actionSnapDist, SIGNAL(activated()), actionHandler, SLOT(slotSnapDist()));
966 connect(this, SIGNAL(windowsChanged(bool)), actionSnapDist, SLOT(setEnabled(bool)));
967 // action = actionFactory.createAction(RS2::ActionSnapIntersection, actionHandler);
968 menu->addAction(actionSnapIntersection);
969 actionHandler->setActionSnapIntersection(actionSnapIntersection); // ???Why???
970 connect(actionSnapIntersection, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersection()));
971 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersection, SLOT(setEnabled(bool)));
972 // action = actionFactory.createAction(RS2::ActionSnapIntersectionManual, actionHandler);
973 menu->addAction(actionSnapIntersectionManual);
974 actionHandler->setActionSnapIntersectionManual(actionSnapIntersectionManual); // ???Why???
975 connect(actionSnapIntersectionManual, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersectionManual()));
976 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersectionManual, SLOT(setEnabled(bool)));
978 menu->addSeparator();
980 // action = actionFactory.createAction(RS2::ActionRestrictNothing, actionHandler);
981 menu->addAction(actionRestrictNothing);
982 actionHandler->setActionRestrictNothing(actionRestrictNothing); // ???WHY???
983 connect(actionRestrictNothing, SIGNAL(activated()), actionHandler, SLOT(slotRestrictNothing()));
984 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictNothing, SLOT(setEnabled(bool)));
985 actionRestrictNothing->setChecked(true);
986 // action = actionFactory.createAction(RS2::ActionRestrictOrthogonal, actionHandler);
987 menu->addAction(actionRestrictOrthogonal);
988 actionHandler->setActionRestrictOrthogonal(actionRestrictOrthogonal); // ???WHY???
989 connect(actionRestrictOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictOrthogonal()));
990 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictOrthogonal, SLOT(setEnabled(bool)));
991 // action = actionFactory.createAction(RS2::ActionRestrictHorizontal, actionHandler);
992 menu->addAction(actionRestrictHorizontal);
993 actionHandler->setActionRestrictHorizontal(actionRestrictHorizontal); // ???WHY???
994 connect(actionRestrictHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictHorizontal()));
995 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictHorizontal, SLOT(setEnabled(bool)));
996 // action = actionFactory.createAction(RS2::ActionRestrictVertical, actionHandler);
997 menu->addAction(actionRestrictVertical);
998 actionHandler->setActionRestrictVertical(actionRestrictVertical); // ???WHY???
999 connect(actionRestrictVertical, SIGNAL(activated()), actionHandler, SLOT(slotRestrictVertical()));
1000 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictVertical, SLOT(setEnabled(bool)));
1002 menu->addSeparator();
1004 // action = actionFactory.createAction(RS2::ActionSetRelativeZero, actionHandler);
1005 menu->addAction(actionSetRelativeZero);
1006 connect(actionSetRelativeZero, SIGNAL(activated()), actionHandler, SLOT(slotSetRelativeZero()));
1007 connect(this, SIGNAL(windowsChanged(bool)), actionSetRelativeZero, SLOT(setEnabled(bool)));
1008 // action = actionFactory.createAction(RS2::ActionLockRelativeZero, actionHandler);
1009 menu->addAction(actionLockRelativeZero);
1010 actionHandler->setActionLockRelativeZero(actionLockRelativeZero);
1011 connect(actionLockRelativeZero, SIGNAL(toggled(bool)), actionHandler, SLOT(slotLockRelativeZero(bool))); // ???WHY???
1012 connect(this, SIGNAL(windowsChanged(bool)), actionLockRelativeZero, SLOT(setEnabled(bool)));
1013 menuBar()->addMenu(menu);
1018 menu = new QMenu(tr("&Info"), this);
1019 //action = actionFactory.createAction(RS2::ActionInfoInside, actionHandler);
1020 //menu->addAction(action);
1021 menu->addAction(actionInfoDist);
1022 connect(actionInfoDist, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist()));
1023 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist, SLOT(setEnabled(bool)));
1024 menu->addAction(actionInfoDist2);
1025 connect(actionInfoDist2, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist2()));
1026 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist2, SLOT(setEnabled(bool)));
1027 menu->addAction(actionInfoAngle);
1028 connect(actionInfoAngle, SIGNAL(activated()), actionHandler, SLOT(slotInfoAngle()));
1029 connect(this, SIGNAL(windowsChanged(bool)), actionInfoAngle, SLOT(setEnabled(bool)));
1030 menu->addAction(actionInfoTotalLength);
1031 connect(actionInfoTotalLength, SIGNAL(activated()), actionHandler, SLOT(slotInfoTotalLength()));
1032 connect(this, SIGNAL(windowsChanged(bool)), actionInfoTotalLength, SLOT(setEnabled(bool)));
1033 menu->addAction(actionInfoArea);
1034 connect(actionInfoArea, SIGNAL(activated()), actionHandler, SLOT(slotInfoArea()));
1035 connect(this, SIGNAL(windowsChanged(bool)), actionInfoArea, SLOT(setEnabled(bool)));
1036 menuBar()->addMenu(menu);
1041 menu = new QMenu(tr("&Layer"), this);
1042 // action = actionFactory.createAction(RS2::ActionLayersDefreezeAll, actionHandler);
1043 menu->addAction(actionLayersDefreezeAll);
1044 connect(actionLayersDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersDefreezeAll()));
1045 connect(this, SIGNAL(windowsChanged(bool)), actionLayersDefreezeAll, SLOT(setEnabled(bool)));
1046 // action = actionFactory.createAction(RS2::ActionLayersFreezeAll, actionHandler);
1047 menu->addAction(actionLayersFreezeAll);
1048 connect(actionLayersFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersFreezeAll()));
1049 connect(this, SIGNAL(windowsChanged(bool)), actionLayersFreezeAll, SLOT(setEnabled(bool)));
1050 // action = actionFactory.createAction(RS2::ActionLayersAdd, actionHandler);
1051 menu->addAction(actionLayersAdd);
1052 connect(actionLayersAdd, SIGNAL(activated()), actionHandler, SLOT(slotLayersAdd()));
1053 connect(this, SIGNAL(windowsChanged(bool)), actionLayersAdd, SLOT(setEnabled(bool)));
1054 // action = actionFactory.createAction(RS2::ActionLayersRemove, actionHandler);
1055 menu->addAction(actionLayersRemove);
1056 connect(actionLayersRemove, SIGNAL(activated()), actionHandler, SLOT(slotLayersRemove()));
1057 connect(this, SIGNAL(windowsChanged(bool)), actionLayersRemove, SLOT(setEnabled(bool)));
1058 // action = actionFactory.createAction(RS2::ActionLayersEdit, actionHandler);
1059 menu->addAction(actionLayersEdit);
1060 connect(actionLayersEdit, SIGNAL(activated()), actionHandler, SLOT(slotLayersEdit()));
1061 connect(this, SIGNAL(windowsChanged(bool)), actionLayersEdit, SLOT(setEnabled(bool)));
1062 // action = actionFactory.createAction(RS2::ActionLayersToggleView, actionHandler);
1063 menu->addAction(actionLayersToggleView);
1064 connect(actionLayersToggleView, SIGNAL(activated()), actionHandler, SLOT(slotLayersToggleView()));
1065 connect(this, SIGNAL(windowsChanged(bool)), actionLayersToggleView, SLOT(setEnabled(bool)));
1066 menuBar()->addMenu(menu);
1070 menu = new QMenu(tr("&Block"), this);
1071 // action = actionFactory.createAction(RS2::ActionBlocksDefreezeAll, actionHandler);
1072 menu->addAction(actionBlocksDefreezeAll);
1073 connect(actionBlocksDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksDefreezeAll()));
1074 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksDefreezeAll, SLOT(setEnabled(bool)));
1075 // action = actionFactory.createAction(RS2::ActionBlocksFreezeAll, actionHandler);
1076 menu->addAction(actionBlocksFreezeAll);
1077 connect(actionBlocksFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksFreezeAll()));
1078 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksFreezeAll, SLOT(setEnabled(bool)));
1079 // action = actionFactory.createAction(RS2::ActionBlocksAdd, actionHandler);
1080 menu->addAction(actionBlocksAdd);
1081 connect(actionBlocksAdd, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAdd()));
1082 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAdd, SLOT(setEnabled(bool)));
1083 // action = actionFactory.createAction(RS2::ActionBlocksRemove, actionHandler);
1084 menu->addAction(actionBlocksRemove);
1085 connect(actionBlocksRemove, SIGNAL(activated()), actionHandler, SLOT(slotBlocksRemove()));
1086 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksRemove, SLOT(setEnabled(bool)));
1087 // action = actionFactory.createAction(RS2::ActionBlocksAttributes, actionHandler);
1088 menu->addAction(actionBlocksAttributes);
1089 connect(actionBlocksAttributes, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAttributes()));
1090 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAttributes, SLOT(setEnabled(bool)));
1091 // action = actionFactory.createAction(RS2::ActionBlocksInsert, actionHandler);
1092 menu->addAction(actionBlocksInsert);
1093 connect(actionBlocksInsert, SIGNAL(activated()), actionHandler, SLOT(slotBlocksInsert()));
1094 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksInsert, SLOT(setEnabled(bool)));
1095 // action = actionFactory.createAction(RS2::ActionBlocksEdit, actionHandler);
1096 menu->addAction(actionBlocksEdit);
1097 connect(actionBlocksEdit, SIGNAL(activated()), actionHandler, SLOT(slotBlocksEdit()));
1098 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksEdit, SLOT(setEnabled(bool)));
1099 // action = actionFactory.createAction(RS2::ActionBlocksCreate, actionHandler);
1100 menu->addAction(actionBlocksCreate);
1101 connect(actionBlocksCreate, SIGNAL(activated()), actionHandler, SLOT(slotBlocksCreate()));
1102 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksCreate, SLOT(setEnabled(bool)));
1103 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
1104 menu->addAction(actionBlocksExplode);
1105 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
1106 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
1107 menuBar()->addMenu(menu);
1109 //will *this* make a toolbar break for us???
1110 addToolBarBreak(Qt::TopToolBarArea);
1111 // addDockWindow(penToolBar, tr("Pen"), Qt::DockTop);
1112 // addDockWindow(optionWidget, tr("Tool Options"), Qt::DockTop, true);
1113 addToolBar(Qt::TopToolBarArea, (QToolBar *)penToolBar); // hmm.
1114 addToolBar(Qt::TopToolBarArea, optionWidget);
1119 scriptMenu = new QMenu(this);
1120 scriptOpenIDE = actionFactory.createAction(RS2::ActionScriptOpenIDE, this);
1121 scriptOpenIDE->addTo(scriptMenu);
1122 scriptRun = actionFactory.createAction(RS2::ActionScriptRun, this);
1123 scriptRun->addTo(scriptMenu);
1126 scriptOpenIDE = NULL;
1132 menu = new QMenu(tr("&CAM"), this);
1133 action = actionFactory.createAction(RS2::ActionCamExportAuto, actionHandler);
1134 menu->addAction(action);
1135 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1136 action = actionFactory.createAction(RS2::ActionCamReorder, actionHandler);
1137 menu->addAction(action);
1138 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1139 menuBar()->addMenu(menu);
1144 helpAboutApp = new QAction(QIcon(QC_APP_ICON16), tr("&About Architektonas"), this);
1145 // helpAboutApp = new QAction(tr("About"), qPixmapFromMimeSource(QC_APP_ICON16), tr("&About %1").arg(QC_APPNAME), 0, this);
1146 helpAboutApp->setStatusTip(tr("About the application"));
1147 //helpAboutApp->setWhatsThis(tr("About\n\nAbout the application"));
1148 connect(helpAboutApp, SIGNAL(activated()), this, SLOT(slotHelpAbout()));
1150 helpManual = new QAction(QIcon(":/res/contents.png"), tr("&Manual"), this);
1151 helpManual->setShortcut(Qt::Key_F1);
1152 // helpManual = new QAction(qPixmapFromMimeSource("contents.png"), tr("&Manual"), Qt::Key_F1, this);
1153 helpManual->setStatusTip(tr("Launch the online manual"));
1154 connect(helpManual, SIGNAL(activated()), this, SLOT(slotHelpManual()));
1156 testDumpEntities = new QAction("Dump &Entities", this);
1157 // testDumpEntities = new QAction("Dump Entities", "Dump &Entities", 0, this);
1158 connect(testDumpEntities, SIGNAL(activated()), this, SLOT(slotTestDumpEntities()));
1160 testDumpUndo = new QAction("Undo Info", this);
1161 // testDumpUndo = new QAction("Dump Undo Info", "Undo Info", 0, this);
1162 connect(testDumpUndo, SIGNAL(activated()), this, SLOT(slotTestDumpUndo()));
1164 testUpdateInserts = new QAction("&Update Inserts", this);
1165 // testUpdateInserts = new QAction("Update Inserts", "&Update Inserts", 0, this);
1166 connect(testUpdateInserts, SIGNAL(activated()), this, SLOT(slotTestUpdateInserts()));
1168 testDrawFreehand = new QAction("Draw Freehand", this);
1169 // testDrawFreehand = new QAction("Draw Freehand", "Draw Freehand", 0, this);
1170 connect(testDrawFreehand, SIGNAL(activated()), this, SLOT(slotTestDrawFreehand()));
1172 testInsertBlock = new QAction("Insert Block", this);
1173 // testInsertBlock = new QAction("Insert Block", "Insert Block", 0, this);
1174 connect(testInsertBlock, SIGNAL(activated()), this, SLOT(slotTestInsertBlock()));
1176 testInsertText = new QAction("Insert Text", this);
1177 // testInsertText = new QAction("Insert Text", "Insert Text", 0, this);
1178 connect(testInsertText, SIGNAL(activated()), this, SLOT(slotTestInsertText()));
1180 testInsertImage = new QAction("Insert Image", this);
1181 // testInsertImage = new QAction("Insert Image", "Insert Image", 0, this);
1182 connect(testInsertImage, SIGNAL(activated()), this, SLOT(slotTestInsertImage()));
1184 testUnicode = new QAction("Unicode", this);
1185 // testUnicode = new QAction("Unicode", "Unicode", 0, this);
1186 connect(testUnicode, SIGNAL(activated()), this, SLOT(slotTestUnicode()));
1188 testInsertEllipse = new QAction("Insert Ellipse", this);
1189 // testInsertEllipse = new QAction("Insert Ellipse", "Insert Ellipse", 0, this);
1190 connect(testInsertEllipse, SIGNAL(activated()), this, SLOT(slotTestInsertEllipse()));
1192 testMath01 = new QAction("Math01", this);
1193 // testMath01 = new QAction("Math01", "Math01", 0, this);
1194 connect(testMath01, SIGNAL(activated()), this, SLOT(slotTestMath01()));
1196 testResize640 = new QAction("Resize 1", this);
1197 // testResize640 = new QAction("Resize to 640x480", "Resize 1", 0, this);
1198 connect(testResize640, SIGNAL(activated()), this, SLOT(slotTestResize640()));
1200 testResize800 = new QAction("Resize 2", this);
1201 // testResize800 = new QAction("Resize to 800x600", "Resize 2", 0, this);
1202 connect(testResize800, SIGNAL(activated()), this, SLOT(slotTestResize800()));
1204 testResize1024 = new QAction("Resize 3", this);
1205 // testResize1024 = new QAction("Resize to 1024x768", "Resize 3", 0, this);
1206 connect(testResize1024, SIGNAL(activated()), this, SLOT(slotTestResize1024()));
1210 * Initializes the menu bar.
1212 void ApplicationWindow::initMenuBar()
1214 RS_DEBUG->print("ApplicationWindow::initMenuBar()");
1216 // menuBar entry windowsMenu
1217 windowsMenu = new QMenu(tr("&Window"), this);
1218 //according to docs, this is obsolete: windowsMenu->setCheckable(true);
1219 connect(windowsMenu, SIGNAL(aboutToShow()), this, SLOT(slotWindowsMenuAboutToShow()));
1221 // menuBar entry scriptMenu
1222 //scriptMenu = new QPopupMenu(this);
1223 //scriptMenu->setCheckable(true);
1224 //scriptOpenIDE->addTo(scriptMenu);
1225 //scriptRun->addTo(scriptMenu);
1226 //connect(scriptMenu, SIGNAL(aboutToShow()), this, SLOT(slotScriptMenuAboutToShow()));
1228 // menuBar entry helpMenu
1229 helpMenu = new QMenu(tr("&Help"), this);
1230 helpMenu->addAction(helpManual);//helpManual->addTo(helpMenu);
1232 // helpMenu->insertSeparator(helpManual);
1233 helpMenu->addSeparator();
1235 helpMenu->addAction(helpAboutApp);//helpAboutApp->addTo(helpMenu);
1237 // menuBar entry test menu
1238 testMenu = new QMenu(tr("De&bugging"), this);
1239 testMenu->addAction(testDumpEntities);//testDumpEntities->addTo(testMenu);
1240 testMenu->addAction(testDumpUndo);//testDumpUndo->addTo(testMenu);
1241 testMenu->addAction(testUpdateInserts);//testUpdateInserts->addTo(testMenu);
1242 testMenu->addAction(testDrawFreehand);//testDrawFreehand->addTo(testMenu);
1243 testMenu->addAction(testInsertBlock);//testInsertBlock->addTo(testMenu);
1244 testMenu->addAction(testInsertText);//testInsertText->addTo(testMenu);
1245 testMenu->addAction(testInsertImage);//testInsertImage->addTo(testMenu);
1246 testMenu->addAction(testInsertEllipse);//testInsertEllipse->addTo(testMenu);
1247 testMenu->addAction(testUnicode);//testUnicode->addTo(testMenu);
1248 testMenu->addAction(testMath01);//testMath01->addTo(testMenu);
1249 testMenu->addAction(testResize640);//testResize640->addTo(testMenu);
1250 testMenu->addAction(testResize800);//testResize800->addTo(testMenu);
1251 testMenu->addAction(testResize1024);//testResize1024->addTo(testMenu);
1253 // menuBar configuration
1255 // menuBar()->insertItem(tr("&Scripts"), scriptMenu);
1256 menuBar()->addMenu(scriptMenu);
1258 // menuBar()->insertItem(tr("&Window"), windowsMenu);
1259 menuBar()->addMenu(windowsMenu);
1261 // menuBar()->insertSeparator();
1262 // menuBar()->insertItem(tr("&Help"), helpMenu);
1263 menuBar()->addMenu(helpMenu);
1266 // menuBar()->insertItem(tr("De&bugging"), testMenu);
1267 menuBar()->addMenu(testMenu);
1269 recentFiles = new RecentFiles(this, fileMenu);
1273 * Initializes the tool bars (file tool bar and pen tool bar).
1275 void ApplicationWindow::initToolBar()
1277 RS_DEBUG->print("ApplicationWindow::initToolBar()");
1279 // fileToolBar = new Q3ToolBar(this, "File Operations");
1280 fileToolBar = addToolBar(tr("File Operations"));
1281 fileToolBar->setObjectName("file");
1282 // editToolBar = new Q3ToolBar(this, "Edit Operations");
1283 editToolBar = addToolBar(tr("Edit Operations"));
1284 editToolBar->setObjectName("edit");
1285 // zoomToolBar = new Q3ToolBar(this, "Zoom Operations");
1286 zoomToolBar = addToolBar(tr("Zoom Operations"));
1287 zoomToolBar->setObjectName("zoom");
1288 penToolBar = new PenToolBar(this, "Pen Selection");
1289 penToolBar->setObjectName("pen");
1291 connect(penToolBar, SIGNAL(penChanged(RS_Pen)), this, SLOT(slotPenChanged(RS_Pen)));
1293 // optionWidget = new Q3ToolBar(this, "Tool Options");
1294 //addToolBarBreak() does nothing...
1295 #warning "!!! add/insertToolBarBreak() does nothing !!!"
1296 // addToolBarBreak(Qt::TopToolBarArea);
1297 optionWidget = addToolBar(tr("Tool Options"));
1298 optionWidget->setObjectName("tooloptions");
1299 optionWidget->setMinimumHeight(26);
1300 optionWidget->setMaximumHeight(26);
1301 #warning "!!! No analogue found for setHorizontallyStretchable yet !!!"
1302 //Maybe sizePolicy or somesuch??
1303 optionWidget->setMinimumWidth(150);
1304 optionWidget->setMaximumWidth(800);
1305 #warning "Following line commented out..."
1306 // optionWidget->setFixedExtentHeight(26);
1307 // optionWidget->setHorizontallyStretchable(true);
1308 // addDockWindow(optionWidget, DockTop, true);
1310 // CAD toolbar left:
1311 // Q3ToolBar * t = new Q3ToolBar(this, "CAD Tools");
1312 QToolBar * t = addToolBar(tr("CAD Tools"));
1313 t->setObjectName("cadtools");
1314 #warning "Following two lines commented out..."
1315 // t->setFixedExtentWidth(59);
1316 t->setMinimumWidth(59);
1317 t->setMaximumWidth(59);
1318 // t->setVerticallyStretchable(true);
1319 // addDockWindow(t, Qt::DockLeft, false);
1320 addToolBar(Qt::LeftToolBarArea, t);
1322 cadToolBar = new CadToolBar(t);//, "CAD Tools");
1323 cadToolBar->createSubToolBars(actionHandler);
1325 connect(cadToolBar, SIGNAL(signalBack()), this, SLOT(slotBack()));
1326 connect(this, SIGNAL(windowsChanged(bool)), cadToolBar, SLOT(setEnabled(bool)));
1328 // QG_CadToolBarMain * cadToolBarMain = new QG_CadToolBarMain(cadToolBar);
1329 //No, no break inserted here either...
1330 // insertToolBarBreak(optionWidget);
1334 * Initializes the status bar at the bottom.
1336 void ApplicationWindow::initStatusBar()
1338 RS_DEBUG->print("ApplicationWindow::initStatusBar()");
1340 statusBar()->setMinimumHeight(32);
1341 coordinateWidget = new CoordinateWidget(statusBar());//, "coordinates");
1342 statusBar()->addWidget(coordinateWidget);
1343 mouseWidget = new MouseWidget(statusBar());//, "mouse info");
1344 statusBar()->addWidget(mouseWidget);
1345 selectionWidget = new SelectionWidget(statusBar());//, "selections");
1346 statusBar()->addWidget(selectionWidget);
1350 * Initializes the global application settings from the
1351 * config file (unix, mac) or registry (windows).
1353 void ApplicationWindow::initSettings()
1355 RS_DEBUG->print("ApplicationWindow::initSettings()");
1356 settings.beginGroup("RecentFiles");
1358 for(int i=0; i<recentFiles->Maximum(); ++i)
1360 QString filename = settings.value(QString("File") + QString::number(i + 1)).toString();
1362 if (!filename.isEmpty())
1363 // recentFiles->add(filename);
1364 recentFiles->add(filename);
1367 settings.endGroup();
1369 if (recentFiles->count() > 0)
1370 // updateRecentFilesMenu();
1371 recentFiles->UpdateGUI();
1373 settings.beginGroup("Geometry");
1374 QSize windowSize = settings.value("WindowSize", QSize(950, 700)).toSize();
1375 QPoint windowPos = settings.value("WindowPos", QPoint(0, 30)).toPoint();
1376 restoreState(settings.value("DockWindows").toByteArray());
1377 settings.endGroup();
1380 // if (windowY < 30)
1382 if (windowSize.y() < 30)
1383 windowSize.y() = 30;
1391 * Stores the global application settings to file or registry.
1393 void ApplicationWindow::storeSettings()
1395 RS_DEBUG->print("ApplicationWindow::storeSettings()");
1397 settings.beginGroup("RecentFiles");
1399 for(int i=0; i<recentFiles->count(); ++i)
1400 settings.setValue(QString("File") + QString::number(i + 1), recentFiles->get(i));
1402 settings.endGroup();
1404 settings.beginGroup("Geometry");
1405 settings.setValue("WindowSize", size());
1406 settings.setValue("WindowPos", pos());
1407 settings.setValue("DockWindows", saveState());
1408 settings.endGroup();
1410 RS_DEBUG->print("ApplicationWindow::storeSettings(): OK");
1414 * Initializes the view.
1416 void ApplicationWindow::initView()
1418 RS_DEBUG->print("ApplicationWindow::initView()");
1420 RS_DEBUG->print("init view..");
1424 libraryWidget = NULL;
1425 commandWidget = NULL;
1427 simulationControls = NULL;
1431 RS_DEBUG->print(" simulation widget..");
1432 dw = new QDockWidget(QDockWidget::InDock, this, "Simulation");
1433 simulationControls = new RS_SimulationControls(dw, "Simulation");
1434 simulationControls->setFocusPolicy(Qt::NoFocus);
1435 connect(simulationControls, SIGNAL(escape()), this, SLOT(slotFocus()));
1436 connect(this, SIGNAL(windowsChanged(bool)), simulationControls, SLOT(setEnabled(bool)));
1437 dw->setWidget(simulationControls);
1438 dw->resize(240, 80);
1439 dw->setResizeEnabled(true);
1440 dw->setFixedExtentWidth(120);
1441 dw->setFixedHeight(80);
1442 dw->setCaption(tr("Simulation Controls"));
1443 dw->setCloseMode(Q3DockWindow::Always);
1444 addDockWindow(dw, Qt::DockRight);
1445 simulationDockWindow = dw;
1446 //simulationDockWindow->hide();
1449 RS_DEBUG->print(" layer widget..");
1450 // dw = new QDockWidget(QDockWidget::InDock, this, "Layer");
1451 dw = new QDockWidget(tr("Layer List"), this);
1452 dw->setObjectName("layer");
1453 layerWidget = new LayerWidget(actionHandler, dw, "Layer");
1454 layerWidget->setFocusPolicy(Qt::NoFocus);
1455 connect(layerWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1456 connect(this, SIGNAL(windowsChanged(bool)), layerWidget, SLOT(setEnabled(bool)));
1457 dw->setWidget(layerWidget);
1458 #warning "following four lines commented out..."
1459 // dw->setFixedExtentWidth(120);
1460 // dw->setResizeEnabled(true);
1461 // dw->setCloseMode(Q3DockWindow::Always);
1462 // dw->setCaption(tr("Layer List"));
1463 addDockWidget(Qt::RightDockWidgetArea, dw);
1464 layerDockWindow = dw;
1466 RS_DEBUG->print(" block widget..");
1467 // dw = new QDockWidget(QDockWidget::InDock, this, "Block");
1468 dw = new QDockWidget(tr("Block List"), this);
1469 dw->setObjectName("block");
1470 blockWidget = new BlockWidget(actionHandler, dw, "Block");
1471 blockWidget->setFocusPolicy(Qt::NoFocus);
1472 connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1473 connect(this, SIGNAL(windowsChanged(bool)), blockWidget, SLOT(setEnabled(bool)));
1474 dw->setWidget(blockWidget);
1475 #warning "following four lines commented out..."
1476 // dw->setFixedExtentWidth(120);
1477 // dw->setResizeEnabled(true);
1478 // dw->setCloseMode(Q3DockWindow::Always);
1479 // dw->setCaption(tr("Block List"));
1480 addDockWidget(Qt::RightDockWidgetArea, dw);
1481 blockDockWindow = dw;
1483 RS_DEBUG->print(" library widget..");
1484 // dw = new QDockWidget(QDockWidget::OutsideDock, this, "Library");
1485 dw = new QDockWidget(tr("Library Browser"), this);
1486 dw->setObjectName("library");
1487 libraryWidget = new LibraryWidget(dw);//WAS:, "Library");
1488 libraryWidget->setActionHandler(actionHandler);
1489 libraryWidget->setFocusPolicy(Qt::NoFocus);
1490 connect(libraryWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1492 // connect(this, SIGNAL(windowsChanged(bool)), (QObject *)libraryWidget->bInsert, SLOT(setEnabled(bool)));
1493 dw->setWidget(libraryWidget);
1494 dw->resize(240, 400);
1495 #warning "following three lines commented out..."
1496 // dw->setResizeEnabled(true);
1497 // dw->setCloseMode(Q3DockWindow::Always);
1498 // dw->setCaption(tr("Library Browser"));
1499 //not sure how to fix this one
1500 #warning "QMainWindow::addDockWidget: invalid 'area' argument"
1501 // addDockWidget(Qt::NoDockWidgetArea, dw);
1502 //This works, but sux
1503 addDockWidget(Qt::RightDockWidgetArea, dw);
1504 libraryDockWindow = dw;
1505 // libraryDockWindow->hide();
1507 RS_DEBUG->print(" command widget..");
1508 // dw = new QDockWidget(QDockWidget::InDock, this, "Command");
1509 dw = new QDockWidget(tr("Command line"), this);
1510 dw->setObjectName("command");
1511 commandWidget = new CommandWidget(dw);//WAS:, "Command");
1512 commandWidget->setActionHandler(actionHandler);
1513 // commandWidget->redirectStderr();
1514 // std::cerr << "Ready.\n";
1515 // commandWidget->processStderr();
1516 connect(this, SIGNAL(windowsChanged(bool)), commandWidget, SLOT(setEnabled(bool)));
1517 dw->setWidget(commandWidget);
1518 #warning "following four lines commented out..."
1519 // dw->setFixedExtentHeight(45);
1520 // dw->setResizeEnabled(true);
1521 // dw->setCloseMode(QDockWidget::Always);
1522 // dw->setCaption(tr("Command line"));
1523 commandDockWindow = dw;
1524 addDockWidget(Qt::BottomDockWidgetArea, dw);
1526 RS_DEBUG->print(" done");
1530 * Creates a new toolbar.
1531 * Implementation from QG_MainWindowInterface.
1532 * Can be called from scripts to add individual GUI elements.
1534 /*QToolBar* ApplicationWindow::createToolBar(const QString& name) {
1535 QToolBar* tb = new QToolBar(this, name);
1541 * Creates a new button in the given tool bar for running a script.
1543 /*void ApplicationWindow::addToolBarButton(QToolBar* tb) {
1545 QAction* action = new QAction("Blah",
1546 QPixmap::fromMimeSource("zoomwindow.png"),
1547 "&Blah", QKeySequence(), NULL);
1548 action->setStatusTip("Blah blah");
1554 * Goes back to the previous menu or one step in the current action.
1556 void ApplicationWindow::slotBack()
1558 GraphicView * graphicView = getGraphicView();
1561 graphicView->back();
1565 cadToolBar->showToolBar(RS2::ToolBarMain);
1570 * Goes one step further in the current action.
1572 void ApplicationWindow::slotEnter()
1574 if (!commandWidget || !commandWidget->checkFocus())
1577 cadToolBar->forceNext();
1580 GraphicView * graphicView = getGraphicView();
1583 graphicView->enter();
1589 * Sets the keyboard focus on the command line.
1591 void ApplicationWindow::slotFocusCommandLine()
1593 if (commandWidget->isVisible())
1594 commandWidget->setFocus();
1598 * Shows the given error on the command line.
1600 void ApplicationWindow::slotError(const QString & msg)
1602 commandWidget->appendHistory(msg);
1606 * Hands focus back to the application window. In the rare event
1607 * of a escape press from the layer widget (e.g after switching desktops
1610 void ApplicationWindow::slotFocus()
1612 //QG_GraphicView* graphicView = getGraphicView();
1613 /*if (graphicView!=NULL) {
1614 graphicView->setFocus();
1622 * Called when a document window was activated.
1624 void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/)
1626 RS_DEBUG->print("ApplicationWindow::slotWindowActivated begin");
1628 //the following does: return (MDIWindow *)workspace->activeSubWindow();
1629 //which means the subwindow is NOT being activated!!!
1630 MDIWindow * m = getMDIWindow();
1631 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m=%08X", m);
1634 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m->getDoc=%08X", m->getDocument());
1636 if (m && m->getDocument())
1638 //m->setWindowState(WindowMaximized);
1640 RS_DEBUG->print("ApplicationWindow::slotWindowActivated: document: %d", m->getDocument()->getId());
1642 bool showByBlock = m->getDocument()->rtti() == RS2::EntityBlock;
1643 layerWidget->setLayerList(m->getDocument()->getLayerList(), showByBlock);
1644 coordinateWidget->setGraphic(m->getGraphic());
1647 simulationControls->setGraphicView(m->getGraphicView());
1650 // Only graphics show blocks. (blocks don't)
1651 if (m->getDocument()->rtti() == RS2::EntityGraphic)
1652 blockWidget->setBlockList(m->getDocument()->getBlockList());
1654 blockWidget->setBlockList(NULL);
1656 // Update all inserts in this graphic (blocks might have changed):
1657 m->getDocument()->updateInserts();
1658 m->getGraphicView()->redraw();
1660 // set snapmode from snapping menu
1661 actionHandler->updateSnapMode();
1663 // set pen from pen toolbar
1664 slotPenChanged(penToolBar->getPen());
1666 // update toggle button status:
1667 if (m->getGraphic())
1669 emit(gridChanged(m->getGraphic()->isGridOn()));
1670 emit(printPreviewChanged(m->getGraphicView()->isPrintPreview()));
1674 //Seems to work now.
1675 //#warning "This is failing... !!! FIX !!!"
1676 // Disable/Enable menu and toolbar items
1677 emit windowsChanged(m != NULL && m->getDocument() != NULL);
1679 RS_DEBUG->print("ApplicationWindow::slotWindowActivated end");
1683 * Called when the menu 'windows' is about to be shown.
1684 * This is used to update the window list in the menu.
1686 void ApplicationWindow::slotWindowsMenuAboutToShow()
1688 RS_DEBUG->print("ApplicationWindow::slotWindowsMenuAboutToShow");
1690 windowsMenu->clear();
1692 int cascadeId = windowsMenu->insertItem(tr("&Cascade"), workspace, SLOT(cascade()));
1693 int tileId = windowsMenu->insertItem(tr("&Tile"), this, SLOT(slotTileVertical()));
1694 int horTileId = windowsMenu->insertItem(tr("Tile &Horizontally"), this, SLOT(slotTileHorizontal()));
1696 if (workspace->subWindowList().isEmpty())
1698 windowsMenu->setItemEnabled(cascadeId, false);
1699 windowsMenu->setItemEnabled(tileId, false);
1700 windowsMenu->setItemEnabled(horTileId, false);
1703 windowsMenu->insertSeparator();
1705 #warning "!!! Qt4 implementation of insertItem is vastly different from Qt3--FIX !!!"
1707 QList<QMdiSubWindow *> windows = workspace->subWindowList();
1709 //#warning "Need to add window numbers underlined so can access windows via keyboard. !!! FIX !!!"
1711 for(int i=0; i<int(windows.count()); ++i)
1713 // int id = windowsMenu->insertItem(windows.at(i)->caption(), this, SLOT(slotWindowsMenuActivated(int)));
1714 //For some reason the triggered() signal created here is type bool... Dunno why...
1715 //It's signalling using the QAction signal, which is type bool (checked or not).
1717 QString actionName = QString("&%1 %2").arg(i + 1).arg(windows.at(i)->windowTitle());
1718 // QAction * action = new QAction(windows.at(i)->windowTitle(), this);
1719 QAction * action = new QAction(actionName, this);
1720 action->setCheckable(true);
1722 action->setChecked(workspace->activeSubWindow() == windows.at(i));
1723 windowsMenu->addAction(action);
1724 connect(windowsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotWindowsMenuActivated(QAction *)));
1725 // connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1727 QAction * id = windowsMenu->addAction(windows.at(i)->windowTitle(), this,
1728 // SLOT(slotWindowsMenuActivated(int)));
1729 SLOT(slotWindowsMenuActivated(QAction *)));
1731 // windowsMenu->setItemParameter(id, i);
1732 // windowsMenu->setItemChecked(id, workspace->activeSubWindow() == windows.at(i));
1734 id->setChecked(workspace->activeSubWindow() == windows.at(i));
1740 * Called when the user selects a document window from the
1743 void ApplicationWindow::slotWindowsMenuActivated(QAction * id)
1745 RS_DEBUG->print("ApplicationWindow::slotWindowsMenuActivated");
1747 // QMdiSubWindow * w = workspace->subWindowList().at(id);
1748 QMdiSubWindow * w = workspace->subWindowList().at(id->data().toInt());
1756 * Tiles MDI windows horizontally.
1758 void ApplicationWindow::slotTileHorizontal()
1760 RS_DEBUG->print("ApplicationWindow::slotTileHorizontal");
1763 // primitive horizontal tiling
1764 QWidgetList windows = workspace->windowList();
1766 if (windows.count() == 0)
1769 int heightForEach = workspace->height() / windows.count();
1772 for(int i=0; i<int(windows.count()); ++i)
1774 QWidget * window = windows.at(i);
1776 #warning "Need to port to Qt4... !!! FIX !!!"
1778 if (window->testWState(WState_Maximized))
1782 window->showNormal();
1786 int preferredHeight = window->minimumHeight() + window->parentWidget()->baseSize().height();
1787 int actHeight = QMAX(heightForEach, preferredHeight);
1789 // window->parentWidget()->resize(workspace->width(), actHeight);
1790 window->parentWidget()->setGeometry(0, y, workspace->width(), actHeight);
1794 workspace->tileSubWindows();
1799 * Tiles MDI windows vertically.
1801 void ApplicationWindow::slotTileVertical()
1807 QWidgetList windows = workspace->windowList();
1808 if (windows.count()==0) {
1812 //int heightForEach = workspace->height() / windows.count();
1814 for (int i=0; i<int(windows.count()); ++i) {
1815 QWidget *window = windows.at(i);
1816 if (window->testWState(WState_Maximized)) {
1819 window->showNormal();
1821 //int preferredHeight = window->minimumHeight()
1822 // + window->parentWidget()->baseSize().height();
1823 //int actHeight = QMAX(heightForEach, preferredHeight);
1825 //window->parentWidget()->setGeometry(0, y,
1826 // workspace->width(), actHeight);
1827 //window->parentWidget()->resize(window->parentWidget()->width(),
1828 // window->parentWidget()->height());
1829 //window->resize(window->width(), window->height());
1834 workspace->tileSubWindows();
1843 void ApplicationWindow::slotCamExportAuto() {
1844 printf("CAM export..\n");
1846 RS_Document* d = getDocument();
1848 Drawing* graphic = (Drawing*)d;
1850 RS_CamDialog dlg(graphic, this);
1858 * Called when something changed in the pen tool bar
1859 * (e.g. color, width, style).
1861 void ApplicationWindow::slotPenChanged(RS_Pen pen)
1863 RS_DEBUG->print("ApplicationWindow::slotPenChanged() begin");
1864 RS_DEBUG->print("Setting active pen...");
1865 MDIWindow * m = getMDIWindow();
1868 m->slotPenChanged(pen);
1870 RS_DEBUG->print("ApplicationWindow::slotPenChanged() end");
1874 * Creates a new MDI window with the given document or a new
1875 * document if 'doc' is NULL.
1877 MDIWindow * ApplicationWindow::slotFileNew(RS_Document * doc)
1879 RS_DEBUG->print("ApplicationWindow::slotFileNew() begin");
1884 statusBar()->showMessage(tr("Creating new file..."));
1886 #warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible"
1887 RS_DEBUG->print(" creating MDI window");
1888 // MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::WA_DeleteOnClose);
1889 MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::SubWindow);
1890 w->setAttribute(Qt::WA_DeleteOnClose);
1891 // w->setWindowState(WindowMaximized);
1892 connect(w, SIGNAL(signalClosing()), this, SLOT(slotFileClosing()));
1894 if (w->getDocument()->rtti() == RS2::EntityBlock)
1895 // w->setCaption(tr("Block '%1'").arg(((RS_Block *)(w->getDocument()))->getName()));
1896 w->setWindowTitle(tr("Block '%1'").arg(((RS_Block *)(w->getDocument()))->getName()));
1898 // w->setCaption(tr("unnamed document %1").arg(id));
1899 w->setWindowTitle(tr("unnamed document %1").arg(id));
1901 // w->setIcon(qPixmapFromMimeSource("document.png"));
1902 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
1903 w->setWindowIcon(QIcon(":/res/document.png"));
1905 // only graphics offer block lists, blocks don't
1906 RS_DEBUG->print(" adding listeners");
1907 Drawing * graphic = w->getDocument()->getGraphic();
1910 if (graphic != NULL)
1912 // Link the graphic's layer list to the pen tool bar
1913 graphic->addLayerListListener(penToolBar);
1914 // Link the layer list to the layer widget
1915 graphic->addLayerListListener(layerWidget);
1916 // Link the block list to the block widget
1917 graphic->addBlockListListener(blockWidget);
1921 // Link the dialog factory to the mouse widget:
1922 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
1923 // Link the dialog factory to the coordinate widget:
1924 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
1925 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
1926 // Link the dialog factory to the option widget:
1927 // QG_DIALOGFACTORY->setOptionWidget(optionWidget);
1928 // Link the dialog factory to the cad tool bar:
1929 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
1930 // Link the dialog factory to the command widget:
1931 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
1932 // Link the dialog factory to the main app window:
1933 QG_DIALOGFACTORY->setMainWindow(this);
1935 #if 1 //bugfix for Qt3->4 conversion
1936 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotFileNew: adding window to workspace...");
1937 // workspace->addWindow(w);
1938 workspace->addSubWindow(w);
1941 RS_DEBUG->print(" showing MDI window");
1944 #warning "w->showMaximized() doesn't seem to do anything here..."
1945 //but then again, the subWindowList isn't going to be empty at this point either...
1946 if (workspace->subWindowList().isEmpty())
1952 #warning "!!! SubWindow is not being activated !!!"
1953 //neither of these is working... Is the event being eaten somewhere???
1954 // workspace->activateNextSubWindow();
1956 //printf("--> ApplicationWindow::slotFileNew(): w %s focus...\n", (w->hasFocus() ? "has" : "DOES NOT HAVE"));
1959 #warning "!!! Parameter to slotWindowActivated() is ignored !!!"
1960 slotWindowActivated(w);
1961 statusBar()->showMessage(tr("New Drawing created."), 2000);
1963 RS_DEBUG->print("ApplicationWindow::slotFileNew() OK");
1970 * Menu file -> open.
1972 void ApplicationWindow::slotFileOpen()
1974 RS_DEBUG->print("ApplicationWindow::slotFileOpen()");
1976 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 001");
1977 RS2::FormatType type = RS2::FormatUnknown;
1978 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 002");
1979 QString fileName = FileDialog::getOpenFileName(this, &type);
1980 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 003");
1981 slotFileOpen(fileName, type);
1982 RS_DEBUG->print("ApplicationWindow::slotFileOpen(): OK");
1986 * Called when a recently opened file is chosen from the list in the
1989 void ApplicationWindow::slotFileOpenRecent(void)
1992 RS_DEBUG->print("ApplicationWindow::slotFileOpenRecent()");
1994 statusBar()->showMessage(tr("Opening recent file..."));
1995 QString fileName = recentFiles->get(id);
1997 if (fileName.endsWith(" (DXF 1)"))
1998 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
2000 slotFileOpen(fileName, RS2::FormatUnknown);
2002 statusBar()->showMessage(tr("Opening recent file..."));
2004 QAction * action = qobject_cast<QAction *>(sender());
2009 QString fileName = action->data().toString();
2011 if (fileName.endsWith(" (DXF 1)"))
2012 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
2014 slotFileOpen(fileName, RS2::FormatUnknown);
2019 * Menu file -> open.
2021 void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType type)
2023 RS_DEBUG->print("ApplicationWindow::slotFileOpen(..)");
2024 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2026 if (!fileName.isEmpty())
2028 RS_DEBUG->print("ApplicationWindow::slotFileOpen: creating new doc window");
2029 // Create new document window:
2030 MDIWindow * w = slotFileNew();
2031 RS_DEBUG->print("ApplicationWindow::slotFileOpen: linking layer list");
2032 // link the layer widget to the new document:
2033 layerWidget->setLayerList(w->getDocument()->getLayerList(), false);
2034 // link the block widget to the new document:
2035 blockWidget->setBlockList(w->getDocument()->getBlockList());
2036 // link coordinate widget to graphic
2037 coordinateWidget->setGraphic(w->getGraphic());
2039 // link the layer widget to the new document:
2040 simulationControls->setGraphicView(w->getGraphicView());
2042 RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file");
2044 // Open the file in the new view:
2045 if (!w->slotFileOpen(fileName, type))
2048 QApplication::restoreOverrideCursor();
2049 QMessageBox::information(this, QMessageBox::tr("Warning"),
2050 tr("Cannot open the file\n%1\nPlease check the permissions.") .arg(fileName), QMessageBox::Ok);
2051 w->setForceClosing(true);
2056 RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file: OK");
2057 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 1");
2059 // update recent files menu:
2060 if (type == RS2::FormatDXF1)
2061 recentFiles->add(fileName + " (DXF 1)");
2063 recentFiles->add(fileName);
2065 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 2");
2066 recentFiles->UpdateGUI();
2067 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: OK");
2068 RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption");
2070 w->setWindowTitle(fileName);
2071 RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption: OK");
2072 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget");
2073 // update coordinate widget format:
2074 RS_DIALOGFACTORY->updateCoordinateWidget(Vector(0.0, 0.0), Vector(0.0, 0.0), true);
2075 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget: OK");
2076 // Update the layer and block widgets (document just loaded may have some)
2077 layerWidget->update();
2078 blockWidget->update();
2079 // show output of filter (if any):
2080 QString message = tr("Loaded document: ") + fileName;
2081 commandWidget->appendHistory(message);
2082 statusBar()->showMessage(message, 2000);
2086 statusBar()->showMessage(tr("Opening aborted"), 2000);
2089 QApplication::restoreOverrideCursor();
2090 RS_DEBUG->print("ApplicationWindow::slotFileOpen(..) OK");
2094 * Menu file -> save.
2096 void ApplicationWindow::slotFileSave()
2098 RS_DEBUG->print("ApplicationWindow::slotFileSave()");
2100 statusBar()->showMessage(tr("Saving drawing..."));
2102 MDIWindow * w = getMDIWindow();
2107 if (w->getDocument()->getFilename().isEmpty())
2113 if (w->slotFileSave(cancelled))
2117 name = w->getDocument()->getFilename();
2118 statusBar()->showMessage(tr("Saved drawing: %1").arg(name), 2000);
2124 QMessageBox::information(this, QMessageBox::tr("Warning"),
2125 tr("Cannot save the file\n%1\nPlease check the permissions.")
2126 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2133 * Menu file -> save as.
2135 void ApplicationWindow::slotFileSaveAs()
2137 RS_DEBUG->print("ApplicationWindow::slotFileSaveAs()");
2139 statusBar()->showMessage(tr("Saving drawing under new filename..."));
2141 MDIWindow * w = getMDIWindow();
2148 if (w->slotFileSaveAs(cancelled))
2152 name = w->getDocument()->getFilename();
2153 recentFiles->add(name);
2154 w->setWindowTitle(name);
2160 QMessageBox::information(this, QMessageBox::tr("Warning"),
2161 tr("Cannot save the file\n%1\nPlease check the permissions.")
2162 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2166 // updateRecentFilesMenu();
2167 recentFiles->UpdateGUI();
2169 QString message = tr("Saved drawing: %1").arg(name);
2170 statusBar()->showMessage(message, 2000);
2171 commandWidget->appendHistory(message);
2175 * Menu file -> export.
2177 void ApplicationWindow::slotFileExport()
2179 RS_DEBUG->print("ApplicationWindow::slotFileExport()");
2180 statusBar()->showMessage(tr("Exporting drawing..."));
2181 MDIWindow * w = getMDIWindow();
2186 // read default settings:
2187 settings.beginGroup("Paths");
2188 QString defDir = settings.value("ExportImage", RS_SYSTEM->getHomeDir()).toString();
2189 QString defFilter = settings.value("ExportImageFilter", "Portable Network Graphic (*.png)").toString();
2190 settings.endGroup();
2192 bool cancel = false;
2194 // Q3FileDialog fileDlg(NULL, "", true);
2195 QFileDialog fileDlg(NULL, "", "", "");
2197 #warning "Need to port to Qt4... !!! FIX !!!"
2199 Q3StrList f = QImageIO::outputFormats();
2200 QStringList formats = QStringList::fromStrList(f);
2201 QStringList filters;
2204 for (QStringList::Iterator it = formats.begin();
2205 it!=formats.end(); ++it)
2210 st = QString("%1 (*.%2 *.jpg)")
2211 .arg(QG_DialogFactory::extToFormat(*it))
2212 .arg(QString(*it).lower());
2216 st = QString("%1 (*.%2)")
2217 .arg(QG_DialogFactory::extToFormat(*it))
2218 .arg(QString(*it).lower());
2223 //if (!all.isEmpty()) {
2226 //all += QString("*.%1").arg(QString(*it).lower());
2229 QStringList filters;
2232 fileDlg.setFilters(filters);
2233 // fileDlg.setMode(Q3FileDialog::AnyFile);
2234 fileDlg.setFileMode(QFileDialog::AnyFile);
2235 // fileDlg.setCaption(QObject::tr("Export Image"));
2236 fileDlg.setWindowTitle(QObject::tr("Export Image"));
2237 // fileDlg.setDir(defDir);
2238 fileDlg.setDirectory(defDir);
2239 fileDlg.selectNameFilter(defFilter);
2241 if (fileDlg.exec() == QDialog::Accepted)
2243 // fn = fileDlg.selectedFile();
2244 QStringList files = fileDlg.selectedFiles();
2246 if (!files.isEmpty())
2254 // store new default settings:
2257 settings.beginGroup("Paths");
2258 // settings.writeEntry("/ExportImage", QFileInfo(fn).dirPath(true));
2259 settings.setValue("ExportImage", QFileInfo(fn).absolutePath());
2260 settings.setValue("ExportImageFilter", fileDlg.selectedFilter());
2261 settings.endGroup();
2263 // find out extension:
2264 QString filter = fileDlg.selectedFilter();
2265 QString format = "";
2266 // int i = filter.find("(*.");
2267 int i = filter.indexOf("(*.");
2271 // int i2 = filter.find(QRegExp("[) ]"), i);
2272 int i2 = filter.indexOf(QRegExp("[) ]"), i);
2273 format = filter.mid(i + 3, i2 - (i + 3));
2274 format = format.toUpper();
2277 // append extension to file:
2278 if (!QFileInfo(fn).fileName().contains("."))
2279 fn.append("." + format.toLower());
2281 // show options dialog:
2282 ImageOptionsDialog dlg(this);
2283 dlg.setGraphicSize(w->getGraphic()->getSize());
2287 bool ret = slotFileExport(fn, format, dlg.getSize(), dlg.isBackgroundBlack());
2291 QString message = tr("Exported: %1").arg(fn);
2292 statusBar()->showMessage(message, 2000);
2293 commandWidget->appendHistory(message);
2301 * Exports the drawing as a bitmap.
2303 * @param name File name.
2304 * @param format File format (e.g. "png")
2305 * @param size Size of the bitmap in pixel
2306 * @param black true: Black background, false: white
2307 * @param bw true: black/white export, false: color
2309 bool ApplicationWindow::slotFileExport(const QString & name, const QString & format, QSize size, bool black, bool bw)
2311 MDIWindow * w = getMDIWindow();
2315 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no window opened");
2319 Drawing * graphic = w->getDocument()->getGraphic();
2323 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no graphic");
2327 statusBar()->showMessage(tr("Exporting..."));
2328 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2331 QPixmap * buffer = new QPixmap(size);
2332 // RS_PainterQt * painter = new RS_PainterQt(buffer);
2333 QPainter qpntr(buffer);
2334 PaintInterface * painter = new PaintInterface(&qpntr);
2336 // black background:
2338 // painter->setBackgroundColor(RS_Color(0, 0, 0));
2339 // qpntr.setBackgroundColor(RS_Color(0, 0, 0));
2340 qpntr.setBackground(QBrush(QColor(0, 0, 0)));
2341 // white background:
2343 // painter->setBackgroundColor(RS_Color(255, 255, 255));
2344 // qpntr.setBackgroundColor(RS_Color(255, 255, 255));
2345 qpntr.setBackground(QBrush(QColor(255, 255, 255)));
2349 painter->setDrawingMode(RS2::ModeBW);
2351 // painter->eraseRect(0, 0, size.width(), size.height());
2352 qpntr.eraseRect(0, 0, size.width(), size.height());
2354 RS_StaticGraphicView gv(size.width(), size.height(), painter);
2357 gv.setBackground(RS_Color(0, 0, 0));
2359 gv.setBackground(RS_Color(255, 255, 255));
2361 gv.setContainer(graphic);
2363 gv.drawEntity(graphic, true);
2370 iio.setFileName(name);
2371 iio.setFormat(format);
2378 #warning "ApplicationWindow::slotFileExport(): Need to port to Qt4... !!! FIX !!!"
2381 QApplication::restoreOverrideCursor();
2383 // GraphicView deletes painter
2390 statusBar()->showMessage(tr("Export complete"), 2000);
2392 statusBar()->showMessage(tr("Export failed!"), 2000);
2398 * Menu file -> close.
2400 void ApplicationWindow::slotFileClose()
2402 RS_DEBUG->print("ApplicationWindow::slotFileClose()");
2404 MDIWindow * m = getMDIWindow();
2413 //m->showMaximized();
2414 m->setWindowState(WindowMaximized);
2420 * Called when a MDI window is actually about to close. Used to
2421 * detach widgets from the document.
2423 void ApplicationWindow::slotFileClosing()
2425 RS_DEBUG->print("ApplicationWindow::slotFileClosing()");
2427 RS_DEBUG->print("detaching lists");
2428 layerWidget->setLayerList(NULL, false);
2429 blockWidget->setBlockList(NULL);
2430 coordinateWidget->setGraphic(NULL);
2432 simulationControls->setGraphicView(NULL);
2437 * Menu file -> print.
2439 void ApplicationWindow::slotFilePrint()
2441 RS_DEBUG->print("ApplicationWindow::slotFilePrint()");
2443 MDIWindow * w = getMDIWindow();
2447 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no window opened");
2451 Drawing * graphic = w->getDocument()->getGraphic();
2453 if (graphic == NULL)
2455 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no graphic");
2459 statusBar()->showMessage(tr("Printing..."));
2460 QPrinter * printer = new QPrinter(QPrinter::HighResolution);
2461 bool landscape = false;
2462 printer->setPageSize(RS2::rsToQtPaperFormat(graphic->getPaperFormat(&landscape)));
2465 printer->setOrientation(QPrinter::Landscape);
2467 printer->setOrientation(QPrinter::Portrait);
2469 settings.beginGroup("Print");
2470 printer->setOutputFileName(settings.value("FileName", "").toString());
2471 printer->setColorMode((QPrinter::ColorMode)settings.value("/ColorMode", (int)QPrinter::Color).toInt());
2472 #warning "!!! Need to port QPrinter::setOutputToFile() to Qt4 !!!"
2473 // printer->setOutputToFile((bool)RS_SETTINGS->readNumEntry("/PrintToFile", 0));
2474 settings.endGroup();
2477 // if (printer->setup(this))
2478 QPrintDialog dialog(printer, this);
2482 //printer->setOutputToFile(true);
2483 //printer->setOutputFileName(outputFile);
2485 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2486 printer->setFullPage(true);
2487 //Can call these functions directly from the QPaintDevice...
2488 // Q3PaintDeviceMetrics metr(printer);
2490 // RS_PainterQt * painter = new RS_PainterQt(printer);
2491 QPainter qpntr(printer);
2492 PaintInterface * painter = new PaintInterface(&qpntr);
2493 painter->setDrawingMode(w->getGraphicView()->getDrawingMode());
2495 // RS_StaticGraphicView gv(metr.width(), metr.height(), painter);
2496 RS_StaticGraphicView gv(printer->width(), printer->height(), painter);
2497 gv.setPrinting(true);
2498 gv.setBorders(0, 0, 0, 0);
2500 // double fx = (double)metr.width() / metr.widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2501 // double fy = (double)metr.height() / metr.heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2502 double fx = (double)printer->width() / printer->widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2503 double fy = (double)printer->height() / printer->heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2504 double f = (fx + fy) / 2;
2505 double scale = graphic->getPaperScale();
2507 gv.setOffset((int)(graphic->getPaperInsertionBase().x * f),
2508 (int)(graphic->getPaperInsertionBase().y * f));
2509 gv.setFactor(f * scale);
2510 gv.setContainer(graphic);
2511 gv.drawEntity(graphic, true);
2513 // GraphicView deletes painter
2518 settings.beginGroup("Print");
2519 #warning "!!! Need to port QPrinter::outputToFile() to Qt4 !!!"
2520 // settings.writeEntry("/PrintToFile", (int)printer->outputToFile());
2521 settings.setValue("ColorMode", (int)printer->colorMode());
2522 settings.setValue("FileName", printer->outputFileName());
2523 settings.endGroup();
2524 QApplication::restoreOverrideCursor();
2529 statusBar()->showMessage(tr("Printing complete"), 2000);
2533 * Menu file -> print preview.
2535 void ApplicationWindow::slotFilePrintPreview(bool on)
2537 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview()");
2539 RS_DEBUG->print(" creating MDI window");
2540 MDIWindow * parent = getMDIWindow();
2544 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrintPreview: no window opened");
2548 // close print preview:
2551 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): off");
2553 if (parent->getGraphicView()->isPrintPreview())
2555 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): close");
2559 // open print preview:
2562 // look for an existing print preview:
2563 MDIWindow * ppv = parent->getPrintPreview();
2567 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): show existing");
2568 slotWindowActivated(ppv);
2573 if (!parent->getGraphicView()->isPrintPreview())
2575 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): create");
2577 MDIWindow * w = new MDIWindow(parent->getDocument(), workspace, 0, Qt::SubWindow);
2578 w->setAttribute(Qt::WA_DeleteOnClose);
2579 parent->addChildWindow(w);
2580 //connect(w, SIGNAL(signalClosing()),
2581 // this, SLOT(slotFileClosing()));
2583 // w->setCaption(tr("Print preview for %1").arg(parent->caption()));
2584 w->setWindowTitle(tr("Print preview for %1").arg(parent->windowTitle()));
2585 // w->setIcon(qPixmapFromMimeSource("document.png"));
2586 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
2587 w->setWindowIcon(QIcon(":/res/document.png"));
2588 w->getGraphicView()->setPrintPreview(true);
2589 w->getGraphicView()->setBackground(RS_Color(255, 255, 255));
2590 w->getGraphicView()->setDefaultAction(new ActionPrintPreview(*w->getDocument(), *w->getGraphicView()));
2592 // only graphics offer block lists, blocks don't
2593 RS_DEBUG->print(" adding listeners");
2594 Drawing * graphic = w->getDocument()->getGraphic();
2599 // Link the layer list to the pen tool bar
2600 graphic->addLayerListListener(penToolBar);
2601 // Link the layer list to the layer widget
2602 graphic->addLayerListListener(layerWidget);
2603 // Link the block list to the block widget
2604 graphic->addBlockListListener(blockWidget);
2606 // Center by default:
2607 graphic->centerToPage();
2610 // Link the graphic view to the mouse widget:
2611 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
2612 // Link the graphic view to the coordinate widget:
2613 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
2614 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
2615 // Link the graphic view to the option widget:
2616 //QG_DIALOGFACTORY->setOptionWidget(optionWidget);
2617 // Link the graphic view to the cad tool bar:
2618 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
2619 // Link the graphic view to the command widget:
2620 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
2622 RS_DEBUG->print(" showing MDI window");
2624 if (workspace->subWindowList().isEmpty())
2629 w->getGraphicView()->zoomPage();
2632 slotWindowActivated(w);
2639 * Menu file -> quit.
2641 void ApplicationWindow::slotFileQuit()
2643 RS_DEBUG->print("ApplicationWindow::slotFileQuit()");
2645 statusBar()->showMessage(tr("Exiting application..."));
2647 if (queryExit(false))
2653 * Forces termination of QCad (demo version).
2655 void ApplicationWindow::slotFileDemoQuit()
2657 statusBar()->showMessage(tr("Exiting application..."));
2665 * Shows / hides the grid.
2667 * @param toggle true: show, false: hide.
2669 void ApplicationWindow::slotViewGrid(bool toggle)
2671 RS_DEBUG->print("ApplicationWindow::slotViewGrid()");
2673 MDIWindow * m = getMDIWindow();
2677 Drawing * g = m->getGraphic();
2680 g->setGridOn(toggle);
2686 RS_DEBUG->print("ApplicationWindow::slotViewGrid() OK");
2690 * Enables / disables the draft mode.
2692 * @param toggle true: enable, false: disable.
2694 void ApplicationWindow::slotViewDraft(bool toggle)
2696 RS_DEBUG->print("ApplicationWindow::slotViewDraft()");
2698 /*MDIWindow* m = getMDIWindow();
2700 Drawing* g = m->getGraphic();
2702 g->setDraftOn(toggle);
2706 settings.beginGroup("Appearance");
2707 settings.setValue("DraftMode", toggle);
2708 settings.endGroup();
2714 * Redraws all mdi windows.
2716 void ApplicationWindow::redrawAll()
2720 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2722 for(int i=0; i<int(windows.count()); ++i)
2724 MDIWindow * m = (MDIWindow *)windows.at(i);
2728 QG_GraphicView * gv = m->getGraphicView();
2738 * Updates all grids of all graphic views.
2740 void ApplicationWindow::updateGrids()
2744 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2746 for(int i=0; i<int(windows.count()); ++i)
2748 MDIWindow * m = (MDIWindow *)windows.at(i);
2752 QG_GraphicView * gv = m->getGraphicView();
2762 * Shows / hides the status bar.
2764 * @param showSB true: show, false: hide.
2766 void ApplicationWindow::slotViewStatusBar(bool showSB)
2768 RS_DEBUG->print("ApplicationWindow::slotViewStatusBar()");
2771 statusBar()->show();
2773 statusBar()->hide();
2777 * Shows / hides the layer list.
2779 * @param toggle true: show, false: hide.
2781 /*void ApplicationWindow::slotViewLayerList(bool toggle) {
2782 RS_DEBUG->print("ApplicationWindow::slotViewLayerList()");
2784 if (toggle==false) {
2785 layerDockWindow->hide();
2787 layerDockWindow->show();
2793 * Shows / hides the block list.
2795 * @param toggle true: show, false: hide.
2798 void ApplicationWindow::slotViewBlockList(bool toggle) {
2799 RS_DEBUG->print("ApplicationWindow::slotViewBlockList()");
2801 if (toggle==false) {
2802 blockDockWindow->hide();
2804 blockDockWindow->show();
2810 * Shows / hides the command line.
2812 * @param toggle true: show, false: hide.
2815 void ApplicationWindow::slotViewCommandLine(bool toggle) {
2816 RS_DEBUG->print("ApplicationWindow::slotViewCommandLine()");
2818 if (toggle==false) {
2819 commandDockWindow->hide();
2820 //QG_GraphicView* graphicView = getGraphicView();
2821 //if (graphicView!=NULL) {
2822 //graphicView->setFocus();
2826 commandDockWindow->show();
2832 * Shows / hides the option toolbar.
2834 * @param toggle true: show, false: hide.
2837 void ApplicationWindow::slotViewOptionToolbar(bool toggle) {
2838 RS_DEBUG->print("ApplicationWindow::slotViewOptionToolbar()");
2840 if (toggle==false) {
2841 optionWidget->hide();
2843 optionWidget->show();
2849 * Creates a new MDI window for editing the selected block.
2852 void ApplicationWindow::slotBlocksEdit() {
2853 RS_DEBUG->print("ApplicationWindow::slotBlocksEdit()");
2855 MDIWindow* parent = getMDIWindow();
2857 RS_BlockList* blist = blockWidget->getBlockList();
2859 RS_Block* blk = blist->getActiveBlock();
2861 MDIWindow* w = slotFileNew(blk);
2862 // the parent needs a pointer to the block window and
2864 parent->addChildWindow(w);
2865 w->getGraphicView()->zoomAuto();
2873 * Shows the dialog for general application preferences.
2875 void ApplicationWindow::slotOptionsGeneral()
2877 RS_DIALOGFACTORY->requestOptionsGeneralDialog();
2879 // update background color of all open drawings:
2880 settings.beginGroup("Appearance");
2881 QColor color(settings.value("BackgroundColor", "#000000").toString());
2882 QColor gridColor(settings.value("GridColor", "Gray").toString());
2883 QColor metaGridColor(settings.value("MetaGridColor", "Darkgray").toString());
2884 QColor selectedColor(settings.value("SelectedColor", "#A54747").toString());
2885 QColor highlightedColor(settings.value("HighlightedColor", "#739373").toString());
2886 settings.endGroup();
2888 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2890 for(int i=0; i<int(windows.count()); ++i)
2892 MDIWindow * m = (MDIWindow *)windows.at(i);
2896 QG_GraphicView * gv = m->getGraphicView();
2900 gv->setBackground(color);
2901 gv->setGridColor(gridColor);
2902 gv->setMetaGridColor(metaGridColor);
2903 gv->setSelectedColor(selectedColor);
2904 gv->setHighlightedColor(highlightedColor);
2913 * Menu script -> show ide
2915 void ApplicationWindow::slotScriptOpenIDE()
2918 scripter->openIDE();
2923 * Menu script -> run
2925 void ApplicationWindow::slotScriptRun()
2928 scripter->runScript();
2933 * Menu help -> about.
2935 void ApplicationWindow::slotHelpAbout()
2937 RS_DEBUG->print("ApplicationWindow::slotHelpAbout()");
2938 QStringList modules;
2945 modules += "Scripting";
2948 QString modulesString;
2950 if (!modules.empty())
2951 modulesString = modules.join(", ");
2953 modulesString = tr("None");
2955 QMessageBox box(this);
2956 box.setWindowTitle(tr("About..."));
2957 box.setText(QString("<qt>") + // no center for main stream QCad
2958 #ifdef QC_ABOUT_HEADER
2959 QString("<center>") +
2960 QString(QC_ABOUT_HEADER) +
2962 //FAIL "<h2>"+ QC_APPNAME+ "</h2>" +
2963 "<h2>Architektonas</h2>" +
2965 tr("Version: %1").arg("1.0.0") + "<br>" +
2966 tr("Date: %1").arg(__DATE__) + "<br>" +
2967 QString("© 2010 Underground Software,<br>James Hammons") +
2969 QString("Portions © 2001-2003 RibbonSoft") +
2971 #ifdef QC_ABOUT_ADD_COMPANY
2972 + QString("<br>") + QC_ABOUT_ADD_COMPANY
2974 + QString("</center>")
2976 #ifndef QC_ABOUT_HEADER
2977 #warning "Failure..."
2978 // box.setIcon(qPixmapFromMimeSource(QC_APP_ICON));
2979 box.setFixedWidth(340);
2980 box.setFixedHeight(250);
2986 * Menu help -> help.
2988 void ApplicationWindow::slotHelpManual()
2990 #warning "No help system ported to Qt4... !!! FIX !!!"
2992 RS_DEBUG->print("ApplicationWindow::slotHelpManual()");
2994 if (assistant == NULL)
2996 RS_DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
2997 RS_DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
2998 assistant = new QAssistantClient(RS_SYSTEM->getAppDir()+"/bin", this);
2999 connect(assistant, SIGNAL(error(const QString&)), this, SLOT(slotError(const QString&)));
3002 args << QDir::convertSeparators(RS_SYSTEM->getDocPath() + "/qcaddoc.adp");
3003 // args << QString("doc") + QDir::separator() + QString("qcaddoc.adp");
3005 #if QT_VERSION>=0x030200
3006 assistant->setArguments(args);
3009 assistant->openAssistant();
3010 //assistant->showPage("index.html");
3017 void ApplicationWindow::slotTestDumpEntities(RS_EntityContainer * d)
3019 RS_DEBUG->print("ApplicationWindow::slotTestDumpEntities()");
3020 static int level = 0;
3021 std::ofstream dumpFile;
3026 dumpFile.open("debug_entities.html");
3031 dumpFile.open("debug_entities.html", std::ios::app);
3039 dumpFile << "<html>\n";
3040 dumpFile << "<body>\n";
3043 for (RS_Entity* e=d->firstEntity();
3048 dumpFile << "<table border=\"1\">\n";
3049 dumpFile << "<tr><td>Entity: " << e->getId()
3053 << "<tr><td><table><tr>"
3054 << "<td>VIS:" << e->isVisible() << "</td>"
3055 << "<td>UND:" << e->isUndone() << "</td>"
3056 << "<td>SEL:" << e->isSelected() << "</td>"
3057 << "<td>TMP:" << e->getFlag(RS2::FlagTemp) << "</td>";
3058 QString lay = "NULL";
3059 if (e->getLayer()!=NULL) {
3060 lay = e->getLayer()->getName();
3063 //fail << "<td>Layer: " << lay << "</td>"
3064 << "<td>Width: " << (int)e->getPen(false).getWidth() << "</td>"
3065 << "<td>Parent: " << e->getParent()->getId() << "</td>"
3073 case RS2::EntityPoint:
3075 RS_Point* p = (RS_Point*)e;
3077 << "<table><tr><td>"
3089 case RS2::EntityLine:
3091 RS_Line* l = (RS_Line*)e;
3093 << "<table><tr><td>"
3099 << l->getStartpoint()
3108 case RS2::EntityArc: {
3109 RS_Arc* a = (RS_Arc*)e;
3111 << "<table><tr><td>"
3128 << "<td>Startpoint: "
3129 << a->getStartpoint()
3135 << (int)a->isReversed()
3141 case RS2::EntityCircle: {
3142 RS_Circle* c = (RS_Circle*)e;
3144 << "<table><tr><td>"
3159 case RS2::EntityDimAligned: {
3160 RS_DimAligned* d = (RS_DimAligned*)e;
3162 << "<table><tr><td>"
3163 << "<b>Dimension / Aligned:</b>"
3168 << d->getDefinitionPoint()
3171 << d->getExtensionPoint1()
3174 << d->getExtensionPoint2()
3177 << d->getText().toLatin1().data()
3180 << d->getLabel().toLatin1().data()
3186 case RS2::EntityDimLinear:
3188 RS_DimLinear* d = (RS_DimLinear*)e;
3190 << "<table><tr><td>"
3191 << "<b>Dimension / Linear:</b>"
3196 << d->getDefinitionPoint()
3199 << d->getExtensionPoint1()
3202 << d->getExtensionPoint2()
3205 //fail << d->getText()
3208 //fail << d->getLabel()
3214 case RS2::EntityInsert: {
3215 RS_Insert* i = (RS_Insert*)e;
3217 << "<table><tr><td>"
3222 << "<td>Insertion point:"
3223 << i->getInsertionPoint()
3229 case RS2::EntityText: {
3230 RS_Text* t = (RS_Text*)e;
3232 << "<table><tr><td>"
3238 << t->getText().toLatin1().data()
3247 case RS2::EntityHatch: {
3248 RS_Hatch* h = (RS_Hatch*)e;
3250 << "<table><tr><td>"
3256 << h->getPattern().toLatin1().data()
3262 << (int)h->isSolid()
3271 << "<b>Unknown Entity: " << e->rtti() << "</b>"
3276 if (e->isContainer() || e->rtti()==RS2::EntityHatch) {
3277 RS_EntityContainer* ec = (RS_EntityContainer*)e;
3278 dumpFile << "<table><tr><td valign=\"top\"> Contents:</td><td>\n";
3280 slotTestDumpEntities(ec);
3281 dumpFile.open("debug_entities.html", std::ios::app);
3282 dumpFile << "</td></tr></table>\n";
3292 dumpFile << "</body>\n";
3293 dumpFile << "</html>\n";
3303 void ApplicationWindow::slotTestDumpUndo()
3305 RS_DEBUG->print("ApplicationWindow::slotTestDumpUndo()");
3307 RS_Document * d = getDocument();
3311 std::cout << *(RS_Undo*)d;
3312 std::cout << std::endl;
3319 void ApplicationWindow::slotTestUpdateInserts()
3321 RS_DEBUG->print("ApplicationWindow::slotTestUpdateInserts()");
3323 RS_Document * d = getDocument();
3332 void ApplicationWindow::slotTestDrawFreehand()
3334 RS_DEBUG->print("ApplicationWindow::slotTestDrawFreehand()");
3336 //Drawing* g = document->getMarking();
3339 ActionDrawLineFree* action =
3340 new ActionDrawLineFree(*document->getGraphic(),
3343 for (int i=0; i<100; ++i) {
3345 int posx = (random()%600);
3346 int posy = (random()%400);
3348 //RS_MouseEvent rsm1(posx, posy, LEFT);
3349 RS_MouseEvent rsm1(QEvent::MouseButtonPress,
3353 action->mousePressEvent(&rsm1);
3358 for (int k=0; k<100; ++k) {
3359 int accx = (random()%40)-20;
3360 int accy = (random()%40)-20;
3368 //RS_MouseEvent rsm2(posx, posy, LEFT);
3370 RS_MouseEvent rsm2(QEvent::MouseMove,
3374 action->mouseMoveEvent(&rsm2);
3377 action->mouseReleaseEvent(NULL);
3389 void ApplicationWindow::slotTestInsertBlock()
3391 RS_DEBUG->print("ApplicationWindow::slotTestInsertBlock()");
3393 RS_Document * d = getDocument();
3395 if (d != NULL && d->rtti() == RS2::EntityGraphic)
3397 Drawing * graphic = (Drawing *)d;
3399 if (graphic == NULL)
3402 graphic->addLayer(new RS_Layer("default"));
3403 RS_Block * block = new RS_Block(graphic, RS_BlockData("debugblock", Vector(0.0, 0.0), true));
3409 // Add one red line:
3410 line = new RS_Line(block, RS_LineData(Vector(0.0, 0.0), Vector(50.0, 0.0)));
3411 line->setLayerToActive();
3412 line->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3413 block->addEntity(line);
3415 // Add one line with attributes from block:
3416 line = new RS_Line(block, RS_LineData(Vector(50.0, 0.0), Vector(50.0, 50.0)));
3417 line->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3418 block->addEntity(line);
3420 // Add one arc with attributes from block:
3421 RS_ArcData d(Vector(50.0, 0.0), 50.0, M_PI / 2.0, M_PI, false);
3422 arc = new RS_Arc(block, d);
3423 arc->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3424 block->addEntity(arc);
3426 // Add one blue circle:
3427 RS_CircleData circleData(Vector(20.0, 15.0), 12.5);
3428 circle = new RS_Circle(block, circleData);
3429 circle->setLayerToActive();
3430 circle->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width01, RS2::SolidLine));
3431 block->addEntity(circle);
3433 graphic->addBlock(block);
3436 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);
3438 // insert one magenta instance of the block (original):
3439 ins = new RS_Insert(graphic, insData);
3440 ins->setLayerToActive();
3441 ins->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width02, RS2::SolidLine));
3443 graphic->addEntity(ins);
3445 // insert one green instance of the block (rotate):
3446 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);
3447 ins = new RS_Insert(graphic, insData);
3448 ins->setLayerToActive();
3449 ins->setPen(RS_Pen(RS_Color(0, 255, 0), RS2::Width02, RS2::SolidLine));
3451 graphic->addEntity(ins);
3453 // insert one cyan instance of the block (move):
3454 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);
3455 ins = new RS_Insert(graphic, insData);
3456 ins->setLayerToActive();
3457 ins->setPen(RS_Pen(RS_Color(0, 255, 255), RS2::Width02, RS2::SolidLine));
3459 graphic->addEntity(ins);
3461 // insert one blue instance of the block:
3462 for(double a=0.0; a<360.0; a+=45.0)
3464 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);
3465 ins = new RS_Insert(graphic, insData);
3466 ins->setLayerToActive();
3467 ins->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width05, RS2::SolidLine));
3469 graphic->addEntity(ins);
3472 // insert an array of yellow instances of the block:
3473 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);
3474 ins = new RS_Insert(graphic, insData);
3475 ins->setLayerToActive();
3476 ins->setPen(RS_Pen(RS_Color(255, 255, 0), RS2::Width01, RS2::SolidLine));
3478 graphic->addEntity(ins);
3480 GraphicView * v = getGraphicView();
3490 void ApplicationWindow::slotTestInsertEllipse()
3492 RS_DEBUG->print("ApplicationWindow::slotTestInsertEllipse()");
3494 RS_Document * d = getDocument();
3498 Drawing * graphic = (Drawing *)d;
3500 if (graphic == NULL)
3503 RS_Ellipse * ellipse;
3506 for (double a=0.0; a<2*M_PI; a+=0.1)
3509 v.setPolar(50.0, a);
3510 double xp = 1000.0*a;
3512 RS_EllipseData ellipseData(Vector(xp, 0.0), v, 0.5, 0.0, 2 * M_PI, false);
3513 ellipse = new RS_Ellipse(graphic, ellipseData);
3515 ellipse->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width01, RS2::SolidLine));
3517 graphic->addEntity(ellipse);
3518 //graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3519 //graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3521 line = new RS_Line(graphic, RS_LineData(Vector(xp, 0.0), Vector(xp, 0.0) + v));
3522 line->setPen(RS_Pen(RS_Color(128, 128, 128), RS2::Width01, RS2::SolidLine));
3523 graphic->addEntity(line);
3526 for (double mx=-60.0; mx<60.0; mx+=1.0) {
3527 //for (double mx=0.0; mx<1.0; mx+=2.5) {
3528 VectorSolutions sol = ellipse->mapX(xp + mx);
3529 //graphic->addEntity(new RS_Point(graphic,
3530 // sol.vector2 + Vector(a*500.0, 0.0)));
3531 //graphic->addEntity(new RS_Point(graphic,
3532 // sol.vector3 + Vector(a*500.0, 0.0)));
3533 //graphic->addEntity(new RS_Point(graphic,
3534 // sol.vector4 + Vector(a*500.0, 0.0)));
3536 line = new RS_Line(graphic,
3537 RS_LineData(Vector(xp+mx,-50.0),
3538 Vector(xp+mx,50.0)));
3539 line->setPen(RS_Pen(RS_Color(60, 60, 60),
3542 graphic->addEntity(line);
3544 graphic->addEntity(new RS_Point(graphic,
3550 // different minor/minor relations
3553 for (y=-250.0; y<=250.0; y+=50.0) {
3554 for (x=-250.0; x<=250.0; x+=50.0) {
3557 ellipse = new RS_Ellipse(graphic,
3559 Vector((x/5+50.0)/2.0, 0.0),
3564 ellipse->setPen(RS_Pen(RS_Color(255, 255, 0),
3568 graphic->addEntity(ellipse);
3569 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3570 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3572 ellipse = new RS_Ellipse(graphic,
3573 v + Vector(750.0, 0.0),
3574 Vector((x/5+50.0)/2.0, 0.0),
3579 graphic->addEntity(ellipse);
3580 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3581 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3587 // different rotation angles:
3589 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3590 ellipse = new RS_Ellipse(graphic,
3591 Vector(rot*200, 500.0),
3592 Vector(50.0, 0.0).rotate(rot),
3596 graphic->addEntity(ellipse);
3597 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3598 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3602 // different arc angles:
3604 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3605 for (a1=0.0; a1<=2*M_PI+0.1; a1+=(M_PI/8)) {
3606 for (a2=a1+M_PI/8; a2<=2*M_PI+a1+0.1; a2+=(M_PI/8)) {
3607 ellipse = new RS_Ellipse(graphic,
3608 Vector(-500.0-a1*200.0-5000.0*rot,
3610 Vector(50.0, 0.0).rotate(rot),
3614 graphic->addEntity(ellipse);
3615 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3616 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3622 GraphicView * v = getGraphicView();
3632 void ApplicationWindow::slotTestInsertText()
3634 RS_DEBUG->print("ApplicationWindow::slotTestInsertText()");
3636 RS_Document * d = getDocument();
3640 Drawing * graphic = (Drawing *)d;
3642 if (graphic == NULL)
3646 RS_TextData textData;
3648 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);
3649 text = new RS_Text(graphic, textData);
3650 text->setLayerToActive();
3651 text->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3652 graphic->addEntity(text);
3656 for (y=-250.0; y<=250.0; y+=50.0) {
3657 for (x=-250.0; x<=250.0; x+=50.0) {
3660 textData = RS_TextData(v,
3671 text = new RS_Text(graphic, textData);
3673 text->setLayerToActive();
3674 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3677 graphic->addEntity(text);
3682 for (x=0.0; x<M_PI*2.0; x+=0.2) {
3683 Vector v(600.0+cos(x)*50.0, 0.0+sin(x)*50.0);
3685 line = new RS_Line(graphic,
3686 RS_LineData(Vector(600.0,0.0),
3688 line->setLayerToActive();
3689 line->setPenToActive();
3690 graphic->addEntity(line);
3692 textData = RS_TextData(v,
3703 text = new RS_Text(graphic, textData);
3705 text->setLayerToActive();
3706 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3709 graphic->addEntity(text);
3712 RS_SolidData solidData = RS_SolidData(Vector(5.0, 10.0),
3714 Vector(15.0, 30.0));
3716 RS_Solid* s = new RS_Solid(graphic, solidData);
3718 s->setLayerToActive();
3719 s->setPen(RS_Pen(RS_Color(255, 255, 0),
3722 graphic->addEntity(s);
3724 GraphicView* v = getGraphicView();
3735 void ApplicationWindow::slotTestInsertImage()
3737 RS_DEBUG->print("ApplicationWindow::slotTestInsertImage()");
3739 RS_Document * d = getDocument();
3743 Drawing * graphic = (Drawing *)d;
3745 if (graphic == NULL)
3749 RS_ImageData imageData;
3751 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);
3752 image = new RS_Image(graphic, imageData);
3754 image->setLayerToActive();
3755 image->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3756 graphic->addEntity(image);
3763 void ApplicationWindow::slotTestUnicode()
3765 RS_DEBUG->print("ApplicationWindow::slotTestUnicode()");
3767 slotFileOpen("./fonts/unicode.cxf", RS2::FormatCXF);
3768 RS_Document* d = getDocument();
3770 Drawing* graphic = (Drawing*)d;
3771 if (graphic==NULL) {
3779 QChar uCode; // e.g. 65 (or 'A')
3780 QString strCode; // unicde as string e.g. '[0041] A'
3782 graphic->setAutoUpdateBorders(false);
3784 for (col=0x0000; col<=0xFFF0; col+=0x10) {
3785 printf("col: %X\n", col);
3786 for (row=0x0; row<=0xF; row++) {
3787 //printf(" row: %X\n", row);
3789 uCode = QChar(col+row);
3790 //printf(" code: %X\n", uCode.unicode());
3792 strCode.setNum(uCode.unicode(), 16);
3793 while (strCode.length()<4) {
3794 strCode="0"+strCode;
3796 strCode = "[" + strCode + "] " + uCode;
3798 if (graphic->findBlock(strCode)!=NULL) {
3799 RS_InsertData d(strCode,
3800 Vector(col/0x10*20.0,row*20.0),
3801 Vector(1.0,1.0), 0.0,
3802 1, 1, Vector(0.0, 0.0),
3803 NULL, RS2::NoUpdate);
3804 ins = new RS_Insert(graphic, d);
3805 ins->setLayerToActive();
3806 ins->setPen(RS_Pen(RS_Color(255, 255, 255),
3810 graphic->addEntity(ins);
3814 graphic->setAutoUpdateBorders(true);
3815 graphic->calculateBorders();
3822 void ApplicationWindow::slotTestMath01()
3824 RS_DEBUG->print("ApplicationWindow::slotTestMath01()");
3826 RS_Document* d = getDocument();
3828 Drawing* graphic = (Drawing*)d;
3829 if (graphic==NULL) {
3834 graphic->addEntity(new RS_Line(graphic,
3835 RS_LineData(Vector(0.0,0.0),
3836 Vector(2*M_PI,0.0))));
3837 graphic->addEntity(new RS_Line(graphic,
3838 RS_LineData(Vector(0.0,-1.0),
3843 double x = 59.0/ARAD;
3844 double x_0 = 60.0/ARAD;
3845 for (a=0.01; a<2*M_PI; a+=0.01) {
3847 RS_Line* line = new RS_Line(graphic,
3848 RS_LineData(Vector(a-0.01, cos(a-0.01)),
3849 Vector(a, cos(a))));
3850 graphic->addEntity(line);
3853 graphic->addEntity(new RS_Line(graphic,
3854 RS_LineData(Vector(a-0.01,cos(x_0)-sin(x_0)*(a-0.01-x_0)),
3855 Vector(a,cos(x_0)-sin(x_0)*(a-x_0)))));
3859 graphic->addEntity(new RS_Line(graphic,
3860 RS_LineData(Vector(x,0.0),
3864 graphic->addEntity(new RS_Line(graphic,
3865 RS_LineData(Vector(x_0,0.0),
3869 //graphic->addEntity(new RS_Line(graphic,
3870 // Vector(0.0,cos(x_0)-sin(x_0)*(0.0-x_0)),
3871 // Vector(6.0,cos(x_0)-sin(x_0)*(6.0-x_0))));
3874 GraphicView* v = getGraphicView();
3884 void ApplicationWindow::slotTestResize640()
3886 RS_DEBUG->print("ApplicationWindow::slotTestResize640()");
3894 void ApplicationWindow::slotTestResize800()
3896 RS_DEBUG->print("ApplicationWindow::slotTestResize800()");
3904 void ApplicationWindow::slotTestResize1024()
3906 RS_DEBUG->print("ApplicationWindow::slotTestResize1024()");
3912 * overloaded for Message box on last window exit.
3914 bool ApplicationWindow::queryExit(bool force)
3916 RS_DEBUG->print("ApplicationWindow::queryExit()");
3923 QMessageBox::information(this, QMessageBox::tr("Warning"),
3924 tr("This is a %1 version "
3925 "which terminates\n"
3926 "automatically after 10min. This software is\n"
3927 "not intended for production use. Please buy\n"
3928 "a full version of the application from\n%2.\n"
3929 "You can save your work now.")
3930 //FAIL .arg(QC_APPNAME)
3931 .arg("Architektonas")
3932 #ifdef QC_CUSTOM_VENDOR
3933 .arg(QC_CUSTOM_VENDOR),
3935 .arg("RibbonSoft, http://www.ribbonsoft.com"),
3940 QList<QMdiSubWindow *> list = workspace->subWindowList();
3942 // for(QWidget * w=list.first(); w!=NULL; w=list.next())
3943 for(int i=0; i<list.size(); i++)
3945 succ = ((MDIWindow *)list[i])->closeMDI(force);
3954 RS_DEBUG->print("ApplicationWindow::queryExit(): OK");
3960 * Handle hotkeys. Don't let it to the default handler of Qt.
3961 * it will consume them also if a text field is active
3962 * which means it's impossible to enter a command.
3964 void ApplicationWindow::keyPressEvent(QKeyEvent * e)
3966 #warning "!!! keyPressEvent(): Do we need this anymore? !!!"
3968 static QTime ts = QTime();
3969 static QString firstKey = "";
3971 // single key codes:
3975 case Qt::Key_Control:
3978 case Qt::Key_CapsLock:
3980 QMainWindow::keyPressEvent(e);
3982 // forward to actions:
3983 GraphicView * graphicView = getGraphicView();
3986 graphicView->keyPressEvent(e);
3992 case Qt::Key_Escape:
3998 case Qt::Key_Return:
3999 if (firstKey.isEmpty())
4007 if (firstKey.isEmpty())
4009 actionHandler->slotZoomIn();
4015 if (firstKey.isEmpty())
4017 actionHandler->slotZoomOut();
4027 if (e->isAccepted())
4030 QTime now = QTime::currentTime();
4033 if (ts.msecsTo(now) < 2000)
4035 QString code = QString("%1%2").arg(firstKey).arg(QChar(e->key())).toLower();
4037 if (actionHandler->keycode(code) == false)
4041 if (QChar(e->key()).isPrint())
4042 firstKey += e->key();
4051 if (QChar(e->key()).isPrint())
4052 firstKey = e->key();
4055 // Q3MainWindow::keyPressEvent(e);
4056 QMainWindow::keyPressEvent(e);
4059 void ApplicationWindow::keyReleaseEvent(QKeyEvent * e)
4064 case Qt::Key_Control:
4067 case Qt::Key_CapsLock:
4069 // Q3MainWindow::keyReleaseEvent(e);
4070 QMainWindow::keyReleaseEvent(e);
4072 // forward to actions:
4073 GraphicView * graphicView = getGraphicView();
4076 graphicView->keyReleaseEvent(e);
4083 // Q3MainWindow::keyPressEvent(e);
4084 QMainWindow::keyPressEvent(e);
4088 * @return Pointer to application window.
4090 /*static*/ ApplicationWindow * ApplicationWindow::getAppWindow()
4096 * @return Pointer to workspace.
4098 QMdiArea * ApplicationWindow::getWorkspace()
4104 * @return Pointer to the currently active MDI Window or NULL if no
4105 * MDI Window is active.
4107 MDIWindow * ApplicationWindow::getMDIWindow()
4109 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::getMDIWindow: workspace=%08X", workspace);
4113 RS_DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=%08X", workspace->activeSubWindow());
4114 return (MDIWindow *)workspace->activeSubWindow();
4117 RS_DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=??? (workspace == NULL)");
4122 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4124 * @return Pointer to the graphic view of the currently active document
4125 * window or NULL if no window is available.
4127 /*virtual*/ GraphicView * ApplicationWindow::getGraphicView()
4129 MDIWindow * m = getMDIWindow();
4131 return (m ? m->getGraphicView() : NULL);
4135 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4137 * @return Pointer to the graphic document of the currently active document
4138 * window or NULL if no window is available.
4140 /*virtual*/ RS_Document * ApplicationWindow::getDocument()
4142 MDIWindow * m = getMDIWindow();
4144 return (m ? m->getDocument() : NULL);
4148 * Creates a new document. Implementation from RS_MainWindowInterface.
4150 /*virtual*/ void ApplicationWindow::createNewDocument(const QString & fileName/*= QString::null*/,
4151 RS_Document * doc/*= NULL*/)
4155 if (fileName != QString::null && getDocument())
4156 getDocument()->setFilename(fileName);
4160 * Implementation from QG_MainWindowInterface.
4162 * @return Pointer to this.
4164 /*virtual*/ QMainWindow * ApplicationWindow::GetMainWindow()
4170 * @return Pointer to action handler. Implementation from QG_MainWindowInterface.
4172 /*virtual*/ ActionHandler * ApplicationWindow::getActionHandler()
4174 return actionHandler;
4178 * Implementation from QG_MainWindowInterface.
4180 /*virtual*/ void ApplicationWindow::showSimulationControls()
4183 simulationDockWindow->show();
4189 * @return Pointer to the qsa object.
4191 QSProject * ApplicationWindow::getQSAProject()
4193 if (scripter != NULL)
4194 return scripter->getQSAProject();
4201 * Implementation from QG_MainWindowInterface.
4203 /*virtual*/ void ApplicationWindow::setFocus2()