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"
50 #include "qg_colorbox.h"
51 #include "qg_filedialog.h"
52 #include "qg_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 QG_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 QG_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 QG_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 QG_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 libraryDockWindow = dw;
1503 libraryDockWindow->hide();
1505 RS_DEBUG->print(" command widget..");
1506 // dw = new QDockWidget(QDockWidget::InDock, this, "Command");
1507 dw = new QDockWidget(tr("Command line"), this);
1508 dw->setObjectName("command");
1509 commandWidget = new CommandWidget(dw);//WAS:, "Command");
1510 commandWidget->setActionHandler(actionHandler);
1511 // commandWidget->redirectStderr();
1512 // std::cerr << "Ready.\n";
1513 // commandWidget->processStderr();
1514 connect(this, SIGNAL(windowsChanged(bool)), commandWidget, SLOT(setEnabled(bool)));
1515 dw->setWidget(commandWidget);
1516 #warning "following four lines commented out..."
1517 // dw->setFixedExtentHeight(45);
1518 // dw->setResizeEnabled(true);
1519 // dw->setCloseMode(QDockWidget::Always);
1520 // dw->setCaption(tr("Command line"));
1521 commandDockWindow = dw;
1522 addDockWidget(Qt::BottomDockWidgetArea, dw);
1524 RS_DEBUG->print(" done");
1528 * Creates a new toolbar.
1529 * Implementation from QG_MainWindowInterface.
1530 * Can be called from scripts to add individual GUI elements.
1532 /*QToolBar* ApplicationWindow::createToolBar(const QString& name) {
1533 QToolBar* tb = new QToolBar(this, name);
1539 * Creates a new button in the given tool bar for running a script.
1541 /*void ApplicationWindow::addToolBarButton(QToolBar* tb) {
1543 QAction* action = new QAction("Blah",
1544 QPixmap::fromMimeSource("zoomwindow.png"),
1545 "&Blah", QKeySequence(), NULL);
1546 action->setStatusTip("Blah blah");
1552 * Goes back to the previous menu or one step in the current action.
1554 void ApplicationWindow::slotBack()
1556 GraphicView * graphicView = getGraphicView();
1559 graphicView->back();
1563 cadToolBar->showToolBar(RS2::ToolBarMain);
1568 * Goes one step further in the current action.
1570 void ApplicationWindow::slotEnter()
1572 if (!commandWidget || !commandWidget->checkFocus())
1575 cadToolBar->forceNext();
1578 GraphicView * graphicView = getGraphicView();
1581 graphicView->enter();
1587 * Sets the keyboard focus on the command line.
1589 void ApplicationWindow::slotFocusCommandLine()
1591 if (commandWidget->isVisible())
1592 commandWidget->setFocus();
1596 * Shows the given error on the command line.
1598 void ApplicationWindow::slotError(const QString & msg)
1600 commandWidget->appendHistory(msg);
1604 * Hands focus back to the application window. In the rare event
1605 * of a escape press from the layer widget (e.g after switching desktops
1608 void ApplicationWindow::slotFocus()
1610 //QG_GraphicView* graphicView = getGraphicView();
1611 /*if (graphicView!=NULL) {
1612 graphicView->setFocus();
1620 * Called when a document window was activated.
1622 void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/)
1624 RS_DEBUG->print("ApplicationWindow::slotWindowActivated begin");
1626 //the following does: return (MDIWindow *)workspace->activeSubWindow();
1627 //which means the subwindow is NOT being activated!!!
1628 MDIWindow * m = getMDIWindow();
1629 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m=%08X", m);
1631 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m->getDoc=%08X", m->getDocument());
1633 if (m && m->getDocument())
1635 //m->setWindowState(WindowMaximized);
1637 RS_DEBUG->print("ApplicationWindow::slotWindowActivated: document: %d", m->getDocument()->getId());
1639 bool showByBlock = m->getDocument()->rtti() == RS2::EntityBlock;
1640 layerWidget->setLayerList(m->getDocument()->getLayerList(), showByBlock);
1641 coordinateWidget->setGraphic(m->getGraphic());
1644 simulationControls->setGraphicView(m->getGraphicView());
1647 // Only graphics show blocks. (blocks don't)
1648 if (m->getDocument()->rtti() == RS2::EntityGraphic)
1649 blockWidget->setBlockList(m->getDocument()->getBlockList());
1651 blockWidget->setBlockList(NULL);
1653 // Update all inserts in this graphic (blocks might have changed):
1654 m->getDocument()->updateInserts();
1655 m->getGraphicView()->redraw();
1657 // set snapmode from snapping menu
1658 actionHandler->updateSnapMode();
1660 // set pen from pen toolbar
1661 slotPenChanged(penToolBar->getPen());
1663 // update toggle button status:
1664 if (m->getGraphic() != NULL)
1666 emit(gridChanged(m->getGraphic()->isGridOn()));
1667 emit(printPreviewChanged(m->getGraphicView()->isPrintPreview()));
1671 //Seems to work now.
1672 //#warning "This is failing... !!! FIX !!!"
1673 // Disable/Enable menu and toolbar items
1674 emit windowsChanged(m != NULL && m->getDocument() != NULL);
1676 RS_DEBUG->print("ApplicationWindow::slotWindowActivated end");
1680 * Called when the menu 'windows' is about to be shown.
1681 * This is used to update the window list in the menu.
1683 void ApplicationWindow::slotWindowsMenuAboutToShow()
1685 RS_DEBUG->print("ApplicationWindow::slotWindowsMenuAboutToShow");
1687 windowsMenu->clear();
1689 int cascadeId = windowsMenu->insertItem(tr("&Cascade"), workspace, SLOT(cascade()));
1690 int tileId = windowsMenu->insertItem(tr("&Tile"), this, SLOT(slotTileVertical()));
1691 int horTileId = windowsMenu->insertItem(tr("Tile &Horizontally"), this, SLOT(slotTileHorizontal()));
1693 if (workspace->subWindowList().isEmpty())
1695 windowsMenu->setItemEnabled(cascadeId, false);
1696 windowsMenu->setItemEnabled(tileId, false);
1697 windowsMenu->setItemEnabled(horTileId, false);
1700 windowsMenu->insertSeparator();
1702 #warning "!!! Qt4 implementation of insertItem is vastly different from Qt3--FIX !!!"
1704 QList<QMdiSubWindow *> windows = workspace->subWindowList();
1706 //#warning "Need to add window numbers underlined so can access windows via keyboard. !!! FIX !!!"
1708 for(int i=0; i<int(windows.count()); ++i)
1710 // int id = windowsMenu->insertItem(windows.at(i)->caption(), this, SLOT(slotWindowsMenuActivated(int)));
1711 //For some reason the triggered() signal created here is type bool... Dunno why...
1712 //It's signalling using the QAction signal, which is type bool (checked or not).
1714 QString actionName = QString("&%1 %2").arg(i + 1).arg(windows.at(i)->windowTitle());
1715 // QAction * action = new QAction(windows.at(i)->windowTitle(), this);
1716 QAction * action = new QAction(actionName, this);
1717 action->setCheckable(true);
1719 action->setChecked(workspace->activeSubWindow() == windows.at(i));
1720 windowsMenu->addAction(action);
1721 connect(windowsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotWindowsMenuActivated(QAction *)));
1722 // connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1724 QAction * id = windowsMenu->addAction(windows.at(i)->windowTitle(), this,
1725 // SLOT(slotWindowsMenuActivated(int)));
1726 SLOT(slotWindowsMenuActivated(QAction *)));
1728 // windowsMenu->setItemParameter(id, i);
1729 // windowsMenu->setItemChecked(id, workspace->activeSubWindow() == windows.at(i));
1731 id->setChecked(workspace->activeSubWindow() == windows.at(i));
1737 * Called when the user selects a document window from the
1740 void ApplicationWindow::slotWindowsMenuActivated(QAction * id)
1742 RS_DEBUG->print("ApplicationWindow::slotWindowsMenuActivated");
1744 // QMdiSubWindow * w = workspace->subWindowList().at(id);
1745 QMdiSubWindow * w = workspace->subWindowList().at(id->data().toInt());
1753 * Tiles MDI windows horizontally.
1755 void ApplicationWindow::slotTileHorizontal()
1757 RS_DEBUG->print("ApplicationWindow::slotTileHorizontal");
1760 // primitive horizontal tiling
1761 QWidgetList windows = workspace->windowList();
1763 if (windows.count() == 0)
1766 int heightForEach = workspace->height() / windows.count();
1769 for(int i=0; i<int(windows.count()); ++i)
1771 QWidget * window = windows.at(i);
1773 #warning "Need to port to Qt4... !!! FIX !!!"
1775 if (window->testWState(WState_Maximized))
1779 window->showNormal();
1783 int preferredHeight = window->minimumHeight() + window->parentWidget()->baseSize().height();
1784 int actHeight = QMAX(heightForEach, preferredHeight);
1786 // window->parentWidget()->resize(workspace->width(), actHeight);
1787 window->parentWidget()->setGeometry(0, y, workspace->width(), actHeight);
1791 workspace->tileSubWindows();
1796 * Tiles MDI windows vertically.
1798 void ApplicationWindow::slotTileVertical()
1804 QWidgetList windows = workspace->windowList();
1805 if (windows.count()==0) {
1809 //int heightForEach = workspace->height() / windows.count();
1811 for (int i=0; i<int(windows.count()); ++i) {
1812 QWidget *window = windows.at(i);
1813 if (window->testWState(WState_Maximized)) {
1816 window->showNormal();
1818 //int preferredHeight = window->minimumHeight()
1819 // + window->parentWidget()->baseSize().height();
1820 //int actHeight = QMAX(heightForEach, preferredHeight);
1822 //window->parentWidget()->setGeometry(0, y,
1823 // workspace->width(), actHeight);
1824 //window->parentWidget()->resize(window->parentWidget()->width(),
1825 // window->parentWidget()->height());
1826 //window->resize(window->width(), window->height());
1831 workspace->tileSubWindows();
1840 void ApplicationWindow::slotCamExportAuto() {
1841 printf("CAM export..\n");
1843 RS_Document* d = getDocument();
1845 Drawing* graphic = (Drawing*)d;
1847 RS_CamDialog dlg(graphic, this);
1855 * Called when something changed in the pen tool bar
1856 * (e.g. color, width, style).
1858 void ApplicationWindow::slotPenChanged(RS_Pen pen)
1860 RS_DEBUG->print("ApplicationWindow::slotPenChanged() begin");
1861 RS_DEBUG->print("Setting active pen...");
1862 MDIWindow * m = getMDIWindow();
1865 m->slotPenChanged(pen);
1867 RS_DEBUG->print("ApplicationWindow::slotPenChanged() end");
1871 * Creates a new MDI window with the given document or a new
1872 * document if 'doc' is NULL.
1874 MDIWindow * ApplicationWindow::slotFileNew(RS_Document * doc)
1876 RS_DEBUG->print("ApplicationWindow::slotFileNew() begin");
1881 statusBar()->showMessage(tr("Creating new file..."));
1883 #warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible"
1884 RS_DEBUG->print(" creating MDI window");
1885 // MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::WA_DeleteOnClose);
1886 MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::SubWindow);
1887 w->setAttribute(Qt::WA_DeleteOnClose);
1888 // w->setWindowState(WindowMaximized);
1889 connect(w, SIGNAL(signalClosing()), this, SLOT(slotFileClosing()));
1891 if (w->getDocument()->rtti() == RS2::EntityBlock)
1892 // w->setCaption(tr("Block '%1'").arg(((RS_Block *)(w->getDocument()))->getName()));
1893 w->setWindowTitle(tr("Block '%1'").arg(((RS_Block *)(w->getDocument()))->getName()));
1895 // w->setCaption(tr("unnamed document %1").arg(id));
1896 w->setWindowTitle(tr("unnamed document %1").arg(id));
1898 // w->setIcon(qPixmapFromMimeSource("document.png"));
1899 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
1900 w->setWindowIcon(QIcon(":/res/document.png"));
1902 // only graphics offer block lists, blocks don't
1903 RS_DEBUG->print(" adding listeners");
1904 Drawing * graphic = w->getDocument()->getGraphic();
1906 if (graphic != NULL)
1908 // Link the graphic's layer list to the pen tool bar
1909 graphic->addLayerListListener(penToolBar);
1910 // Link the layer list to the layer widget
1911 graphic->addLayerListListener(layerWidget);
1912 // Link the block list to the block widget
1913 graphic->addBlockListListener(blockWidget);
1916 // Link the dialog factory to the mouse widget:
1917 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
1918 // Link the dialog factory to the coordinate widget:
1919 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
1920 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
1921 // Link the dialog factory to the option widget:
1922 // QG_DIALOGFACTORY->setOptionWidget(optionWidget);
1923 // Link the dialog factory to the cad tool bar:
1924 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
1925 // Link the dialog factory to the command widget:
1926 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
1927 // Link the dialog factory to the main app window:
1928 QG_DIALOGFACTORY->setMainWindow(this);
1930 #if 1 //bugfix for Qt3->4 conversion
1931 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotFileNew: adding window to workspace...");
1932 // workspace->addWindow(w);
1933 workspace->addSubWindow(w);
1936 RS_DEBUG->print(" showing MDI window");
1939 #warning "w->showMaximized() doesn't seem to do anything here..."
1940 //but then again, the subWindowList isn't going to be empty at this point either...
1941 if (workspace->subWindowList().isEmpty())
1947 #warning "!!! SubWindow is not being activated !!!"
1948 //neither of these is working... Is the event being eaten somewhere???
1949 // workspace->activateNextSubWindow();
1951 //printf("--> ApplicationWindow::slotFileNew(): w %s focus...\n", (w->hasFocus() ? "has" : "DOES NOT HAVE"));
1954 #warning "!!! Parameter to slotWindowActivated() is ignored !!!"
1955 slotWindowActivated(w);
1956 statusBar()->showMessage(tr("New Drawing created."), 2000);
1958 RS_DEBUG->print("ApplicationWindow::slotFileNew() OK");
1965 * Menu file -> open.
1967 void ApplicationWindow::slotFileOpen()
1969 RS_DEBUG->print("ApplicationWindow::slotFileOpen()");
1971 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 001");
1972 RS2::FormatType type = RS2::FormatUnknown;
1973 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 002");
1974 QString fileName = QG_FileDialog::getOpenFileName(this, &type);
1975 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 003");
1976 slotFileOpen(fileName, type);
1977 RS_DEBUG->print("ApplicationWindow::slotFileOpen(): OK");
1981 * Called when a recently opened file is chosen from the list in the
1984 void ApplicationWindow::slotFileOpenRecent(void)
1987 RS_DEBUG->print("ApplicationWindow::slotFileOpenRecent()");
1989 statusBar()->showMessage(tr("Opening recent file..."));
1990 QString fileName = recentFiles->get(id);
1992 if (fileName.endsWith(" (DXF 1)"))
1993 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
1995 slotFileOpen(fileName, RS2::FormatUnknown);
1997 statusBar()->showMessage(tr("Opening recent file..."));
1999 QAction * action = qobject_cast<QAction *>(sender());
2004 QString fileName = action->data().toString();
2006 if (fileName.endsWith(" (DXF 1)"))
2007 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
2009 slotFileOpen(fileName, RS2::FormatUnknown);
2014 * Menu file -> open.
2016 void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType type)
2018 RS_DEBUG->print("ApplicationWindow::slotFileOpen(..)");
2020 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2022 if (!fileName.isEmpty())
2024 RS_DEBUG->print("ApplicationWindow::slotFileOpen: creating new doc window");
2025 // Create new document window:
2026 MDIWindow * w = slotFileNew();
2027 // RS_APP->processEvents(1000);
2028 //Really, is this needed???
2029 // RS_APP->processEvents(QEventLoop::AllEvents, 1000);
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());
2043 RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file");
2045 // RS_APP->processEvents(1000);
2046 //We no longer try to do Qt better than the Qt folks...
2047 // RS_APP->processEvents(QEventLoop::AllEvents, 1000);
2049 // open the file in the new view:
2050 if (w->slotFileOpen(fileName, type) == false)
2053 QApplication::restoreOverrideCursor();
2054 QMessageBox::information(this, QMessageBox::tr("Warning"),
2055 tr("Cannot open the file\n%1\nPlease check the permissions.") .arg(fileName), QMessageBox::Ok);
2056 w->setForceClosing(true);
2061 RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file: OK");
2062 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 1");
2064 // update recent files menu:
2065 if (type == RS2::FormatDXF1)
2066 recentFiles->add(fileName + " (DXF 1)");
2068 recentFiles->add(fileName);
2070 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 2");
2071 // updateRecentFilesMenu();
2072 recentFiles->UpdateGUI();
2074 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: OK");
2076 RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption");
2078 // w->setCaption(fileName);
2079 w->setWindowTitle(fileName);
2080 RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption: OK");
2082 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget");
2083 // update coordinate widget format:
2084 RS_DIALOGFACTORY->updateCoordinateWidget(Vector(0.0, 0.0), Vector(0.0, 0.0), true);
2085 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget: OK");
2087 // show output of filter (if any):
2088 // commandWidget->processStderr();
2089 QString message = tr("Loaded document: ") + fileName;
2090 commandWidget->appendHistory(message);
2091 statusBar()->showMessage(message, 2000);
2095 statusBar()->showMessage(tr("Opening aborted"), 2000);
2098 QApplication::restoreOverrideCursor();
2099 RS_DEBUG->print("ApplicationWindow::slotFileOpen(..) OK");
2103 * Menu file -> save.
2105 void ApplicationWindow::slotFileSave()
2107 RS_DEBUG->print("ApplicationWindow::slotFileSave()");
2109 statusBar()->showMessage(tr("Saving drawing..."));
2111 MDIWindow * w = getMDIWindow();
2116 if (w->getDocument()->getFilename().isEmpty())
2122 if (w->slotFileSave(cancelled))
2126 name = w->getDocument()->getFilename();
2127 statusBar()->showMessage(tr("Saved drawing: %1").arg(name), 2000);
2133 QMessageBox::information(this, QMessageBox::tr("Warning"),
2134 tr("Cannot save the file\n%1\nPlease check the permissions.")
2135 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2142 * Menu file -> save as.
2144 void ApplicationWindow::slotFileSaveAs()
2146 RS_DEBUG->print("ApplicationWindow::slotFileSaveAs()");
2148 statusBar()->showMessage(tr("Saving drawing under new filename..."));
2150 MDIWindow * w = getMDIWindow();
2157 if (w->slotFileSaveAs(cancelled))
2161 name = w->getDocument()->getFilename();
2162 recentFiles->add(name);
2163 w->setWindowTitle(name);
2169 QMessageBox::information(this, QMessageBox::tr("Warning"),
2170 tr("Cannot save the file\n%1\nPlease check the permissions.")
2171 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2175 // updateRecentFilesMenu();
2176 recentFiles->UpdateGUI();
2178 QString message = tr("Saved drawing: %1").arg(name);
2179 statusBar()->showMessage(message, 2000);
2180 commandWidget->appendHistory(message);
2184 * Menu file -> export.
2186 void ApplicationWindow::slotFileExport()
2188 RS_DEBUG->print("ApplicationWindow::slotFileExport()");
2190 statusBar()->showMessage(tr("Exporting drawing..."));
2192 MDIWindow * w = getMDIWindow();
2197 // read default settings:
2198 settings.beginGroup("Paths");
2199 QString defDir = settings.value("ExportImage", RS_SYSTEM->getHomeDir()).toString();
2200 QString defFilter = settings.value("ExportImageFilter", "Portable Network Graphic (*.png)").toString();
2201 settings.endGroup();
2203 bool cancel = false;
2205 // Q3FileDialog fileDlg(NULL, "", true);
2206 QFileDialog fileDlg(NULL, "", "", "");
2208 #warning "Need to port to Qt4... !!! FIX !!!"
2210 Q3StrList f = QImageIO::outputFormats();
2211 QStringList formats = QStringList::fromStrList(f);
2212 QStringList filters;
2215 for (QStringList::Iterator it = formats.begin();
2216 it!=formats.end(); ++it)
2221 st = QString("%1 (*.%2 *.jpg)")
2222 .arg(QG_DialogFactory::extToFormat(*it))
2223 .arg(QString(*it).lower());
2227 st = QString("%1 (*.%2)")
2228 .arg(QG_DialogFactory::extToFormat(*it))
2229 .arg(QString(*it).lower());
2234 //if (!all.isEmpty()) {
2237 //all += QString("*.%1").arg(QString(*it).lower());
2240 QStringList filters;
2243 fileDlg.setFilters(filters);
2244 // fileDlg.setMode(Q3FileDialog::AnyFile);
2245 fileDlg.setFileMode(QFileDialog::AnyFile);
2246 // fileDlg.setCaption(QObject::tr("Export Image"));
2247 fileDlg.setWindowTitle(QObject::tr("Export Image"));
2248 // fileDlg.setDir(defDir);
2249 fileDlg.setDirectory(defDir);
2250 fileDlg.selectNameFilter(defFilter);
2252 if (fileDlg.exec() == QDialog::Accepted)
2254 // fn = fileDlg.selectedFile();
2255 QStringList files = fileDlg.selectedFiles();
2257 if (!files.isEmpty())
2265 // store new default settings:
2268 settings.beginGroup("Paths");
2269 // settings.writeEntry("/ExportImage", QFileInfo(fn).dirPath(true));
2270 settings.setValue("ExportImage", QFileInfo(fn).absolutePath());
2271 settings.setValue("ExportImageFilter", fileDlg.selectedFilter());
2272 settings.endGroup();
2274 // find out extension:
2275 QString filter = fileDlg.selectedFilter();
2276 QString format = "";
2277 // int i = filter.find("(*.");
2278 int i = filter.indexOf("(*.");
2282 // int i2 = filter.find(QRegExp("[) ]"), i);
2283 int i2 = filter.indexOf(QRegExp("[) ]"), i);
2284 format = filter.mid(i + 3, i2 - (i + 3));
2285 format = format.toUpper();
2288 // append extension to file:
2289 if (!QFileInfo(fn).fileName().contains("."))
2290 fn.append("." + format.toLower());
2292 // show options dialog:
2293 ImageOptionsDialog dlg(this);
2294 dlg.setGraphicSize(w->getGraphic()->getSize());
2298 bool ret = slotFileExport(fn, format, dlg.getSize(), dlg.isBackgroundBlack());
2302 QString message = tr("Exported: %1").arg(fn);
2303 statusBar()->showMessage(message, 2000);
2304 commandWidget->appendHistory(message);
2312 * Exports the drawing as a bitmap.
2314 * @param name File name.
2315 * @param format File format (e.g. "png")
2316 * @param size Size of the bitmap in pixel
2317 * @param black true: Black background, false: white
2318 * @param bw true: black/white export, false: color
2320 bool ApplicationWindow::slotFileExport(const QString & name, const QString & format, QSize size, bool black, bool bw)
2322 MDIWindow * w = getMDIWindow();
2326 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no window opened");
2330 Drawing * graphic = w->getDocument()->getGraphic();
2332 if (graphic == NULL)
2334 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no graphic");
2338 statusBar()->showMessage(tr("Exporting..."));
2339 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2342 QPixmap * buffer = new QPixmap(size);
2343 // RS_PainterQt * painter = new RS_PainterQt(buffer);
2344 QPainter qpntr(buffer);
2345 PaintInterface * painter = new PaintInterface(&qpntr);
2347 // black background:
2349 // painter->setBackgroundColor(RS_Color(0, 0, 0));
2350 // qpntr.setBackgroundColor(RS_Color(0, 0, 0));
2351 qpntr.setBackground(QBrush(QColor(0, 0, 0)));
2352 // white background:
2354 // painter->setBackgroundColor(RS_Color(255, 255, 255));
2355 // qpntr.setBackgroundColor(RS_Color(255, 255, 255));
2356 qpntr.setBackground(QBrush(QColor(255, 255, 255)));
2360 painter->setDrawingMode(RS2::ModeBW);
2362 // painter->eraseRect(0, 0, size.width(), size.height());
2363 qpntr.eraseRect(0, 0, size.width(), size.height());
2365 RS_StaticGraphicView gv(size.width(), size.height(), painter);
2368 gv.setBackground(RS_Color(0, 0, 0));
2370 gv.setBackground(RS_Color(255, 255, 255));
2372 gv.setContainer(graphic);
2374 gv.drawEntity(graphic, true);
2381 iio.setFileName(name);
2382 iio.setFormat(format);
2389 #warning "Need to port to Qt4... !!! FIX !!!"
2392 QApplication::restoreOverrideCursor();
2394 // GraphicView deletes painter
2401 statusBar()->showMessage(tr("Export complete"), 2000);
2403 statusBar()->showMessage(tr("Export failed!"), 2000);
2409 * Menu file -> close.
2411 void ApplicationWindow::slotFileClose()
2413 RS_DEBUG->print("ApplicationWindow::slotFileClose()");
2415 MDIWindow * m = getMDIWindow();
2424 //m->showMaximized();
2425 m->setWindowState(WindowMaximized);
2431 * Called when a MDI window is actually about to close. Used to
2432 * detach widgets from the document.
2434 void ApplicationWindow::slotFileClosing()
2436 RS_DEBUG->print("ApplicationWindow::slotFileClosing()");
2438 RS_DEBUG->print("detaching lists");
2439 layerWidget->setLayerList(NULL, false);
2440 blockWidget->setBlockList(NULL);
2441 coordinateWidget->setGraphic(NULL);
2443 simulationControls->setGraphicView(NULL);
2448 * Menu file -> print.
2450 void ApplicationWindow::slotFilePrint()
2452 RS_DEBUG->print("ApplicationWindow::slotFilePrint()");
2454 MDIWindow * w = getMDIWindow();
2458 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no window opened");
2462 Drawing * graphic = w->getDocument()->getGraphic();
2464 if (graphic == NULL)
2466 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no graphic");
2470 statusBar()->showMessage(tr("Printing..."));
2471 QPrinter * printer = new QPrinter(QPrinter::HighResolution);
2472 bool landscape = false;
2473 printer->setPageSize(RS2::rsToQtPaperFormat(graphic->getPaperFormat(&landscape)));
2476 printer->setOrientation(QPrinter::Landscape);
2478 printer->setOrientation(QPrinter::Portrait);
2480 settings.beginGroup("Print");
2481 printer->setOutputFileName(settings.value("FileName", "").toString());
2482 printer->setColorMode((QPrinter::ColorMode)settings.value("/ColorMode", (int)QPrinter::Color).toInt());
2483 #warning "!!! Need to port QPrinter::setOutputToFile() to Qt4 !!!"
2484 // printer->setOutputToFile((bool)RS_SETTINGS->readNumEntry("/PrintToFile", 0));
2485 settings.endGroup();
2488 // if (printer->setup(this))
2489 QPrintDialog dialog(printer, this);
2492 //printer->setOutputToFile(true);
2493 //printer->setOutputFileName(outputFile);
2495 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2496 printer->setFullPage(true);
2497 //Can call these functions directly from the QPaintDevice...
2498 // Q3PaintDeviceMetrics metr(printer);
2500 // RS_PainterQt * painter = new RS_PainterQt(printer);
2501 QPainter qpntr(printer);
2502 PaintInterface * painter = new PaintInterface(&qpntr);
2503 painter->setDrawingMode(w->getGraphicView()->getDrawingMode());
2505 // RS_StaticGraphicView gv(metr.width(), metr.height(), painter);
2506 RS_StaticGraphicView gv(printer->width(), printer->height(), painter);
2507 gv.setPrinting(true);
2508 gv.setBorders(0, 0, 0, 0);
2510 // double fx = (double)metr.width() / metr.widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2511 // double fy = (double)metr.height() / metr.heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2512 double fx = (double)printer->width() / printer->widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2513 double fy = (double)printer->height() / printer->heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2514 double f = (fx + fy) / 2;
2515 double scale = graphic->getPaperScale();
2517 gv.setOffset((int)(graphic->getPaperInsertionBase().x * f),
2518 (int)(graphic->getPaperInsertionBase().y * f));
2519 gv.setFactor(f * scale);
2520 gv.setContainer(graphic);
2521 gv.drawEntity(graphic, true);
2523 // GraphicView deletes painter
2528 settings.beginGroup("Print");
2529 #warning "!!! Need to port QPrinter::outputToFile() to Qt4 !!!"
2530 // settings.writeEntry("/PrintToFile", (int)printer->outputToFile());
2531 settings.setValue("ColorMode", (int)printer->colorMode());
2532 settings.setValue("FileName", printer->outputFileName());
2533 settings.endGroup();
2534 QApplication::restoreOverrideCursor();
2539 statusBar()->showMessage(tr("Printing complete"), 2000);
2543 * Menu file -> print preview.
2545 void ApplicationWindow::slotFilePrintPreview(bool on)
2547 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview()");
2549 RS_DEBUG->print(" creating MDI window");
2550 MDIWindow * parent = getMDIWindow();
2554 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrintPreview: no window opened");
2558 // close print preview:
2561 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): off");
2563 if (parent->getGraphicView()->isPrintPreview())
2565 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): close");
2569 // open print preview:
2572 // look for an existing print preview:
2573 MDIWindow * ppv = parent->getPrintPreview();
2577 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): show existing");
2578 slotWindowActivated(ppv);
2583 if (!parent->getGraphicView()->isPrintPreview())
2585 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): create");
2587 MDIWindow * w = new MDIWindow(parent->getDocument(), workspace, 0, Qt::SubWindow);
2588 w->setAttribute(Qt::WA_DeleteOnClose);
2589 parent->addChildWindow(w);
2590 //connect(w, SIGNAL(signalClosing()),
2591 // this, SLOT(slotFileClosing()));
2593 // w->setCaption(tr("Print preview for %1").arg(parent->caption()));
2594 w->setWindowTitle(tr("Print preview for %1").arg(parent->windowTitle()));
2595 // w->setIcon(qPixmapFromMimeSource("document.png"));
2596 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
2597 w->setWindowIcon(QIcon(":/res/document.png"));
2598 w->getGraphicView()->setPrintPreview(true);
2599 w->getGraphicView()->setBackground(RS_Color(255, 255, 255));
2600 w->getGraphicView()->setDefaultAction(new ActionPrintPreview(*w->getDocument(), *w->getGraphicView()));
2602 // only graphics offer block lists, blocks don't
2603 RS_DEBUG->print(" adding listeners");
2604 Drawing * graphic = w->getDocument()->getGraphic();
2606 if (graphic != NULL)
2608 // Link the layer list to the pen tool bar
2609 graphic->addLayerListListener(penToolBar);
2610 // Link the layer list to the layer widget
2611 graphic->addLayerListListener(layerWidget);
2612 // Link the block list to the block widget
2613 graphic->addBlockListListener(blockWidget);
2614 // Center by default:
2615 graphic->centerToPage();
2618 // Link the graphic view to the mouse widget:
2619 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
2620 // Link the graphic view to the coordinate widget:
2621 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
2622 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
2623 // Link the graphic view to the option widget:
2624 //QG_DIALOGFACTORY->setOptionWidget(optionWidget);
2625 // Link the graphic view to the cad tool bar:
2626 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
2627 // Link the graphic view to the command widget:
2628 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
2630 RS_DEBUG->print(" showing MDI window");
2632 if (workspace->subWindowList().isEmpty())
2637 w->getGraphicView()->zoomPage();
2640 slotWindowActivated(w);
2647 * Menu file -> quit.
2649 void ApplicationWindow::slotFileQuit()
2651 RS_DEBUG->print("ApplicationWindow::slotFileQuit()");
2653 statusBar()->showMessage(tr("Exiting application..."));
2655 if (queryExit(false))
2660 * Forces termination of QCad (demo version).
2662 void ApplicationWindow::slotFileDemoQuit()
2664 statusBar()->showMessage(tr("Exiting application..."));
2671 * Shows / hides the grid.
2673 * @param toggle true: show, false: hide.
2675 void ApplicationWindow::slotViewGrid(bool toggle)
2677 RS_DEBUG->print("ApplicationWindow::slotViewGrid()");
2679 MDIWindow * m = getMDIWindow();
2683 Drawing * g = m->getGraphic();
2686 g->setGridOn(toggle);
2692 RS_DEBUG->print("ApplicationWindow::slotViewGrid() OK");
2696 * Enables / disables the draft mode.
2698 * @param toggle true: enable, false: disable.
2700 void ApplicationWindow::slotViewDraft(bool toggle)
2702 RS_DEBUG->print("ApplicationWindow::slotViewDraft()");
2704 /*MDIWindow* m = getMDIWindow();
2706 Drawing* g = m->getGraphic();
2708 g->setDraftOn(toggle);
2712 settings.beginGroup("Appearance");
2713 settings.setValue("DraftMode", toggle);
2714 settings.endGroup();
2720 * Redraws all mdi windows.
2722 void ApplicationWindow::redrawAll()
2726 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2728 for(int i=0; i<int(windows.count()); ++i)
2730 MDIWindow * m = (MDIWindow *)windows.at(i);
2734 QG_GraphicView * gv = m->getGraphicView();
2744 * Updates all grids of all graphic views.
2746 void ApplicationWindow::updateGrids()
2750 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2752 for(int i=0; i<int(windows.count()); ++i)
2754 MDIWindow * m = (MDIWindow *)windows.at(i);
2758 QG_GraphicView * gv = m->getGraphicView();
2768 * Shows / hides the status bar.
2770 * @param showSB true: show, false: hide.
2772 void ApplicationWindow::slotViewStatusBar(bool showSB)
2774 RS_DEBUG->print("ApplicationWindow::slotViewStatusBar()");
2777 statusBar()->show();
2779 statusBar()->hide();
2783 * Shows / hides the layer list.
2785 * @param toggle true: show, false: hide.
2787 /*void ApplicationWindow::slotViewLayerList(bool toggle) {
2788 RS_DEBUG->print("ApplicationWindow::slotViewLayerList()");
2790 if (toggle==false) {
2791 layerDockWindow->hide();
2793 layerDockWindow->show();
2799 * Shows / hides the block list.
2801 * @param toggle true: show, false: hide.
2804 void ApplicationWindow::slotViewBlockList(bool toggle) {
2805 RS_DEBUG->print("ApplicationWindow::slotViewBlockList()");
2807 if (toggle==false) {
2808 blockDockWindow->hide();
2810 blockDockWindow->show();
2816 * Shows / hides the command line.
2818 * @param toggle true: show, false: hide.
2821 void ApplicationWindow::slotViewCommandLine(bool toggle) {
2822 RS_DEBUG->print("ApplicationWindow::slotViewCommandLine()");
2824 if (toggle==false) {
2825 commandDockWindow->hide();
2826 //QG_GraphicView* graphicView = getGraphicView();
2827 //if (graphicView!=NULL) {
2828 //graphicView->setFocus();
2832 commandDockWindow->show();
2838 * Shows / hides the option toolbar.
2840 * @param toggle true: show, false: hide.
2843 void ApplicationWindow::slotViewOptionToolbar(bool toggle) {
2844 RS_DEBUG->print("ApplicationWindow::slotViewOptionToolbar()");
2846 if (toggle==false) {
2847 optionWidget->hide();
2849 optionWidget->show();
2855 * Creates a new MDI window for editing the selected block.
2858 void ApplicationWindow::slotBlocksEdit() {
2859 RS_DEBUG->print("ApplicationWindow::slotBlocksEdit()");
2861 MDIWindow* parent = getMDIWindow();
2863 RS_BlockList* blist = blockWidget->getBlockList();
2865 RS_Block* blk = blist->getActiveBlock();
2867 MDIWindow* w = slotFileNew(blk);
2868 // the parent needs a pointer to the block window and
2870 parent->addChildWindow(w);
2871 w->getGraphicView()->zoomAuto();
2879 * Shows the dialog for general application preferences.
2881 void ApplicationWindow::slotOptionsGeneral()
2883 RS_DIALOGFACTORY->requestOptionsGeneralDialog();
2885 // update background color of all open drawings:
2886 settings.beginGroup("Appearance");
2887 QColor color(settings.value("BackgroundColor", "#000000").toString());
2888 QColor gridColor(settings.value("GridColor", "Gray").toString());
2889 QColor metaGridColor(settings.value("MetaGridColor", "Darkgray").toString());
2890 QColor selectedColor(settings.value("SelectedColor", "#A54747").toString());
2891 QColor highlightedColor(settings.value("HighlightedColor", "#739373").toString());
2892 settings.endGroup();
2894 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2896 for(int i=0; i<int(windows.count()); ++i)
2898 MDIWindow * m = (MDIWindow *)windows.at(i);
2902 QG_GraphicView * gv = m->getGraphicView();
2906 gv->setBackground(color);
2907 gv->setGridColor(gridColor);
2908 gv->setMetaGridColor(metaGridColor);
2909 gv->setSelectedColor(selectedColor);
2910 gv->setHighlightedColor(highlightedColor);
2919 * Menu script -> show ide
2921 void ApplicationWindow::slotScriptOpenIDE()
2924 scripter->openIDE();
2929 * Menu script -> run
2931 void ApplicationWindow::slotScriptRun()
2934 scripter->runScript();
2939 * Menu help -> about.
2941 void ApplicationWindow::slotHelpAbout()
2943 RS_DEBUG->print("ApplicationWindow::slotHelpAbout()");
2944 QStringList modules;
2951 modules += "Scripting";
2954 QString modulesString;
2956 if (modules.empty() == false)
2957 modulesString = modules.join(", ");
2959 modulesString = tr("None");
2961 QMessageBox box(this);
2962 box.setWindowTitle(tr("About..."));
2963 box.setText(QString("<qt>") + // no center for main stream QCad
2964 #ifdef QC_ABOUT_HEADER
2965 QString("<center>") +
2966 QString(QC_ABOUT_HEADER) +
2968 //FAIL "<h2>"+ QC_APPNAME+ "</h2>" +
2969 "<h2>Architektonas</h2>" +
2971 tr("Version: %1").arg("1.0.0") + "<br>" +
2972 tr("Date: %1").arg(__DATE__) + "<br>" +
2973 QString("© 2010 Underground Software,<br>James Hammons") +
2975 #ifdef QC_ABOUT_ADD_COMPANY
2976 + QString("<br>") + QC_ABOUT_ADD_COMPANY
2978 + QString("</center>")
2980 #ifndef QC_ABOUT_HEADER
2981 #warning "Failure..."
2982 // box.setIcon(qPixmapFromMimeSource(QC_APP_ICON));
2983 box.setFixedWidth(340);
2984 box.setFixedHeight(250);
2990 * Menu help -> help.
2992 void ApplicationWindow::slotHelpManual()
2994 #warning "No help system ported to Qt4... !!! FIX !!!"
2996 RS_DEBUG->print("ApplicationWindow::slotHelpManual()");
2998 if (assistant == NULL)
3000 RS_DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
3001 RS_DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
3002 assistant = new QAssistantClient(RS_SYSTEM->getAppDir()+"/bin", this);
3003 connect(assistant, SIGNAL(error(const QString&)), this, SLOT(slotError(const QString&)));
3006 args << QDir::convertSeparators(RS_SYSTEM->getDocPath() + "/qcaddoc.adp");
3007 // args << QString("doc") + QDir::separator() + QString("qcaddoc.adp");
3009 #if QT_VERSION>=0x030200
3010 assistant->setArguments(args);
3013 assistant->openAssistant();
3014 //assistant->showPage("index.html");
3021 void ApplicationWindow::slotTestDumpEntities(RS_EntityContainer * d)
3023 RS_DEBUG->print("ApplicationWindow::slotTestDumpEntities()");
3024 static int level = 0;
3025 std::ofstream dumpFile;
3030 dumpFile.open("debug_entities.html");
3035 dumpFile.open("debug_entities.html", std::ios::app);
3043 dumpFile << "<html>\n";
3044 dumpFile << "<body>\n";
3047 for (RS_Entity* e=d->firstEntity();
3052 dumpFile << "<table border=\"1\">\n";
3053 dumpFile << "<tr><td>Entity: " << e->getId()
3057 << "<tr><td><table><tr>"
3058 << "<td>VIS:" << e->isVisible() << "</td>"
3059 << "<td>UND:" << e->isUndone() << "</td>"
3060 << "<td>SEL:" << e->isSelected() << "</td>"
3061 << "<td>TMP:" << e->getFlag(RS2::FlagTemp) << "</td>";
3062 QString lay = "NULL";
3063 if (e->getLayer()!=NULL) {
3064 lay = e->getLayer()->getName();
3067 //fail << "<td>Layer: " << lay << "</td>"
3068 << "<td>Width: " << (int)e->getPen(false).getWidth() << "</td>"
3069 << "<td>Parent: " << e->getParent()->getId() << "</td>"
3077 case RS2::EntityPoint:
3079 RS_Point* p = (RS_Point*)e;
3081 << "<table><tr><td>"
3093 case RS2::EntityLine:
3095 RS_Line* l = (RS_Line*)e;
3097 << "<table><tr><td>"
3103 << l->getStartpoint()
3112 case RS2::EntityArc: {
3113 RS_Arc* a = (RS_Arc*)e;
3115 << "<table><tr><td>"
3132 << "<td>Startpoint: "
3133 << a->getStartpoint()
3139 << (int)a->isReversed()
3145 case RS2::EntityCircle: {
3146 RS_Circle* c = (RS_Circle*)e;
3148 << "<table><tr><td>"
3163 case RS2::EntityDimAligned: {
3164 RS_DimAligned* d = (RS_DimAligned*)e;
3166 << "<table><tr><td>"
3167 << "<b>Dimension / Aligned:</b>"
3172 << d->getDefinitionPoint()
3175 << d->getExtensionPoint1()
3178 << d->getExtensionPoint2()
3181 << d->getText().toLatin1().data()
3184 << d->getLabel().toLatin1().data()
3190 case RS2::EntityDimLinear:
3192 RS_DimLinear* d = (RS_DimLinear*)e;
3194 << "<table><tr><td>"
3195 << "<b>Dimension / Linear:</b>"
3200 << d->getDefinitionPoint()
3203 << d->getExtensionPoint1()
3206 << d->getExtensionPoint2()
3209 //fail << d->getText()
3212 //fail << d->getLabel()
3218 case RS2::EntityInsert: {
3219 RS_Insert* i = (RS_Insert*)e;
3221 << "<table><tr><td>"
3226 << "<td>Insertion point:"
3227 << i->getInsertionPoint()
3233 case RS2::EntityText: {
3234 RS_Text* t = (RS_Text*)e;
3236 << "<table><tr><td>"
3242 << t->getText().toLatin1().data()
3251 case RS2::EntityHatch: {
3252 RS_Hatch* h = (RS_Hatch*)e;
3254 << "<table><tr><td>"
3260 << h->getPattern().toLatin1().data()
3266 << (int)h->isSolid()
3275 << "<b>Unknown Entity: " << e->rtti() << "</b>"
3280 if (e->isContainer() || e->rtti()==RS2::EntityHatch) {
3281 RS_EntityContainer* ec = (RS_EntityContainer*)e;
3282 dumpFile << "<table><tr><td valign=\"top\"> Contents:</td><td>\n";
3284 slotTestDumpEntities(ec);
3285 dumpFile.open("debug_entities.html", std::ios::app);
3286 dumpFile << "</td></tr></table>\n";
3296 dumpFile << "</body>\n";
3297 dumpFile << "</html>\n";
3307 void ApplicationWindow::slotTestDumpUndo()
3309 RS_DEBUG->print("ApplicationWindow::slotTestDumpUndo()");
3311 RS_Document * d = getDocument();
3315 std::cout << *(RS_Undo*)d;
3316 std::cout << std::endl;
3323 void ApplicationWindow::slotTestUpdateInserts()
3325 RS_DEBUG->print("ApplicationWindow::slotTestUpdateInserts()");
3327 RS_Document * d = getDocument();
3336 void ApplicationWindow::slotTestDrawFreehand()
3338 RS_DEBUG->print("ApplicationWindow::slotTestDrawFreehand()");
3340 //Drawing* g = document->getMarking();
3343 ActionDrawLineFree* action =
3344 new ActionDrawLineFree(*document->getGraphic(),
3347 for (int i=0; i<100; ++i) {
3349 int posx = (random()%600);
3350 int posy = (random()%400);
3352 //RS_MouseEvent rsm1(posx, posy, LEFT);
3353 RS_MouseEvent rsm1(QEvent::MouseButtonPress,
3357 action->mousePressEvent(&rsm1);
3362 for (int k=0; k<100; ++k) {
3363 int accx = (random()%40)-20;
3364 int accy = (random()%40)-20;
3372 //RS_MouseEvent rsm2(posx, posy, LEFT);
3374 RS_MouseEvent rsm2(QEvent::MouseMove,
3378 action->mouseMoveEvent(&rsm2);
3381 action->mouseReleaseEvent(NULL);
3393 void ApplicationWindow::slotTestInsertBlock()
3395 RS_DEBUG->print("ApplicationWindow::slotTestInsertBlock()");
3397 RS_Document * d = getDocument();
3399 if (d != NULL && d->rtti() == RS2::EntityGraphic)
3401 Drawing * graphic = (Drawing *)d;
3403 if (graphic == NULL)
3406 graphic->addLayer(new RS_Layer("default"));
3407 RS_Block * block = new RS_Block(graphic, RS_BlockData("debugblock", Vector(0.0, 0.0), true));
3413 // Add one red line:
3414 line = new RS_Line(block, RS_LineData(Vector(0.0, 0.0), Vector(50.0, 0.0)));
3415 line->setLayerToActive();
3416 line->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3417 block->addEntity(line);
3419 // Add one line with attributes from block:
3420 line = new RS_Line(block, RS_LineData(Vector(50.0, 0.0), Vector(50.0, 50.0)));
3421 line->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3422 block->addEntity(line);
3424 // Add one arc with attributes from block:
3425 RS_ArcData d(Vector(50.0, 0.0), 50.0, M_PI / 2.0, M_PI, false);
3426 arc = new RS_Arc(block, d);
3427 arc->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3428 block->addEntity(arc);
3430 // Add one blue circle:
3431 RS_CircleData circleData(Vector(20.0, 15.0), 12.5);
3432 circle = new RS_Circle(block, circleData);
3433 circle->setLayerToActive();
3434 circle->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width01, RS2::SolidLine));
3435 block->addEntity(circle);
3437 graphic->addBlock(block);
3440 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);
3442 // insert one magenta instance of the block (original):
3443 ins = new RS_Insert(graphic, insData);
3444 ins->setLayerToActive();
3445 ins->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width02, RS2::SolidLine));
3447 graphic->addEntity(ins);
3449 // insert one green instance of the block (rotate):
3450 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);
3451 ins = new RS_Insert(graphic, insData);
3452 ins->setLayerToActive();
3453 ins->setPen(RS_Pen(RS_Color(0, 255, 0), RS2::Width02, RS2::SolidLine));
3455 graphic->addEntity(ins);
3457 // insert one cyan instance of the block (move):
3458 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);
3459 ins = new RS_Insert(graphic, insData);
3460 ins->setLayerToActive();
3461 ins->setPen(RS_Pen(RS_Color(0, 255, 255), RS2::Width02, RS2::SolidLine));
3463 graphic->addEntity(ins);
3465 // insert one blue instance of the block:
3466 for(double a=0.0; a<360.0; a+=45.0)
3468 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);
3469 ins = new RS_Insert(graphic, insData);
3470 ins->setLayerToActive();
3471 ins->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width05, RS2::SolidLine));
3473 graphic->addEntity(ins);
3476 // insert an array of yellow instances of the block:
3477 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);
3478 ins = new RS_Insert(graphic, insData);
3479 ins->setLayerToActive();
3480 ins->setPen(RS_Pen(RS_Color(255, 255, 0), RS2::Width01, RS2::SolidLine));
3482 graphic->addEntity(ins);
3484 GraphicView * v = getGraphicView();
3494 void ApplicationWindow::slotTestInsertEllipse()
3496 RS_DEBUG->print("ApplicationWindow::slotTestInsertEllipse()");
3498 RS_Document * d = getDocument();
3502 Drawing * graphic = (Drawing *)d;
3504 if (graphic == NULL)
3507 RS_Ellipse * ellipse;
3510 for (double a=0.0; a<2*M_PI; a+=0.1)
3513 v.setPolar(50.0, a);
3514 double xp = 1000.0*a;
3516 RS_EllipseData ellipseData(Vector(xp, 0.0), v, 0.5, 0.0, 2 * M_PI, false);
3517 ellipse = new RS_Ellipse(graphic, ellipseData);
3519 ellipse->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width01, RS2::SolidLine));
3521 graphic->addEntity(ellipse);
3522 //graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3523 //graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3525 line = new RS_Line(graphic, RS_LineData(Vector(xp, 0.0), Vector(xp, 0.0) + v));
3526 line->setPen(RS_Pen(RS_Color(128, 128, 128), RS2::Width01, RS2::SolidLine));
3527 graphic->addEntity(line);
3530 for (double mx=-60.0; mx<60.0; mx+=1.0) {
3531 //for (double mx=0.0; mx<1.0; mx+=2.5) {
3532 VectorSolutions sol = ellipse->mapX(xp + mx);
3533 //graphic->addEntity(new RS_Point(graphic,
3534 // sol.vector2 + Vector(a*500.0, 0.0)));
3535 //graphic->addEntity(new RS_Point(graphic,
3536 // sol.vector3 + Vector(a*500.0, 0.0)));
3537 //graphic->addEntity(new RS_Point(graphic,
3538 // sol.vector4 + Vector(a*500.0, 0.0)));
3540 line = new RS_Line(graphic,
3541 RS_LineData(Vector(xp+mx,-50.0),
3542 Vector(xp+mx,50.0)));
3543 line->setPen(RS_Pen(RS_Color(60, 60, 60),
3546 graphic->addEntity(line);
3548 graphic->addEntity(new RS_Point(graphic,
3554 // different minor/minor relations
3557 for (y=-250.0; y<=250.0; y+=50.0) {
3558 for (x=-250.0; x<=250.0; x+=50.0) {
3561 ellipse = new RS_Ellipse(graphic,
3563 Vector((x/5+50.0)/2.0, 0.0),
3568 ellipse->setPen(RS_Pen(RS_Color(255, 255, 0),
3572 graphic->addEntity(ellipse);
3573 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3574 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3576 ellipse = new RS_Ellipse(graphic,
3577 v + Vector(750.0, 0.0),
3578 Vector((x/5+50.0)/2.0, 0.0),
3583 graphic->addEntity(ellipse);
3584 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3585 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3591 // different rotation angles:
3593 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3594 ellipse = new RS_Ellipse(graphic,
3595 Vector(rot*200, 500.0),
3596 Vector(50.0, 0.0).rotate(rot),
3600 graphic->addEntity(ellipse);
3601 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3602 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3606 // different arc angles:
3608 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3609 for (a1=0.0; a1<=2*M_PI+0.1; a1+=(M_PI/8)) {
3610 for (a2=a1+M_PI/8; a2<=2*M_PI+a1+0.1; a2+=(M_PI/8)) {
3611 ellipse = new RS_Ellipse(graphic,
3612 Vector(-500.0-a1*200.0-5000.0*rot,
3614 Vector(50.0, 0.0).rotate(rot),
3618 graphic->addEntity(ellipse);
3619 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3620 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3626 GraphicView * v = getGraphicView();
3636 void ApplicationWindow::slotTestInsertText()
3638 RS_DEBUG->print("ApplicationWindow::slotTestInsertText()");
3640 RS_Document * d = getDocument();
3644 Drawing * graphic = (Drawing *)d;
3646 if (graphic == NULL)
3650 RS_TextData textData;
3652 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);
3653 text = new RS_Text(graphic, textData);
3654 text->setLayerToActive();
3655 text->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3656 graphic->addEntity(text);
3660 for (y=-250.0; y<=250.0; y+=50.0) {
3661 for (x=-250.0; x<=250.0; x+=50.0) {
3664 textData = RS_TextData(v,
3675 text = new RS_Text(graphic, textData);
3677 text->setLayerToActive();
3678 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3681 graphic->addEntity(text);
3686 for (x=0.0; x<M_PI*2.0; x+=0.2) {
3687 Vector v(600.0+cos(x)*50.0, 0.0+sin(x)*50.0);
3689 line = new RS_Line(graphic,
3690 RS_LineData(Vector(600.0,0.0),
3692 line->setLayerToActive();
3693 line->setPenToActive();
3694 graphic->addEntity(line);
3696 textData = RS_TextData(v,
3707 text = new RS_Text(graphic, textData);
3709 text->setLayerToActive();
3710 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3713 graphic->addEntity(text);
3716 RS_SolidData solidData = RS_SolidData(Vector(5.0, 10.0),
3718 Vector(15.0, 30.0));
3720 RS_Solid* s = new RS_Solid(graphic, solidData);
3722 s->setLayerToActive();
3723 s->setPen(RS_Pen(RS_Color(255, 255, 0),
3726 graphic->addEntity(s);
3728 GraphicView* v = getGraphicView();
3739 void ApplicationWindow::slotTestInsertImage()
3741 RS_DEBUG->print("ApplicationWindow::slotTestInsertImage()");
3743 RS_Document * d = getDocument();
3747 Drawing * graphic = (Drawing *)d;
3749 if (graphic == NULL)
3753 RS_ImageData imageData;
3755 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);
3756 image = new RS_Image(graphic, imageData);
3758 image->setLayerToActive();
3759 image->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3760 graphic->addEntity(image);
3767 void ApplicationWindow::slotTestUnicode()
3769 RS_DEBUG->print("ApplicationWindow::slotTestUnicode()");
3771 slotFileOpen("./fonts/unicode.cxf", RS2::FormatCXF);
3772 RS_Document* d = getDocument();
3774 Drawing* graphic = (Drawing*)d;
3775 if (graphic==NULL) {
3783 QChar uCode; // e.g. 65 (or 'A')
3784 QString strCode; // unicde as string e.g. '[0041] A'
3786 graphic->setAutoUpdateBorders(false);
3788 for (col=0x0000; col<=0xFFF0; col+=0x10) {
3789 printf("col: %X\n", col);
3790 for (row=0x0; row<=0xF; row++) {
3791 //printf(" row: %X\n", row);
3793 uCode = QChar(col+row);
3794 //printf(" code: %X\n", uCode.unicode());
3796 strCode.setNum(uCode.unicode(), 16);
3797 while (strCode.length()<4) {
3798 strCode="0"+strCode;
3800 strCode = "[" + strCode + "] " + uCode;
3802 if (graphic->findBlock(strCode)!=NULL) {
3803 RS_InsertData d(strCode,
3804 Vector(col/0x10*20.0,row*20.0),
3805 Vector(1.0,1.0), 0.0,
3806 1, 1, Vector(0.0, 0.0),
3807 NULL, RS2::NoUpdate);
3808 ins = new RS_Insert(graphic, d);
3809 ins->setLayerToActive();
3810 ins->setPen(RS_Pen(RS_Color(255, 255, 255),
3814 graphic->addEntity(ins);
3818 graphic->setAutoUpdateBorders(true);
3819 graphic->calculateBorders();
3826 void ApplicationWindow::slotTestMath01()
3828 RS_DEBUG->print("ApplicationWindow::slotTestMath01()");
3830 RS_Document* d = getDocument();
3832 Drawing* graphic = (Drawing*)d;
3833 if (graphic==NULL) {
3838 graphic->addEntity(new RS_Line(graphic,
3839 RS_LineData(Vector(0.0,0.0),
3840 Vector(2*M_PI,0.0))));
3841 graphic->addEntity(new RS_Line(graphic,
3842 RS_LineData(Vector(0.0,-1.0),
3847 double x = 59.0/ARAD;
3848 double x_0 = 60.0/ARAD;
3849 for (a=0.01; a<2*M_PI; a+=0.01) {
3851 RS_Line* line = new RS_Line(graphic,
3852 RS_LineData(Vector(a-0.01, cos(a-0.01)),
3853 Vector(a, cos(a))));
3854 graphic->addEntity(line);
3857 graphic->addEntity(new RS_Line(graphic,
3858 RS_LineData(Vector(a-0.01,cos(x_0)-sin(x_0)*(a-0.01-x_0)),
3859 Vector(a,cos(x_0)-sin(x_0)*(a-x_0)))));
3863 graphic->addEntity(new RS_Line(graphic,
3864 RS_LineData(Vector(x,0.0),
3868 graphic->addEntity(new RS_Line(graphic,
3869 RS_LineData(Vector(x_0,0.0),
3873 //graphic->addEntity(new RS_Line(graphic,
3874 // Vector(0.0,cos(x_0)-sin(x_0)*(0.0-x_0)),
3875 // Vector(6.0,cos(x_0)-sin(x_0)*(6.0-x_0))));
3878 GraphicView* v = getGraphicView();
3888 void ApplicationWindow::slotTestResize640()
3890 RS_DEBUG->print("ApplicationWindow::slotTestResize640()");
3898 void ApplicationWindow::slotTestResize800()
3900 RS_DEBUG->print("ApplicationWindow::slotTestResize800()");
3908 void ApplicationWindow::slotTestResize1024()
3910 RS_DEBUG->print("ApplicationWindow::slotTestResize1024()");
3916 * overloaded for Message box on last window exit.
3918 bool ApplicationWindow::queryExit(bool force)
3920 RS_DEBUG->print("ApplicationWindow::queryExit()");
3927 QMessageBox::information(this, QMessageBox::tr("Warning"),
3928 tr("This is a %1 version "
3929 "which terminates\n"
3930 "automatically after 10min. This software is\n"
3931 "not intended for production use. Please buy\n"
3932 "a full version of the application from\n%2.\n"
3933 "You can save your work now.")
3934 //FAIL .arg(QC_APPNAME)
3935 .arg("Architektonas")
3936 #ifdef QC_CUSTOM_VENDOR
3937 .arg(QC_CUSTOM_VENDOR),
3939 .arg("RibbonSoft, http://www.ribbonsoft.com"),
3944 QList<QMdiSubWindow *> list = workspace->subWindowList();
3946 // for(QWidget * w=list.first(); w!=NULL; w=list.next())
3947 for(int i=0; i<list.size(); i++)
3949 succ = ((MDIWindow *)list[i])->closeMDI(force);
3958 RS_DEBUG->print("ApplicationWindow::queryExit(): OK");
3964 * Handle hotkeys. Don't let it to the default handler of Qt.
3965 * it will consume them also if a text field is active
3966 * which means it's impossible to enter a command.
3968 void ApplicationWindow::keyPressEvent(QKeyEvent * e)
3970 #warning "!!! keyPressEvent(): Do we need this anymore? !!!"
3972 static QTime ts = QTime();
3973 static QString firstKey = "";
3975 // single key codes:
3979 case Qt::Key_Control:
3982 case Qt::Key_CapsLock:
3984 QMainWindow::keyPressEvent(e);
3986 // forward to actions:
3987 GraphicView * graphicView = getGraphicView();
3990 graphicView->keyPressEvent(e);
3996 case Qt::Key_Escape:
4002 case Qt::Key_Return:
4003 if (firstKey.isEmpty())
4011 if (firstKey.isEmpty())
4013 actionHandler->slotZoomIn();
4019 if (firstKey.isEmpty())
4021 actionHandler->slotZoomOut();
4031 if (e->isAccepted())
4034 QTime now = QTime::currentTime();
4037 if (ts.msecsTo(now) < 2000)
4039 QString code = QString("%1%2").arg(firstKey).arg(QChar(e->key())).toLower();
4041 if (actionHandler->keycode(code) == false)
4045 if (QChar(e->key()).isPrint())
4046 firstKey += e->key();
4055 if (QChar(e->key()).isPrint())
4056 firstKey = e->key();
4059 // Q3MainWindow::keyPressEvent(e);
4060 QMainWindow::keyPressEvent(e);
4063 void ApplicationWindow::keyReleaseEvent(QKeyEvent * e)
4068 case Qt::Key_Control:
4071 case Qt::Key_CapsLock:
4073 // Q3MainWindow::keyReleaseEvent(e);
4074 QMainWindow::keyReleaseEvent(e);
4076 // forward to actions:
4077 GraphicView * graphicView = getGraphicView();
4080 graphicView->keyReleaseEvent(e);
4087 // Q3MainWindow::keyPressEvent(e);
4088 QMainWindow::keyPressEvent(e);
4092 * @return Pointer to application window.
4094 /*static*/ ApplicationWindow * ApplicationWindow::getAppWindow()
4100 * @return Pointer to workspace.
4102 QMdiArea * ApplicationWindow::getWorkspace()
4108 * @return Pointer to the currently active MDI Window or NULL if no
4109 * MDI Window is active.
4111 MDIWindow * ApplicationWindow::getMDIWindow()
4113 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::getMDIWindow: workspace=%08X", workspace);
4117 RS_DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=%08X", workspace->activeSubWindow());
4118 return (MDIWindow *)workspace->activeSubWindow();
4121 RS_DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=??? (workspace == NULL)");
4126 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4128 * @return Pointer to the graphic view of the currently active document
4129 * window or NULL if no window is available.
4131 /*virtual*/ GraphicView * ApplicationWindow::getGraphicView()
4133 MDIWindow * m = getMDIWindow();
4135 return (m ? m->getGraphicView() : NULL);
4139 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4141 * @return Pointer to the graphic document of the currently active document
4142 * window or NULL if no window is available.
4144 /*virtual*/ RS_Document * ApplicationWindow::getDocument()
4146 MDIWindow * m = getMDIWindow();
4148 return (m ? m->getDocument() : NULL);
4152 * Creates a new document. Implementation from RS_MainWindowInterface.
4154 /*virtual*/ void ApplicationWindow::createNewDocument(const QString & fileName/*= QString::null*/,
4155 RS_Document * doc/*= NULL*/)
4159 if (fileName != QString::null && getDocument())
4160 getDocument()->setFilename(fileName);
4164 * Implementation from QG_MainWindowInterface.
4166 * @return Pointer to this.
4168 /*virtual*/ QMainWindow * ApplicationWindow::GetMainWindow()
4174 * @return Pointer to action handler. Implementation from QG_MainWindowInterface.
4176 /*virtual*/ QG_ActionHandler * ApplicationWindow::getActionHandler()
4178 return actionHandler;
4182 * Implementation from QG_MainWindowInterface.
4184 /*virtual*/ void ApplicationWindow::showSimulationControls()
4187 simulationDockWindow->show();
4193 * @return Pointer to the qsa object.
4195 QSProject * ApplicationWindow::getQSAProject()
4197 if (scripter != NULL)
4198 return scripter->getQSAProject();
4205 * Implementation from QG_MainWindowInterface.
4207 /*virtual*/ void ApplicationWindow::setFocus2()