1 // applicationwindow.cpp
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/17/2010 Added this text. :-)
15 // JLH 05/27/2010 Finished refactoring old Qt3 based action handling code to
16 // Qt4's much more sensible action handling
19 #include "applicationwindow.h"
22 #include "actiondrawlinefree.h"
23 #include "actionlibraryinsert.h"
24 #include "actionprintpreview.h"
25 #include "rs_creation.h"
26 #include "rs_dialogfactory.h"
27 #include "rs_dimaligned.h"
28 #include "rs_dimlinear.h"
29 #include "rs_dimradial.h"
30 #include "rs_ellipse.h"
31 #include "rs_fileio.h"
33 #include "rs_insert.h"
35 #include "paintinterface.h"
36 #include "rs_script.h"
37 #include "rs_scriptlist.h"
40 #include "rs_staticgraphicview.h"
41 #include "rs_system.h"
46 #include "rs_camdialog.h"
47 #include "rs_simulationcontrols.h"
51 #include "filedialog.h"
52 #include "pentoolbar.h"
53 #include "recentfiles.h"
54 #include "cadtoolbar.h"
55 #include "cadtoolbarmain.h"
56 #include "coordinatewidget.h"
57 #include "dlgimageoptions.h"
58 #include "mousewidget.h"
59 #include "selectionwidget.h"
61 #include "createqtactions.h"
62 #include "qc_dialogfactory.h"
63 #include "qg_graphicview.h"
65 #include "mdiwindow.h"
67 ApplicationWindow * ApplicationWindow::appWindow = NULL;
70 # define QC_APP_ICON "qcad.png"
73 # define QC_APP_ICON16 "qcad16.png"
76 extern QSplashScreen * splash;
79 * Constructor. Initializes the app.
81 ApplicationWindow::ApplicationWindow():
82 // Q3MainWindow(0, "", Qt::WDestructiveClose), QG_MainWindowInterface()
83 QMainWindow((QWidget *)NULL/*,this is not a Qt::WindowFlags --> Qt::WA_DeleteOnClose*/), QG_MainWindowInterface()
85 RS_DEBUG->print("ApplicationWindow::ApplicationWindow");
88 //no assistant = NULL;
91 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: setting icon");
92 // setIcon(qPixmapFromMimeSource(QC_APP_ICON));
93 // setWindowIcon(qPixmapFromMimeSource(QC_APP_ICON));
94 setWindowIcon(QIcon(":/res/" QC_APP_ICON));
95 CreateQtActions(this);
97 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler");
98 actionHandler = new ActionHandler(this);
99 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating action handler: OK");
102 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating scripter");
103 scripter = new QS_Scripter(this, this);
104 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating scripter: OK");
107 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init view");
109 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init toolbar");
111 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init actions");
113 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init menu bar");
115 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init status bar");
118 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory");
119 dialogFactory = new QC_DialogFactory(this, optionWidget);
120 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory: OK");
121 RS_DEBUG->print("setting dialog factory object");
123 if (RS_DialogFactory::instance() == NULL)
124 RS_DEBUG->print("no RS_DialogFactory instance");
126 RS_DEBUG->print("got RS_DialogFactory instance");
128 RS_DialogFactory::instance()->setFactoryObject(dialogFactory);
129 RS_DEBUG->print("setting dialog factory object: OK");
131 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init settings");
134 RS_DEBUG->print("ApplicationWindow::ApplicationWindow: init MDI");
137 // Disable menu and toolbar items
138 emit windowsChanged(FALSE);
140 //FAIL statusBar()->showMessage(QC_APPNAME " Ready", 2000);
141 statusBar()->showMessage("Architektonas Ready", 2000);
142 //setFocusPolicy(WheelFocus);
148 ApplicationWindow::~ApplicationWindow()
150 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow");
152 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting scripter");
154 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting scripter: OK");
157 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting action handler");
158 delete actionHandler;
159 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting action handler: OK");
161 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory");
162 delete dialogFactory;
163 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory: OK");
165 //no RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: "
166 // "deleting assistant..");
167 // if (assistant!=NULL) {
170 // RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: "
171 // "deleting assistant: OK");
172 RS_DEBUG->print("ApplicationWindow::~ApplicationWindow: OK");
176 * Runs the start script if scripting is available.
178 void ApplicationWindow::slotRunStartScript()
180 slotRunScript("autostart.qs");
184 * Runs a script. The action that triggers this slot has to carry the
185 * name of the script file.
187 void ApplicationWindow::slotRunScript()
189 RS_DEBUG->print("ApplicationWindow::slotRunScript");
191 const QObject * s = sender();
195 QString script = ((QAction *)s)->text();
196 RS_DEBUG->print("ApplicationWindow::slotRunScript: %s", script.toLatin1().data());
197 slotRunScript(script);
202 * Runs the script with the given name.
204 void ApplicationWindow::slotRunScript(const QString & name)
207 RS_DEBUG->print("ApplicationWindow::slotRunScript");
209 if (scripter == NULL)
211 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotRunScript: scripter not initialized");
215 statusBar()->showMessage(tr("Running script '%1'").arg(name), 2000);
217 QStringList scriptList = RS_SYSTEM->getScriptList();
218 scriptList.append(RS_SYSTEM->getHomeDir() + "/.qcad/" + name);
220 for (QStringList::Iterator it = scriptList.begin(); it!=scriptList.end(); ++it)
222 RS_DEBUG->print("ApplicationWindow::slotRunScript: checking script '%s'", (*it).toLatin1().data();
225 if (fi.exists() && fi.fileName() == name)
227 RS_DEBUG->print("ApplicationWindow::slotRunScript: running '%s'", (*it).toLatin1().data());
228 scripter->runScript(*it, "main");
235 * Called from toolbar buttons that were added by scripts to
238 void ApplicationWindow::slotInsertBlock()
240 const QObject * s = sender();
244 QString block = ((QAction *)s)->text();
245 RS_DEBUG->print("ApplicationWindow::slotInsertBlock: %s", block.toLatin1().data());
246 slotInsertBlock(block);
251 * Called to insert blocks.
253 void ApplicationWindow::slotInsertBlock(const QString & name)
255 RS_DEBUG->print("ApplicationWindow::slotInsertBlock: '%s'", name.toLatin1().data());
257 statusBar()->showMessage(tr("Inserting block '%1'").arg(name), 2000);
259 GraphicView * graphicView = getGraphicView();
260 RS_Document * document = getDocument();
262 if (graphicView && document)
264 ActionLibraryInsert * action = new ActionLibraryInsert(*document, *graphicView);
265 action->setFile(name);
266 graphicView->setCurrentAction(action);
271 * Shows the main application window and a splash screen.
273 void ApplicationWindow::show()
275 #ifdef QSPLASHSCREEN_H
282 #ifdef QSPLASHSCREEN_H
286 qApp->processEvents();
287 splash->clearMessage();
288 # ifdef QC_DELAYED_SPLASH_SCREEN
289 QTimer::singleShot(1000 * 2, this, SLOT(finishSplashScreen()));
291 finishSplashScreen();
298 * Called when the splash screen has to terminate.
300 void ApplicationWindow::finishSplashScreen()
302 #ifdef QSPLASHSCREEN_H
305 splash->finish(this);
313 * Close Event. Called when the user tries to close the app.
315 void ApplicationWindow::closeEvent(QCloseEvent * /*ce*/)
317 RS_DEBUG->print("ApplicationWindow::closeEvent()");
319 RS_DEBUG->print("ApplicationWindow::closeEvent(): OK");
323 * Handles right-clicks for moving back to the last cad tool bar.
325 void ApplicationWindow::mouseReleaseEvent(QMouseEvent * e)
327 if (e->button() == Qt::RightButton && cadToolBar != NULL)
328 cadToolBar->showToolBarMain();
334 * Initializes the MDI workspace.
336 void ApplicationWindow::initMDI()
338 RS_DEBUG->print("ApplicationWindow::initMDI() begin");
340 /* Could use QVBoxLayout instead of Q3VBox, but do we even need to? */
341 // Q3VBox * vb = new Q3VBox(this);
342 // vb->setFrameStyle(Q3Frame::StyledPanel | Q3Frame::Sunken);
343 // workspace = new QMdiArea(vb);
344 workspace = new QMdiArea(this);
345 // workspace->setScrollBarsEnabled(true);
346 // setCentralWidget(vb);
347 setCentralWidget(workspace);//JLH:hmm. (Yes, it works! \o/)
348 RS_DEBUG->print("ApplicationWindow::initMDI(): workspace=%08X", workspace);
350 //#warning "Object::connect: No such signal QMdiArea::windowActivated(QWidget *)"
351 // connect(workspace, SIGNAL(windowActivated(QWidget *)), this, SLOT(slotWindowActivated(QWidget *)));
352 connect(workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this,
353 SLOT(slotWindowActivated(QMdiSubWindow *)));
355 RS_DEBUG->print("ApplicationWindow::initMDI() end");
359 * Initializes all QActions of the application.
360 * (Actually, it creates all application menus & toolbars. All actions are
361 * created in CreateQtActions() and simply referenced here.)
363 void ApplicationWindow::initActions()
365 RS_DEBUG->print("ApplicationWindow::initActions()");
370 QMenu * menu = new QMenu(tr("&File"), this);
371 QToolBar * tb = fileToolBar;
372 tb->setWindowTitle("File");
373 // tb->setCloseMode(Q3DockWindow::Undocked);
375 menu->addAction(actionFileNew);
376 tb->addAction(actionFileNew);
377 connect(actionFileNew, SIGNAL(activated()), this, SLOT(slotFileNew()));
378 menu->addAction(actionFileOpen);
379 tb->addAction(actionFileOpen);
380 connect(actionFileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen()));
381 menu->addAction(actionFileSave);
382 tb->addAction(actionFileSave);
383 connect(actionFileSave, SIGNAL(activated()), this, SLOT(slotFileSave()));
384 connect(this, SIGNAL(windowsChanged(bool)), actionFileSave, SLOT(setEnabled(bool)));
385 menu->addAction(actionFileSaveAs);
386 connect(actionFileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs()));
387 connect(this, SIGNAL(windowsChanged(bool)), actionFileSaveAs, SLOT(setEnabled(bool)));
388 menu->addAction(actionFileExport);
389 connect(actionFileExport, SIGNAL(activated()), this, SLOT(slotFileExport()));
390 connect(this, SIGNAL(windowsChanged(bool)), actionFileExport, SLOT(setEnabled(bool)));
392 menu->addSeparator();
394 menu->addAction(actionFileClose);
395 connect(actionFileClose, SIGNAL(activated()), this, SLOT(slotFileClose()));
396 connect(this, SIGNAL(windowsChanged(bool)), actionFileClose, SLOT(setEnabled(bool)));
398 menu->addSeparator();
400 menu->addAction(actionFilePrint);
401 tb->addAction(actionFilePrint);
402 connect(actionFilePrint, SIGNAL(activated()), this, SLOT(slotFilePrint()));
403 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrint, SLOT(setEnabled(bool)));
404 menu->addAction(actionFilePrintPreview);
405 tb->addAction(actionFilePrintPreview);
406 connect(actionFilePrintPreview, SIGNAL(toggled(bool)), this, SLOT(slotFilePrintPreview(bool)));
407 connect(this, SIGNAL(printPreviewChanged(bool)), actionFilePrintPreview, SLOT(setOn(bool)));
408 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrintPreview, SLOT(setEnabled(bool)));
410 menu->addSeparator();
412 menu->addAction(actionFileQuit);
413 connect(actionFileQuit, SIGNAL(activated()), this, SLOT(slotFileQuit()));
415 menu->addSeparator();
417 menuBar()->addMenu(menu);
418 addToolBar(Qt::TopToolBarArea, tb);
424 menu = new QMenu(tr("&Edit"), this);
426 tb->setWindowTitle("Edit");
427 // tb->setCloseMode(Q3DockWindow::Undocked);
429 // action = actionFactory.createAction(RS2::ActionEditUndo, actionHandler);
430 menu->addAction(actionEditUndo);
431 tb->addAction(actionEditUndo);
432 connect(actionEditUndo, SIGNAL(activated()), actionHandler, SLOT(slotEditUndo()));
433 connect(this, SIGNAL(windowsChanged(bool)), actionEditUndo, SLOT(setEnabled(bool)));
434 // action = actionFactory.createAction(RS2::ActionEditRedo, actionHandler);
435 menu->addAction(actionEditRedo);
436 tb->addAction(actionEditRedo);
437 connect(actionEditRedo, SIGNAL(activated()), actionHandler, SLOT(slotEditRedo()));
438 connect(this, SIGNAL(windowsChanged(bool)), actionEditRedo, SLOT(setEnabled(bool)));
441 menu->addSeparator();
443 // action = actionFactory.createAction(RS2::ActionEditCut, actionHandler);
444 menu->addAction(actionEditCut);
445 tb->addAction(actionEditCut);
446 connect(actionEditCut, SIGNAL(activated()), actionHandler, SLOT(slotEditCut()));
447 connect(this, SIGNAL(windowsChanged(bool)), actionEditCut, SLOT(setEnabled(bool)));
448 // action = actionFactory.createAction(RS2::ActionEditCopy, actionHandler);
449 menu->addAction(actionEditCopy);
450 tb->addAction(actionEditCopy);
451 connect(actionEditCopy, SIGNAL(activated()), actionHandler, SLOT(slotEditCopy()));
452 connect(this, SIGNAL(windowsChanged(bool)), actionEditCopy, SLOT(setEnabled(bool)));
453 // action = actionFactory.createAction(RS2::ActionEditPaste, actionHandler);
454 menu->addAction(actionEditPaste);
455 tb->addAction(actionEditPaste);
456 connect(actionEditPaste, SIGNAL(activated()), actionHandler, SLOT(slotEditPaste()));
457 connect(this, SIGNAL(windowsChanged(bool)), actionEditPaste, SLOT(setEnabled(bool)));
459 menu->addSeparator();
461 menu->addAction(actionOptionsGeneral);
462 connect(actionOptionsGeneral, SIGNAL(activated()), this, SLOT(slotOptionsGeneral()));
463 menu->addAction(actionOptionsDrawing);
464 connect(actionOptionsDrawing, SIGNAL(activated()), actionHandler, SLOT(slotOptionsDrawing()));
465 connect(this, SIGNAL(windowsChanged(bool)), actionOptionsDrawing, SLOT(setEnabled(bool)));
467 menuBar()->addMenu(menu);
468 addToolBar(Qt::TopToolBarArea, tb);
472 //menu = new QPopupMenu(this);
473 //menuBar()->insertItem(tr("&Options"), menu);
475 // Viewing / Zooming actions:
477 // menu = new Q3PopupMenu(this);
478 menu = new QMenu(tr("&View"), this);
479 //obsolete: menu->setCheckable(true);
481 tb->setWindowTitle("View");
482 // tb->setCloseMode(Q3DockWindow::Undocked);
484 // action = actionFactory.createAction(RS2::ActionViewGrid, this);
485 menu->addAction(actionViewGrid);
486 tb->addAction(actionViewGrid);
487 actionViewGrid->setChecked(true);
488 connect(actionViewGrid, SIGNAL(toggled(bool)), this, SLOT(slotViewGrid(bool)));
489 connect(this, SIGNAL(gridChanged(bool)), actionViewGrid, SLOT(setOn(bool)));
490 connect(this, SIGNAL(windowsChanged(bool)), actionViewGrid, SLOT(setEnabled(bool)));
492 settings.beginGroup("Appearance");
493 bool draftMode = settings.value("DraftMode", false).toBool();
496 // action = actionFactory.createAction(RS2::ActionViewDraft, this);
497 menu->addAction(actionViewDraft);
498 tb->addAction(actionViewDraft);
499 actionViewDraft->setChecked(draftMode);
500 connect(actionViewDraft, SIGNAL(toggled(bool)), this, SLOT(slotViewDraft(bool)));
501 connect(this, SIGNAL(draftChanged(bool)), actionViewDraft, SLOT(setOn(bool)));
502 connect(this, SIGNAL(windowsChanged(bool)), actionViewDraft, SLOT(setEnabled(bool)));
505 action = actionFactory.createAction(RS2::ActionViewLayerList, this);
507 action->setChecked(true);
508 action = actionFactory.createAction(RS2::ActionViewBlockList, this);
510 action->setChecked(true);
511 action = actionFactory.createAction(RS2::ActionViewOptionToolbar, this);
513 action->setChecked(true);
514 action = actionFactory.createAction(RS2::ActionViewCommandLine, this);
516 action->setChecked(true);*/
518 // action = actionFactory.createAction(RS2::ActionZoomRedraw, actionHandler);
519 menu->addAction(actionZoomRedraw);
520 tb->addAction(actionZoomRedraw);
521 connect(actionZoomRedraw, SIGNAL(activated()), actionHandler, SLOT(slotZoomRedraw()));
522 connect(this, SIGNAL(windowsChanged(bool)), actionZoomRedraw, SLOT(setEnabled(bool)));
523 // action = actionFactory.createAction(RS2::ActionZoomIn, actionHandler);
524 menu->addAction(actionZoomIn);
525 tb->addAction(actionZoomIn);
526 connect(actionZoomIn, SIGNAL(activated()), actionHandler, SLOT(slotZoomIn()));
527 connect(this, SIGNAL(windowsChanged(bool)), actionZoomIn, SLOT(setEnabled(bool)));
528 // action = actionFactory.createAction(RS2::ActionZoomOut, actionHandler);
529 menu->addAction(actionZoomOut);
530 tb->addAction(actionZoomOut);
531 connect(actionZoomOut, SIGNAL(activated()), actionHandler, SLOT(slotZoomOut()));
532 connect(this, SIGNAL(windowsChanged(bool)), actionZoomOut, SLOT(setEnabled(bool)));
533 // action = actionFactory.createAction(RS2::ActionZoomAuto, actionHandler);
534 menu->addAction(actionZoomAuto);
535 tb->addAction(actionZoomAuto);
536 connect(actionZoomAuto, SIGNAL(activated()), actionHandler, SLOT(slotZoomAuto()));
537 connect(this, SIGNAL(windowsChanged(bool)), actionZoomAuto, SLOT(setEnabled(bool)));
538 // action = actionFactory.createAction(RS2::ActionZoomPrevious, actionHandler);
539 menu->addAction(actionZoomPrevious);
540 tb->addAction(actionZoomPrevious);
541 connect(actionZoomPrevious, SIGNAL(activated()), actionHandler, SLOT(slotZoomPrevious()));
542 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPrevious, SLOT(setEnabled(bool)));
543 // action = actionFactory.createAction(RS2::ActionZoomWindow, actionHandler);
544 menu->addAction(actionZoomWindow);
545 tb->addAction(actionZoomWindow);
546 connect(actionZoomWindow, SIGNAL(activated()), actionHandler, SLOT(slotZoomWindow()));
547 connect(this, SIGNAL(windowsChanged(bool)), actionZoomWindow, SLOT(setEnabled(bool)));
548 // action = actionFactory.createAction(RS2::ActionZoomPan, actionHandler);
549 menu->addAction(actionZoomPan);
550 tb->addAction(actionZoomPan);
551 connect(actionZoomPan, SIGNAL(activated()), actionHandler, SLOT(slotZoomPan()));
552 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPan, SLOT(setEnabled(bool)));
554 menu->addSeparator();
556 // action = actionFactory.createAction(RS2::ActionViewStatusBar, this);
557 menu->addAction(actionViewStatusbar);
558 actionViewStatusbar->setChecked(true);
559 connect(actionViewStatusbar, SIGNAL(toggled(bool)), this, SLOT(slotViewStatusBar(bool)));
562 menu->insertItem(tr("Vie&ws"), createDockWindowMenu(NoToolBars));
563 menu->insertItem(tr("Tool&bars"), createDockWindowMenu(OnlyToolBars));
565 //Actually, this isn't really needed... This crap is maintained by Qt...
566 //#warning "!!! More stuff to port to Qt4 !!!"
569 menu->addAction(actionFocusCommandLine);
570 connect(actionFocusCommandLine, SIGNAL(activated()), this, SLOT(slotFocusCommandLine()));
571 connect(this, SIGNAL(windowsChanged(bool)), actionFocusCommandLine, SLOT(setEnabled(bool)));
572 menuBar()->addMenu(menu);
573 //addToolBar(tb, tr("View"));
574 // addDockWindow(tb, tr("View"), Qt::DockTop);
575 addToolBar(Qt::TopToolBarArea, tb);
577 // Selecting actions:
579 menu = new QMenu(tr("&Select"), this);
580 // action = actionFactory.createAction(RS2::ActionDeselectAll, actionHandler);
581 menu->addAction(actionDeselectAll);
582 connect(actionDeselectAll, SIGNAL(activated()), actionHandler, SLOT(slotDeselectAll()));
583 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectAll, SLOT(setEnabled(bool)));
584 // action = actionFactory.createAction(RS2::ActionSelectAll, actionHandler);
585 menu->addAction(actionSelectAll);
586 connect(actionSelectAll, SIGNAL(activated()), actionHandler, SLOT(slotSelectAll()));
587 connect(this, SIGNAL(windowsChanged(bool)), actionSelectAll, SLOT(setEnabled(bool)));
588 // action = actionFactory.createAction(RS2::ActionSelectSingle, actionHandler);
589 menu->addAction(actionSelectSingle);
590 connect(actionSelectSingle, SIGNAL(activated()), actionHandler, SLOT(slotSelectSingle()));
591 connect(this, SIGNAL(windowsChanged(bool)), actionSelectSingle, SLOT(setEnabled(bool)));
592 // action = actionFactory.createAction(RS2::ActionSelectContour, actionHandler);
593 menu->addAction(actionSelectContour);
594 connect(actionSelectContour, SIGNAL(activated()), actionHandler, SLOT(slotSelectContour()));
595 connect(this, SIGNAL(windowsChanged(bool)), actionSelectContour, SLOT(setEnabled(bool)));
596 // action = actionFactory.createAction(RS2::ActionDeselectWindow, actionHandler);
597 menu->addAction(actionDeselectWindow);
598 connect(actionDeselectWindow, SIGNAL(activated()), actionHandler, SLOT(slotDeselectWindow()));
599 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectWindow, SLOT(setEnabled(bool)));
600 // action = actionFactory.createAction(RS2::ActionSelectWindow, actionHandler);
601 menu->addAction(actionSelectWindow);
602 connect(actionSelectWindow, SIGNAL(activated()), actionHandler, SLOT(slotSelectWindow()));
603 connect(this, SIGNAL(windowsChanged(bool)), actionSelectWindow, SLOT(setEnabled(bool)));
604 // action = actionFactory.createAction(RS2::ActionSelectInvert, actionHandler);
605 menu->addAction(actionSelectInvert);
606 connect(actionSelectInvert, SIGNAL(activated()), actionHandler, SLOT(slotSelectInvert()));
607 connect(this, SIGNAL(windowsChanged(bool)), actionSelectInvert, SLOT(setEnabled(bool)));
608 // action = actionFactory.createAction(RS2::ActionSelectIntersected, actionHandler);
609 menu->addAction(actionSelectIntersected);
610 connect(actionSelectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotSelectIntersected()));
611 connect(this, SIGNAL(windowsChanged(bool)), actionSelectIntersected, SLOT(setEnabled(bool)));
612 // action = actionFactory.createAction(RS2::ActionDeselectIntersected, actionHandler);
613 menu->addAction(actionDeselectIntersected);
614 connect(actionDeselectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotDeselectIntersected()));
615 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectIntersected, SLOT(setEnabled(bool)));
616 // action = actionFactory.createAction(RS2::ActionSelectLayer, actionHandler);
617 menu->addAction(actionSelectLayer);
618 connect(actionSelectLayer, SIGNAL(activated()), actionHandler, SLOT(slotSelectLayer()));
619 connect(this, SIGNAL(windowsChanged(bool)), actionSelectLayer, SLOT(setEnabled(bool)));
620 menuBar()->addMenu(menu);
624 menu = new QMenu(tr("&Draw"), this);
627 QMenu * subMenu = new QMenu(tr("&Point"), this);
628 // action = actionFactory.createAction(RS2::ActionDrawPoint, actionHandler);
629 subMenu->addAction(actionDrawPoint);
630 connect(actionDrawPoint, SIGNAL(activated()), actionHandler, SLOT(slotDrawPoint()));
631 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPoint, SLOT(setEnabled(bool)));
632 menu->addMenu(subMenu);
635 subMenu = new QMenu(tr("&Line"), this);
636 // action = actionFactory.createAction(RS2::ActionDrawLine, actionHandler);
637 subMenu->addAction(actionDrawLine);
638 connect(actionDrawLine, SIGNAL(activated()), actionHandler, SLOT(slotDrawLine()));
639 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLine, SLOT(setEnabled(bool)));
640 // action = actionFactory.createAction(RS2::ActionDrawLineAngle, actionHandler);
641 subMenu->addAction(actionDrawLineAngle);
642 connect(actionDrawLineAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineAngle()));
643 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineAngle, SLOT(setEnabled(bool)));
644 // action = actionFactory.createAction(RS2::ActionDrawLineHorizontal, actionHandler);
645 subMenu->addAction(actionDrawLineHorizontal);
646 connect(actionDrawLineHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineHorizontal()));
647 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineHorizontal, SLOT(setEnabled(bool)));
648 // action = actionFactory.createAction(RS2::ActionDrawLineVertical, actionHandler);
649 subMenu->addAction(actionDrawLineVertical);
650 connect(actionDrawLineVertical, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineVertical()));
651 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineVertical, SLOT(setEnabled(bool)));
652 // action = actionFactory.createAction(RS2::ActionDrawLineRectangle, actionHandler);
653 subMenu->addAction(actionDrawLineRectangle);
654 connect(actionDrawLineRectangle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRectangle()));
655 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRectangle, SLOT(setEnabled(bool)));
656 // action = actionFactory.createAction(RS2::ActionDrawLineParallel, actionHandler);
657 subMenu->addAction(actionDrawLineParallel);
658 connect(actionDrawLineParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallel()));
659 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallel, SLOT(setEnabled(bool)));
660 // action = actionFactory.createAction(RS2::ActionDrawLineParallelThrough, actionHandler);
661 subMenu->addAction(actionDrawLineParallelThrough);
662 connect(actionDrawLineParallelThrough, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallelThrough()));
663 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallelThrough, SLOT(setEnabled(bool)));
664 // action = actionFactory.createAction(RS2::ActionDrawLineBisector, actionHandler);
665 subMenu->addAction(actionDrawLineBisector);
666 connect(actionDrawLineBisector, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineBisector()));
667 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineBisector, SLOT(setEnabled(bool)));
668 // action = actionFactory.createAction(RS2::ActionDrawLineTangent1, actionHandler);
669 subMenu->addAction(actionDrawLineTangent1);
670 connect(actionDrawLineTangent1, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent1()));
671 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent1, SLOT(setEnabled(bool)));
672 // action = actionFactory.createAction(RS2::ActionDrawLineTangent2, actionHandler);
673 subMenu->addAction(actionDrawLineTangent2);
674 connect(actionDrawLineTangent2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent2()));
675 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent2, SLOT(setEnabled(bool)));
676 // action = actionFactory.createAction(RS2::ActionDrawLineOrthogonal, actionHandler);
677 subMenu->addAction(actionDrawLineOrthogonal);
678 connect(actionDrawLineOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineOrthogonal()));
679 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineOrthogonal, SLOT(setEnabled(bool)));
680 // action = actionFactory.createAction(RS2::ActionDrawLineRelAngle, actionHandler);
681 subMenu->addAction(actionDrawLineRelAngle);
682 connect(actionDrawLineRelAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRelAngle()));
683 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRelAngle, SLOT(setEnabled(bool)));
684 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon, actionHandler);
685 subMenu->addAction(actionDrawLinePolygon);
686 connect(actionDrawLinePolygon, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon()));
687 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon, SLOT(setEnabled(bool)));
688 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon2, actionHandler);
689 subMenu->addAction(actionDrawLinePolygon2);
690 connect(actionDrawLinePolygon2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon2()));
691 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon2, SLOT(setEnabled(bool)));
692 // action = actionFactory.createAction(RS2::ActionDrawLineFree, actionHandler);
693 subMenu->addAction(actionDrawLineFree);
694 connect(actionDrawLineFree, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineFree()));
695 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineFree, SLOT(setEnabled(bool)));
696 menu->addMenu(subMenu);
699 subMenu = new QMenu(tr("&Arc"), this);
700 subMenu->addAction(actionDrawArc);
701 connect(actionDrawArc, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc()));
702 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc, SLOT(setEnabled(bool)));
703 subMenu->addAction(actionDrawArc3P);
704 connect(actionDrawArc3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc3P()));
705 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc3P, SLOT(setEnabled(bool)));
706 subMenu->addAction(actionDrawArcParallel);
707 connect(actionDrawArcParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcParallel()));
708 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcParallel, SLOT(setEnabled(bool)));
709 subMenu->addAction(actionDrawArcTangential);
710 connect(actionDrawArcTangential, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcTangential()));
711 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcTangential, SLOT(setEnabled(bool)));
712 menu->addMenu(subMenu);
715 subMenu = new QMenu(tr("&Circle"), this);
716 // action = actionFactory.createAction(RS2::ActionDrawCircle, actionHandler);
717 subMenu->addAction(actionDrawCircle);
718 connect(actionDrawCircle, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle()));
719 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle, SLOT(setEnabled(bool)));
720 // action = actionFactory.createAction(RS2::ActionDrawCircleCR, actionHandler);
721 subMenu->addAction(actionDrawCircleCR);
722 connect(actionDrawCircleCR, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleCR()));
723 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleCR, SLOT(setEnabled(bool)));
724 // action = actionFactory.createAction(RS2::ActionDrawCircle2P, actionHandler);
725 subMenu->addAction(actionDrawCircle2P);
726 connect(actionDrawCircle2P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle2P()));
727 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle2P, SLOT(setEnabled(bool)));
728 // action = actionFactory.createAction(RS2::ActionDrawCircle3P, actionHandler);
729 subMenu->addAction(actionDrawCircle3P);
730 connect(actionDrawCircle3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle3P()));
731 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle3P, SLOT(setEnabled(bool)));
732 // action = actionFactory.createAction(RS2::ActionDrawCircleParallel, actionHandler);
733 subMenu->addAction(actionDrawCircleParallel);
734 connect(actionDrawCircleParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleParallel()));
735 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleParallel, SLOT(setEnabled(bool)));
736 menu->addMenu(subMenu);
739 subMenu = new QMenu(tr("&Ellipse"), this);
740 // action = actionFactory.createAction(RS2::ActionDrawEllipseAxis, actionHandler);
741 subMenu->addAction(actionDrawEllipseAxis);
742 connect(actionDrawEllipseAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseAxis()));
743 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseAxis, SLOT(setEnabled(bool)));
744 // action = actionFactory.createAction(RS2::ActionDrawEllipseArcAxis, actionHandler);
745 subMenu->addAction(actionDrawEllipseArcAxis);
746 connect(actionDrawEllipseArcAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseArcAxis()));
747 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseArcAxis, SLOT(setEnabled(bool)));
748 menu->addMenu(subMenu);
751 subMenu = new QMenu(tr("&Spline"), this);
752 // action = actionFactory.createAction(RS2::ActionDrawSpline, actionHandler);
753 subMenu->addAction(actionDrawSpline);
754 connect(actionDrawSpline, SIGNAL(activated()), actionHandler, SLOT(slotDrawSpline()));
755 connect(this, SIGNAL(windowsChanged(bool)), actionDrawSpline, SLOT(setEnabled(bool)));
756 menu->addMenu(subMenu);
759 subMenu = new QMenu(tr("&Polyline"), this);
760 // action = actionFactory.createAction(RS2::ActionDrawPolyline, actionHandler);
761 subMenu->addAction(actionDrawPolyline);
762 connect(actionDrawPolyline, SIGNAL(activated()), actionHandler, SLOT(slotDrawPolyline()));
763 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPolyline, SLOT(setEnabled(bool)));
764 // action = actionFactory.createAction(RS2::ActionPolylineAdd, actionHandler);
765 subMenu->addAction(actionPolylineAdd);
766 connect(actionPolylineAdd, SIGNAL(activated()), actionHandler, SLOT(slotPolylineAdd()));
767 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineAdd, SLOT(setEnabled(bool)));
768 // action = actionFactory.createAction(RS2::ActionPolylineDel, actionHandler);
769 subMenu->addAction(actionPolylineDel);
770 connect(actionPolylineDel, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDel()));
771 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDel, SLOT(setEnabled(bool)));
772 // action = actionFactory.createAction(RS2::ActionPolylineDelBetween, actionHandler);
773 subMenu->addAction(actionPolylineDelBetween);
774 connect(actionPolylineDelBetween, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDelBetween()));
775 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDelBetween, SLOT(setEnabled(bool)));
776 // action = actionFactory.createAction(RS2::ActionPolylineTrim, actionHandler);
777 subMenu->addAction(actionPolylineTrim);
778 connect(actionPolylineTrim, SIGNAL(activated()), actionHandler, SLOT(slotPolylineTrim()));
779 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineTrim, SLOT(setEnabled(bool)));
780 menu->addMenu(subMenu);
783 // action = actionFactory.createAction(RS2::ActionDrawText, actionHandler);
784 menu->addAction(actionDrawText);
785 connect(actionDrawText, SIGNAL(activated()), actionHandler, SLOT(slotDrawText()));
786 connect(this, SIGNAL(windowsChanged(bool)), actionDrawText, SLOT(setEnabled(bool)));
788 // action = actionFactory.createAction(RS2::ActionDrawHatch, actionHandler);
789 menu->addAction(actionDrawHatch);
790 connect(actionDrawHatch, SIGNAL(activated()), actionHandler, SLOT(slotDrawHatch()));
791 connect(this, SIGNAL(windowsChanged(bool)), actionDrawHatch, SLOT(setEnabled(bool)));
793 // action = actionFactory.createAction(RS2::ActionDrawImage, actionHandler);
794 menu->addAction(actionDrawImage);
795 connect(actionDrawImage, SIGNAL(activated()), actionHandler, SLOT(slotDrawImage()));
796 connect(this, SIGNAL(windowsChanged(bool)), actionDrawImage, SLOT(setEnabled(bool)));
797 // menuBar()->insertItem(tr("&Draw"), menu);
798 menuBar()->addMenu(menu);
800 // Dimensioning actions:
806 menu = new QMenu(tr("&Dimension"), this);
807 // action = actionFactory.createAction(RS2::ActionDimAligned, actionHandler);
808 menu->addAction(actionDimAligned);
809 connect(actionDimAligned, SIGNAL(activated()), actionHandler, SLOT(slotDimAligned()));
810 connect(this, SIGNAL(windowsChanged(bool)), actionDimAligned, SLOT(setEnabled(bool)));
811 // action = actionFactory.createAction(RS2::ActionDimLinear, actionHandler);
812 menu->addAction(actionDimLinear);
813 connect(actionDimLinear, SIGNAL(activated()), actionHandler, SLOT(slotDimLinear()));
814 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinear, SLOT(setEnabled(bool)));
815 // action = actionFactory.createAction(RS2::ActionDimLinearHor, actionHandler);
816 menu->addAction(actionDimLinearHor);
817 connect(actionDimLinearHor, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearHor()));
818 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearHor, SLOT(setEnabled(bool)));
819 // action = actionFactory.createAction(RS2::ActionDimLinearVer, actionHandler);
820 menu->addAction(actionDimLinearVer);
821 connect(actionDimLinearVer, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearVer()));
822 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearVer, SLOT(setEnabled(bool)));
823 // action = actionFactory.createAction(RS2::ActionDimRadial, actionHandler);
824 menu->addAction(actionDimRadial);
825 connect(actionDimRadial, SIGNAL(activated()), actionHandler, SLOT(slotDimRadial()));
826 connect(this, SIGNAL(windowsChanged(bool)), actionDimRadial, SLOT(setEnabled(bool)));
827 // action = actionFactory.createAction(RS2::ActionDimDiametric, actionHandler);
828 menu->addAction(actionDimDiametric);
829 connect(actionDimDiametric, SIGNAL(activated()), actionHandler, SLOT(slotDimDiametric()));
830 connect(this, SIGNAL(windowsChanged(bool)), actionDimDiametric, SLOT(setEnabled(bool)));
831 // action = actionFactory.createAction(RS2::ActionDimAngular, actionHandler);
832 menu->addAction(actionDimAngular);
833 connect(actionDimAngular, SIGNAL(activated()), actionHandler, SLOT(slotDimAngular()));
834 connect(this, SIGNAL(windowsChanged(bool)), actionDimAngular, SLOT(setEnabled(bool)));
835 // action = actionFactory.createAction(RS2::ActionDimLeader, actionHandler);
836 menu->addAction(actionDimLeader);
837 connect(actionDimLeader, SIGNAL(activated()), actionHandler, SLOT(slotDimLeader()));
838 connect(this, SIGNAL(windowsChanged(bool)), actionDimLeader, SLOT(setEnabled(bool)));
840 m->insertItem(tr("&Dimension"), menu);
842 menuBar()->addMenu(menu);
845 // Modifying actions:
847 menu = new QMenu(tr("&Modify"), this);
848 // action = actionFactory.createAction(RS2::ActionModifyMove, actionHandler);
849 menu->addAction(actionModifyMove);
850 connect(actionModifyMove, SIGNAL(activated()), actionHandler, SLOT(slotModifyMove()));
851 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMove, SLOT(setEnabled(bool)));
852 // action = actionFactory.createAction(RS2::ActionModifyRotate, actionHandler);
853 menu->addAction(actionModifyRotate);
854 connect(actionModifyRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate()));
855 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate, SLOT(setEnabled(bool)));
856 // action = actionFactory.createAction(RS2::ActionModifyScale, actionHandler);
857 menu->addAction(actionModifyScale);
858 connect(actionModifyScale, SIGNAL(activated()), actionHandler, SLOT(slotModifyScale()));
859 connect(this, SIGNAL(windowsChanged(bool)), actionModifyScale, SLOT(setEnabled(bool)));
860 // action = actionFactory.createAction(RS2::ActionModifyMirror, actionHandler);
861 menu->addAction(actionModifyMirror);
862 connect(actionModifyMirror, SIGNAL(activated()), actionHandler, SLOT(slotModifyMirror()));
863 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMirror, SLOT(setEnabled(bool)));
864 // action = actionFactory.createAction(RS2::ActionModifyMoveRotate, actionHandler);
865 menu->addAction(actionModifyMoveRotate);
866 connect(actionModifyMoveRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyMoveRotate()));
867 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMoveRotate, SLOT(setEnabled(bool)));
868 // action = actionFactory.createAction(RS2::ActionModifyRotate2, actionHandler);
869 menu->addAction(actionModifyRotate2);
870 connect(actionModifyRotate2, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate2()));
871 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate2, SLOT(setEnabled(bool)));
872 // action = actionFactory.createAction(RS2::ActionModifyTrim, actionHandler);
873 menu->addAction(actionModifyTrim);
874 connect(actionModifyTrim, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim()));
875 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim, SLOT(setEnabled(bool)));
876 // action = actionFactory.createAction(RS2::ActionModifyTrim2, actionHandler);
877 menu->addAction(actionModifyTrim2);
878 connect(actionModifyTrim2, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim2()));
879 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim2, SLOT(setEnabled(bool)));
880 // action = actionFactory.createAction(RS2::ActionModifyTrimAmount, actionHandler);
881 menu->addAction(actionModifyTrimAmount);
882 connect(actionModifyTrimAmount, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrimAmount()));
883 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrimAmount, SLOT(setEnabled(bool)));
884 // action = actionFactory.createAction(RS2::ActionModifyBevel, actionHandler);
885 menu->addAction(actionModifyBevel);
886 connect(actionModifyBevel, SIGNAL(activated()), actionHandler, SLOT(slotModifyBevel()));
887 connect(this, SIGNAL(windowsChanged(bool)), actionModifyBevel, SLOT(setEnabled(bool)));
888 // action = actionFactory.createAction(RS2::ActionModifyRound, actionHandler);
889 menu->addAction(actionModifyRound);
890 connect(actionModifyRound, SIGNAL(activated()), actionHandler, SLOT(slotModifyRound()));
891 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRound, SLOT(setEnabled(bool)));
892 // action = actionFactory.createAction(RS2::ActionModifyCut, actionHandler);
893 menu->addAction(actionModifyCut);
894 connect(actionModifyCut, SIGNAL(activated()), actionHandler, SLOT(slotModifyCut()));
895 connect(this, SIGNAL(windowsChanged(bool)), actionModifyCut, SLOT(setEnabled(bool)));
896 // action = actionFactory.createAction(RS2::ActionModifyStretch, actionHandler);
897 menu->addAction(actionModifyStretch);
898 connect(actionModifyStretch, SIGNAL(activated()), actionHandler, SLOT(slotModifyStretch()));
899 connect(this, SIGNAL(windowsChanged(bool)), actionModifyStretch, SLOT(setEnabled(bool)));
900 // action = actionFactory.createAction(RS2::ActionModifyEntity, actionHandler);
901 menu->addAction(actionModifyEntity);
902 connect(actionModifyEntity, SIGNAL(activated()), actionHandler, SLOT(slotModifyEntity()));
903 connect(this, SIGNAL(windowsChanged(bool)), actionModifyEntity, SLOT(setEnabled(bool)));
904 // action = actionFactory.createAction(RS2::ActionModifyAttributes, actionHandler);
905 menu->addAction(actionModifyAttributes);
906 connect(actionModifyAttributes, SIGNAL(activated()), actionHandler, SLOT(slotModifyAttributes()));
907 connect(this, SIGNAL(windowsChanged(bool)), actionModifyAttributes, SLOT(setEnabled(bool)));
908 // action = actionFactory.createAction(RS2::ActionModifyDelete, actionHandler);
909 menu->addAction(actionModifyDelete);
910 connect(actionModifyDelete, SIGNAL(activated()), actionHandler, SLOT(slotModifyDelete()));
911 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDelete, SLOT(setEnabled(bool)));
912 // action = actionFactory.createAction(RS2::ActionModifyDeleteQuick, actionHandler);
913 menu->addAction(actionModifyDeleteQuick);
914 connect(actionModifyDeleteQuick, SIGNAL(activated()), actionHandler, SLOT(slotModifyDeleteQuick()));
915 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDeleteQuick, SLOT(setEnabled(bool)));
916 // action = actionFactory.createAction(RS2::ActionModifyExplodeText, actionHandler);
917 menu->addAction(actionModifyExplodeText);
918 connect(actionModifyExplodeText, SIGNAL(activated()), actionHandler, SLOT(slotModifyExplodeText()));
919 connect(this, SIGNAL(windowsChanged(bool)), actionModifyExplodeText, SLOT(setEnabled(bool)));
920 //// action = actionFactory.createAction(RS2::ActionModifyDeleteFree, actionHandler);
921 //// menu->addAction(action);
922 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
923 menu->addAction(actionBlocksExplode);
924 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
925 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
926 menuBar()->addMenu(menu);
930 menu = new QMenu(tr("&Snap"), this);
931 // action = actionFactory.createAction(RS2::ActionSnapFree, actionHandler);
932 menu->addAction(actionSnapFree);
933 actionHandler->setActionSnapFree(actionSnapFree); // ???Why???
934 connect(actionSnapFree, SIGNAL(activated()), actionHandler, SLOT(slotSnapFree()));
935 connect(this, SIGNAL(windowsChanged(bool)), actionSnapFree, SLOT(setEnabled(bool)));
936 actionSnapFree->setChecked(true);
937 // action = actionFactory.createAction(RS2::ActionSnapGrid, actionHandler);
938 menu->addAction(actionSnapGrid);
939 actionHandler->setActionSnapGrid(actionSnapGrid); // ???Why???
940 connect(actionSnapGrid, SIGNAL(activated()), actionHandler, SLOT(slotSnapGrid()));
941 connect(this, SIGNAL(windowsChanged(bool)), actionSnapGrid, SLOT(setEnabled(bool)));
942 // action = actionFactory.createAction(RS2::ActionSnapEndpoint, actionHandler);
943 menu->addAction(actionSnapEndpoint);
944 actionHandler->setActionSnapEndpoint(actionSnapEndpoint); // ???Why???
945 connect(actionSnapEndpoint, SIGNAL(activated()), actionHandler, SLOT(slotSnapEndpoint()));
946 connect(this, SIGNAL(windowsChanged(bool)), actionSnapEndpoint, SLOT(setEnabled(bool)));
947 // action = actionFactory.createAction(RS2::ActionSnapOnEntity, actionHandler);
948 menu->addAction(actionSnapOnEntity);
949 actionHandler->setActionSnapOnEntity(actionSnapOnEntity); // ???Why???
950 connect(actionSnapOnEntity, SIGNAL(activated()), actionHandler, SLOT(slotSnapOnEntity()));
951 connect(this, SIGNAL(windowsChanged(bool)), actionSnapOnEntity, SLOT(setEnabled(bool)));
952 // action = actionFactory.createAction(RS2::ActionSnapCenter, actionHandler);
953 menu->addAction(actionSnapCenter);
954 actionHandler->setActionSnapCenter(actionSnapCenter); // ???Why???
955 connect(actionSnapCenter, SIGNAL(activated()), actionHandler, SLOT(slotSnapCenter()));
956 connect(this, SIGNAL(windowsChanged(bool)), actionSnapCenter, SLOT(setEnabled(bool)));
957 // action = actionFactory.createAction(RS2::ActionSnapMiddle, actionHandler);
958 menu->addAction(actionSnapMiddle);
959 actionHandler->setActionSnapMiddle(actionSnapMiddle); // ???Why???
960 connect(actionSnapMiddle, SIGNAL(activated()), actionHandler, SLOT(slotSnapMiddle()));
961 connect(this, SIGNAL(windowsChanged(bool)), actionSnapMiddle, SLOT(setEnabled(bool)));
962 // action = actionFactory.createAction(RS2::ActionSnapDist, actionHandler);
963 menu->addAction(actionSnapDist);
964 actionHandler->setActionSnapDist(actionSnapDist); // ???Why???
965 connect(actionSnapDist, SIGNAL(activated()), actionHandler, SLOT(slotSnapDist()));
966 connect(this, SIGNAL(windowsChanged(bool)), actionSnapDist, SLOT(setEnabled(bool)));
967 // action = actionFactory.createAction(RS2::ActionSnapIntersection, actionHandler);
968 menu->addAction(actionSnapIntersection);
969 actionHandler->setActionSnapIntersection(actionSnapIntersection); // ???Why???
970 connect(actionSnapIntersection, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersection()));
971 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersection, SLOT(setEnabled(bool)));
972 // action = actionFactory.createAction(RS2::ActionSnapIntersectionManual, actionHandler);
973 menu->addAction(actionSnapIntersectionManual);
974 actionHandler->setActionSnapIntersectionManual(actionSnapIntersectionManual); // ???Why???
975 connect(actionSnapIntersectionManual, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersectionManual()));
976 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersectionManual, SLOT(setEnabled(bool)));
978 menu->addSeparator();
980 // action = actionFactory.createAction(RS2::ActionRestrictNothing, actionHandler);
981 menu->addAction(actionRestrictNothing);
982 actionHandler->setActionRestrictNothing(actionRestrictNothing); // ???WHY???
983 connect(actionRestrictNothing, SIGNAL(activated()), actionHandler, SLOT(slotRestrictNothing()));
984 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictNothing, SLOT(setEnabled(bool)));
985 actionRestrictNothing->setChecked(true);
986 // action = actionFactory.createAction(RS2::ActionRestrictOrthogonal, actionHandler);
987 menu->addAction(actionRestrictOrthogonal);
988 actionHandler->setActionRestrictOrthogonal(actionRestrictOrthogonal); // ???WHY???
989 connect(actionRestrictOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictOrthogonal()));
990 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictOrthogonal, SLOT(setEnabled(bool)));
991 // action = actionFactory.createAction(RS2::ActionRestrictHorizontal, actionHandler);
992 menu->addAction(actionRestrictHorizontal);
993 actionHandler->setActionRestrictHorizontal(actionRestrictHorizontal); // ???WHY???
994 connect(actionRestrictHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictHorizontal()));
995 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictHorizontal, SLOT(setEnabled(bool)));
996 // action = actionFactory.createAction(RS2::ActionRestrictVertical, actionHandler);
997 menu->addAction(actionRestrictVertical);
998 actionHandler->setActionRestrictVertical(actionRestrictVertical); // ???WHY???
999 connect(actionRestrictVertical, SIGNAL(activated()), actionHandler, SLOT(slotRestrictVertical()));
1000 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictVertical, SLOT(setEnabled(bool)));
1002 menu->addSeparator();
1004 // action = actionFactory.createAction(RS2::ActionSetRelativeZero, actionHandler);
1005 menu->addAction(actionSetRelativeZero);
1006 connect(actionSetRelativeZero, SIGNAL(activated()), actionHandler, SLOT(slotSetRelativeZero()));
1007 connect(this, SIGNAL(windowsChanged(bool)), actionSetRelativeZero, SLOT(setEnabled(bool)));
1008 // action = actionFactory.createAction(RS2::ActionLockRelativeZero, actionHandler);
1009 menu->addAction(actionLockRelativeZero);
1010 actionHandler->setActionLockRelativeZero(actionLockRelativeZero);
1011 connect(actionLockRelativeZero, SIGNAL(toggled(bool)), actionHandler, SLOT(slotLockRelativeZero(bool))); // ???WHY???
1012 connect(this, SIGNAL(windowsChanged(bool)), actionLockRelativeZero, SLOT(setEnabled(bool)));
1013 menuBar()->addMenu(menu);
1018 menu = new QMenu(tr("&Info"), this);
1019 //action = actionFactory.createAction(RS2::ActionInfoInside, actionHandler);
1020 //menu->addAction(action);
1021 menu->addAction(actionInfoDist);
1022 connect(actionInfoDist, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist()));
1023 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist, SLOT(setEnabled(bool)));
1024 menu->addAction(actionInfoDist2);
1025 connect(actionInfoDist2, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist2()));
1026 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist2, SLOT(setEnabled(bool)));
1027 menu->addAction(actionInfoAngle);
1028 connect(actionInfoAngle, SIGNAL(activated()), actionHandler, SLOT(slotInfoAngle()));
1029 connect(this, SIGNAL(windowsChanged(bool)), actionInfoAngle, SLOT(setEnabled(bool)));
1030 menu->addAction(actionInfoTotalLength);
1031 connect(actionInfoTotalLength, SIGNAL(activated()), actionHandler, SLOT(slotInfoTotalLength()));
1032 connect(this, SIGNAL(windowsChanged(bool)), actionInfoTotalLength, SLOT(setEnabled(bool)));
1033 menu->addAction(actionInfoArea);
1034 connect(actionInfoArea, SIGNAL(activated()), actionHandler, SLOT(slotInfoArea()));
1035 connect(this, SIGNAL(windowsChanged(bool)), actionInfoArea, SLOT(setEnabled(bool)));
1036 menuBar()->addMenu(menu);
1041 menu = new QMenu(tr("&Layer"), this);
1042 // action = actionFactory.createAction(RS2::ActionLayersDefreezeAll, actionHandler);
1043 menu->addAction(actionLayersDefreezeAll);
1044 connect(actionLayersDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersDefreezeAll()));
1045 connect(this, SIGNAL(windowsChanged(bool)), actionLayersDefreezeAll, SLOT(setEnabled(bool)));
1046 // action = actionFactory.createAction(RS2::ActionLayersFreezeAll, actionHandler);
1047 menu->addAction(actionLayersFreezeAll);
1048 connect(actionLayersFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersFreezeAll()));
1049 connect(this, SIGNAL(windowsChanged(bool)), actionLayersFreezeAll, SLOT(setEnabled(bool)));
1050 // action = actionFactory.createAction(RS2::ActionLayersAdd, actionHandler);
1051 menu->addAction(actionLayersAdd);
1052 connect(actionLayersAdd, SIGNAL(activated()), actionHandler, SLOT(slotLayersAdd()));
1053 connect(this, SIGNAL(windowsChanged(bool)), actionLayersAdd, SLOT(setEnabled(bool)));
1054 // action = actionFactory.createAction(RS2::ActionLayersRemove, actionHandler);
1055 menu->addAction(actionLayersRemove);
1056 connect(actionLayersRemove, SIGNAL(activated()), actionHandler, SLOT(slotLayersRemove()));
1057 connect(this, SIGNAL(windowsChanged(bool)), actionLayersRemove, SLOT(setEnabled(bool)));
1058 // action = actionFactory.createAction(RS2::ActionLayersEdit, actionHandler);
1059 menu->addAction(actionLayersEdit);
1060 connect(actionLayersEdit, SIGNAL(activated()), actionHandler, SLOT(slotLayersEdit()));
1061 connect(this, SIGNAL(windowsChanged(bool)), actionLayersEdit, SLOT(setEnabled(bool)));
1062 // action = actionFactory.createAction(RS2::ActionLayersToggleView, actionHandler);
1063 menu->addAction(actionLayersToggleView);
1064 connect(actionLayersToggleView, SIGNAL(activated()), actionHandler, SLOT(slotLayersToggleView()));
1065 connect(this, SIGNAL(windowsChanged(bool)), actionLayersToggleView, SLOT(setEnabled(bool)));
1066 menuBar()->addMenu(menu);
1070 menu = new QMenu(tr("&Block"), this);
1071 // action = actionFactory.createAction(RS2::ActionBlocksDefreezeAll, actionHandler);
1072 menu->addAction(actionBlocksDefreezeAll);
1073 connect(actionBlocksDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksDefreezeAll()));
1074 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksDefreezeAll, SLOT(setEnabled(bool)));
1075 // action = actionFactory.createAction(RS2::ActionBlocksFreezeAll, actionHandler);
1076 menu->addAction(actionBlocksFreezeAll);
1077 connect(actionBlocksFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksFreezeAll()));
1078 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksFreezeAll, SLOT(setEnabled(bool)));
1079 // action = actionFactory.createAction(RS2::ActionBlocksAdd, actionHandler);
1080 menu->addAction(actionBlocksAdd);
1081 connect(actionBlocksAdd, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAdd()));
1082 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAdd, SLOT(setEnabled(bool)));
1083 // action = actionFactory.createAction(RS2::ActionBlocksRemove, actionHandler);
1084 menu->addAction(actionBlocksRemove);
1085 connect(actionBlocksRemove, SIGNAL(activated()), actionHandler, SLOT(slotBlocksRemove()));
1086 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksRemove, SLOT(setEnabled(bool)));
1087 // action = actionFactory.createAction(RS2::ActionBlocksAttributes, actionHandler);
1088 menu->addAction(actionBlocksAttributes);
1089 connect(actionBlocksAttributes, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAttributes()));
1090 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAttributes, SLOT(setEnabled(bool)));
1091 // action = actionFactory.createAction(RS2::ActionBlocksInsert, actionHandler);
1092 menu->addAction(actionBlocksInsert);
1093 connect(actionBlocksInsert, SIGNAL(activated()), actionHandler, SLOT(slotBlocksInsert()));
1094 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksInsert, SLOT(setEnabled(bool)));
1095 // action = actionFactory.createAction(RS2::ActionBlocksEdit, actionHandler);
1096 menu->addAction(actionBlocksEdit);
1097 connect(actionBlocksEdit, SIGNAL(activated()), actionHandler, SLOT(slotBlocksEdit()));
1098 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksEdit, SLOT(setEnabled(bool)));
1099 // action = actionFactory.createAction(RS2::ActionBlocksCreate, actionHandler);
1100 menu->addAction(actionBlocksCreate);
1101 connect(actionBlocksCreate, SIGNAL(activated()), actionHandler, SLOT(slotBlocksCreate()));
1102 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksCreate, SLOT(setEnabled(bool)));
1103 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
1104 menu->addAction(actionBlocksExplode);
1105 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
1106 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
1107 menuBar()->addMenu(menu);
1109 //will *this* make a toolbar break for us???
1110 addToolBarBreak(Qt::TopToolBarArea);
1111 // addDockWindow(penToolBar, tr("Pen"), Qt::DockTop);
1112 // addDockWindow(optionWidget, tr("Tool Options"), Qt::DockTop, true);
1113 addToolBar(Qt::TopToolBarArea, (QToolBar *)penToolBar); // hmm.
1114 addToolBar(Qt::TopToolBarArea, optionWidget);
1119 scriptMenu = new QMenu(this);
1120 scriptOpenIDE = actionFactory.createAction(RS2::ActionScriptOpenIDE, this);
1121 scriptOpenIDE->addTo(scriptMenu);
1122 scriptRun = actionFactory.createAction(RS2::ActionScriptRun, this);
1123 scriptRun->addTo(scriptMenu);
1126 scriptOpenIDE = NULL;
1132 menu = new QMenu(tr("&CAM"), this);
1133 action = actionFactory.createAction(RS2::ActionCamExportAuto, actionHandler);
1134 menu->addAction(action);
1135 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1136 action = actionFactory.createAction(RS2::ActionCamReorder, actionHandler);
1137 menu->addAction(action);
1138 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1139 menuBar()->addMenu(menu);
1144 helpAboutApp = new QAction(QIcon(QC_APP_ICON16), tr("&About Architektonas"), this);
1145 // helpAboutApp = new QAction(tr("About"), qPixmapFromMimeSource(QC_APP_ICON16), tr("&About %1").arg(QC_APPNAME), 0, this);
1146 helpAboutApp->setStatusTip(tr("About the application"));
1147 //helpAboutApp->setWhatsThis(tr("About\n\nAbout the application"));
1148 connect(helpAboutApp, SIGNAL(activated()), this, SLOT(slotHelpAbout()));
1150 helpManual = new QAction(QIcon(":/res/contents.png"), tr("&Manual"), this);
1151 helpManual->setShortcut(Qt::Key_F1);
1152 // helpManual = new QAction(qPixmapFromMimeSource("contents.png"), tr("&Manual"), Qt::Key_F1, this);
1153 helpManual->setStatusTip(tr("Launch the online manual"));
1154 connect(helpManual, SIGNAL(activated()), this, SLOT(slotHelpManual()));
1156 testDumpEntities = new QAction("Dump &Entities", this);
1157 // testDumpEntities = new QAction("Dump Entities", "Dump &Entities", 0, this);
1158 connect(testDumpEntities, SIGNAL(activated()), this, SLOT(slotTestDumpEntities()));
1160 testDumpUndo = new QAction("Undo Info", this);
1161 // testDumpUndo = new QAction("Dump Undo Info", "Undo Info", 0, this);
1162 connect(testDumpUndo, SIGNAL(activated()), this, SLOT(slotTestDumpUndo()));
1164 testUpdateInserts = new QAction("&Update Inserts", this);
1165 // testUpdateInserts = new QAction("Update Inserts", "&Update Inserts", 0, this);
1166 connect(testUpdateInserts, SIGNAL(activated()), this, SLOT(slotTestUpdateInserts()));
1168 testDrawFreehand = new QAction("Draw Freehand", this);
1169 // testDrawFreehand = new QAction("Draw Freehand", "Draw Freehand", 0, this);
1170 connect(testDrawFreehand, SIGNAL(activated()), this, SLOT(slotTestDrawFreehand()));
1172 testInsertBlock = new QAction("Insert Block", this);
1173 // testInsertBlock = new QAction("Insert Block", "Insert Block", 0, this);
1174 connect(testInsertBlock, SIGNAL(activated()), this, SLOT(slotTestInsertBlock()));
1176 testInsertText = new QAction("Insert Text", this);
1177 // testInsertText = new QAction("Insert Text", "Insert Text", 0, this);
1178 connect(testInsertText, SIGNAL(activated()), this, SLOT(slotTestInsertText()));
1180 testInsertImage = new QAction("Insert Image", this);
1181 // testInsertImage = new QAction("Insert Image", "Insert Image", 0, this);
1182 connect(testInsertImage, SIGNAL(activated()), this, SLOT(slotTestInsertImage()));
1184 testUnicode = new QAction("Unicode", this);
1185 // testUnicode = new QAction("Unicode", "Unicode", 0, this);
1186 connect(testUnicode, SIGNAL(activated()), this, SLOT(slotTestUnicode()));
1188 testInsertEllipse = new QAction("Insert Ellipse", this);
1189 // testInsertEllipse = new QAction("Insert Ellipse", "Insert Ellipse", 0, this);
1190 connect(testInsertEllipse, SIGNAL(activated()), this, SLOT(slotTestInsertEllipse()));
1192 testMath01 = new QAction("Math01", this);
1193 // testMath01 = new QAction("Math01", "Math01", 0, this);
1194 connect(testMath01, SIGNAL(activated()), this, SLOT(slotTestMath01()));
1196 testResize640 = new QAction("Resize 1", this);
1197 // testResize640 = new QAction("Resize to 640x480", "Resize 1", 0, this);
1198 connect(testResize640, SIGNAL(activated()), this, SLOT(slotTestResize640()));
1200 testResize800 = new QAction("Resize 2", this);
1201 // testResize800 = new QAction("Resize to 800x600", "Resize 2", 0, this);
1202 connect(testResize800, SIGNAL(activated()), this, SLOT(slotTestResize800()));
1204 testResize1024 = new QAction("Resize 3", this);
1205 // testResize1024 = new QAction("Resize to 1024x768", "Resize 3", 0, this);
1206 connect(testResize1024, SIGNAL(activated()), this, SLOT(slotTestResize1024()));
1210 * Initializes the menu bar.
1212 void ApplicationWindow::initMenuBar()
1214 RS_DEBUG->print("ApplicationWindow::initMenuBar()");
1216 // menuBar entry windowsMenu
1217 windowsMenu = new QMenu(tr("&Window"), this);
1218 //according to docs, this is obsolete: windowsMenu->setCheckable(true);
1219 connect(windowsMenu, SIGNAL(aboutToShow()), this, SLOT(slotWindowsMenuAboutToShow()));
1221 // menuBar entry scriptMenu
1222 //scriptMenu = new QPopupMenu(this);
1223 //scriptMenu->setCheckable(true);
1224 //scriptOpenIDE->addTo(scriptMenu);
1225 //scriptRun->addTo(scriptMenu);
1226 //connect(scriptMenu, SIGNAL(aboutToShow()), this, SLOT(slotScriptMenuAboutToShow()));
1228 // menuBar entry helpMenu
1229 helpMenu = new QMenu(tr("&Help"), this);
1230 helpMenu->addAction(helpManual);//helpManual->addTo(helpMenu);
1232 // helpMenu->insertSeparator(helpManual);
1233 helpMenu->addSeparator();
1235 helpMenu->addAction(helpAboutApp);//helpAboutApp->addTo(helpMenu);
1237 // menuBar entry test menu
1238 testMenu = new QMenu(tr("De&bugging"), this);
1239 testMenu->addAction(testDumpEntities);//testDumpEntities->addTo(testMenu);
1240 testMenu->addAction(testDumpUndo);//testDumpUndo->addTo(testMenu);
1241 testMenu->addAction(testUpdateInserts);//testUpdateInserts->addTo(testMenu);
1242 testMenu->addAction(testDrawFreehand);//testDrawFreehand->addTo(testMenu);
1243 testMenu->addAction(testInsertBlock);//testInsertBlock->addTo(testMenu);
1244 testMenu->addAction(testInsertText);//testInsertText->addTo(testMenu);
1245 testMenu->addAction(testInsertImage);//testInsertImage->addTo(testMenu);
1246 testMenu->addAction(testInsertEllipse);//testInsertEllipse->addTo(testMenu);
1247 testMenu->addAction(testUnicode);//testUnicode->addTo(testMenu);
1248 testMenu->addAction(testMath01);//testMath01->addTo(testMenu);
1249 testMenu->addAction(testResize640);//testResize640->addTo(testMenu);
1250 testMenu->addAction(testResize800);//testResize800->addTo(testMenu);
1251 testMenu->addAction(testResize1024);//testResize1024->addTo(testMenu);
1253 // menuBar configuration
1255 // menuBar()->insertItem(tr("&Scripts"), scriptMenu);
1256 menuBar()->addMenu(scriptMenu);
1258 // menuBar()->insertItem(tr("&Window"), windowsMenu);
1259 menuBar()->addMenu(windowsMenu);
1261 // menuBar()->insertSeparator();
1262 // menuBar()->insertItem(tr("&Help"), helpMenu);
1263 menuBar()->addMenu(helpMenu);
1266 // menuBar()->insertItem(tr("De&bugging"), testMenu);
1267 menuBar()->addMenu(testMenu);
1269 recentFiles = new RecentFiles(this, fileMenu);
1273 * Initializes the tool bars (file tool bar and pen tool bar).
1275 void ApplicationWindow::initToolBar()
1277 RS_DEBUG->print("ApplicationWindow::initToolBar()");
1279 // fileToolBar = new Q3ToolBar(this, "File Operations");
1280 fileToolBar = addToolBar(tr("File Operations"));
1281 fileToolBar->setObjectName("file");
1282 // editToolBar = new Q3ToolBar(this, "Edit Operations");
1283 editToolBar = addToolBar(tr("Edit Operations"));
1284 editToolBar->setObjectName("edit");
1285 // zoomToolBar = new Q3ToolBar(this, "Zoom Operations");
1286 zoomToolBar = addToolBar(tr("Zoom Operations"));
1287 zoomToolBar->setObjectName("zoom");
1288 penToolBar = new PenToolBar(this, "Pen Selection");
1289 penToolBar->setObjectName("pen");
1291 connect(penToolBar, SIGNAL(penChanged(RS_Pen)), this, SLOT(slotPenChanged(RS_Pen)));
1293 // optionWidget = new Q3ToolBar(this, "Tool Options");
1294 //addToolBarBreak() does nothing...
1295 #warning "!!! add/insertToolBarBreak() does nothing !!!"
1296 // addToolBarBreak(Qt::TopToolBarArea);
1297 optionWidget = addToolBar(tr("Tool Options"));
1298 optionWidget->setObjectName("tooloptions");
1299 optionWidget->setMinimumHeight(26);
1300 optionWidget->setMaximumHeight(26);
1301 #warning "!!! No analogue found for setHorizontallyStretchable yet !!!"
1302 //Maybe sizePolicy or somesuch??
1303 optionWidget->setMinimumWidth(150);
1304 optionWidget->setMaximumWidth(800);
1305 #warning "Following line commented out..."
1306 // optionWidget->setFixedExtentHeight(26);
1307 // optionWidget->setHorizontallyStretchable(true);
1308 // addDockWindow(optionWidget, DockTop, true);
1310 // CAD toolbar left:
1311 // Q3ToolBar * t = new Q3ToolBar(this, "CAD Tools");
1312 QToolBar * t = addToolBar(tr("CAD Tools"));
1313 t->setObjectName("cadtools");
1314 #warning "Following two lines commented out..."
1315 // t->setFixedExtentWidth(59);
1316 t->setMinimumWidth(59);
1317 t->setMaximumWidth(59);
1318 // t->setVerticallyStretchable(true);
1319 // addDockWindow(t, Qt::DockLeft, false);
1320 addToolBar(Qt::LeftToolBarArea, t);
1322 cadToolBar = new CadToolBar(t);//, "CAD Tools");
1323 cadToolBar->createSubToolBars(actionHandler);
1325 connect(cadToolBar, SIGNAL(signalBack()), this, SLOT(slotBack()));
1326 connect(this, SIGNAL(windowsChanged(bool)), cadToolBar, SLOT(setEnabled(bool)));
1328 // QG_CadToolBarMain * cadToolBarMain = new QG_CadToolBarMain(cadToolBar);
1329 //No, no break inserted here either...
1330 // insertToolBarBreak(optionWidget);
1334 * Initializes the status bar at the bottom.
1336 void ApplicationWindow::initStatusBar()
1338 RS_DEBUG->print("ApplicationWindow::initStatusBar()");
1340 statusBar()->setMinimumHeight(32);
1341 coordinateWidget = new CoordinateWidget(statusBar());//, "coordinates");
1342 statusBar()->addWidget(coordinateWidget);
1343 mouseWidget = new MouseWidget(statusBar());//, "mouse info");
1344 statusBar()->addWidget(mouseWidget);
1345 selectionWidget = new SelectionWidget(statusBar());//, "selections");
1346 statusBar()->addWidget(selectionWidget);
1350 * Initializes the global application settings from the
1351 * config file (unix, mac) or registry (windows).
1353 void ApplicationWindow::initSettings()
1355 RS_DEBUG->print("ApplicationWindow::initSettings()");
1356 settings.beginGroup("RecentFiles");
1358 for(int i=0; i<recentFiles->Maximum(); ++i)
1360 QString filename = settings.value(QString("File") + QString::number(i + 1)).toString();
1362 if (!filename.isEmpty())
1363 // recentFiles->add(filename);
1364 recentFiles->add(filename);
1367 settings.endGroup();
1369 if (recentFiles->count() > 0)
1370 // updateRecentFilesMenu();
1371 recentFiles->UpdateGUI();
1373 settings.beginGroup("Geometry");
1374 QSize windowSize = settings.value("WindowSize", QSize(950, 700)).toSize();
1375 QPoint windowPos = settings.value("WindowPos", QPoint(0, 30)).toPoint();
1376 restoreState(settings.value("DockWindows").toByteArray());
1377 settings.endGroup();
1380 // if (windowY < 30)
1382 if (windowSize.y() < 30)
1383 windowSize.y() = 30;
1391 * Stores the global application settings to file or registry.
1393 void ApplicationWindow::storeSettings()
1395 RS_DEBUG->print("ApplicationWindow::storeSettings()");
1397 settings.beginGroup("RecentFiles");
1399 for(int i=0; i<recentFiles->count(); ++i)
1400 settings.setValue(QString("File") + QString::number(i + 1), recentFiles->get(i));
1402 settings.endGroup();
1404 settings.beginGroup("Geometry");
1405 settings.setValue("WindowSize", size());
1406 settings.setValue("WindowPos", pos());
1407 settings.setValue("DockWindows", saveState());
1408 settings.endGroup();
1410 RS_DEBUG->print("ApplicationWindow::storeSettings(): OK");
1414 * Initializes the view.
1416 void ApplicationWindow::initView()
1418 RS_DEBUG->print("ApplicationWindow::initView()");
1420 RS_DEBUG->print("init view..");
1424 libraryWidget = NULL;
1425 commandWidget = NULL;
1427 simulationControls = NULL;
1431 RS_DEBUG->print(" simulation widget..");
1432 dw = new QDockWidget(QDockWidget::InDock, this, "Simulation");
1433 simulationControls = new RS_SimulationControls(dw, "Simulation");
1434 simulationControls->setFocusPolicy(Qt::NoFocus);
1435 connect(simulationControls, SIGNAL(escape()), this, SLOT(slotFocus()));
1436 connect(this, SIGNAL(windowsChanged(bool)), simulationControls, SLOT(setEnabled(bool)));
1437 dw->setWidget(simulationControls);
1438 dw->resize(240, 80);
1439 dw->setResizeEnabled(true);
1440 dw->setFixedExtentWidth(120);
1441 dw->setFixedHeight(80);
1442 dw->setCaption(tr("Simulation Controls"));
1443 dw->setCloseMode(Q3DockWindow::Always);
1444 addDockWindow(dw, Qt::DockRight);
1445 simulationDockWindow = dw;
1446 //simulationDockWindow->hide();
1449 RS_DEBUG->print(" layer widget..");
1450 // dw = new QDockWidget(QDockWidget::InDock, this, "Layer");
1451 dw = new QDockWidget(tr("Layer List"), this);
1452 dw->setObjectName("layer");
1453 layerWidget = new LayerWidget(actionHandler, dw, "Layer");
1454 layerWidget->setFocusPolicy(Qt::NoFocus);
1455 connect(layerWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1456 connect(this, SIGNAL(windowsChanged(bool)), layerWidget, SLOT(setEnabled(bool)));
1457 dw->setWidget(layerWidget);
1458 #warning "following four lines commented out..."
1459 // dw->setFixedExtentWidth(120);
1460 // dw->setResizeEnabled(true);
1461 // dw->setCloseMode(Q3DockWindow::Always);
1462 // dw->setCaption(tr("Layer List"));
1463 addDockWidget(Qt::RightDockWidgetArea, dw);
1464 layerDockWindow = dw;
1466 RS_DEBUG->print(" block widget..");
1467 // dw = new QDockWidget(QDockWidget::InDock, this, "Block");
1468 dw = new QDockWidget(tr("Block List"), this);
1469 dw->setObjectName("block");
1470 blockWidget = new BlockWidget(actionHandler, dw, "Block");
1471 blockWidget->setFocusPolicy(Qt::NoFocus);
1472 connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1473 connect(this, SIGNAL(windowsChanged(bool)), blockWidget, SLOT(setEnabled(bool)));
1474 dw->setWidget(blockWidget);
1475 #warning "following four lines commented out..."
1476 // dw->setFixedExtentWidth(120);
1477 // dw->setResizeEnabled(true);
1478 // dw->setCloseMode(Q3DockWindow::Always);
1479 // dw->setCaption(tr("Block List"));
1480 addDockWidget(Qt::RightDockWidgetArea, dw);
1481 blockDockWindow = dw;
1483 RS_DEBUG->print(" library widget..");
1484 // dw = new QDockWidget(QDockWidget::OutsideDock, this, "Library");
1485 dw = new QDockWidget(tr("Library Browser"), this);
1486 dw->setObjectName("library");
1487 libraryWidget = new LibraryWidget(dw);//WAS:, "Library");
1488 libraryWidget->setActionHandler(actionHandler);
1489 libraryWidget->setFocusPolicy(Qt::NoFocus);
1490 connect(libraryWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1492 // connect(this, SIGNAL(windowsChanged(bool)), (QObject *)libraryWidget->bInsert, SLOT(setEnabled(bool)));
1493 dw->setWidget(libraryWidget);
1494 dw->resize(240, 400);
1495 #warning "following three lines commented out..."
1496 // dw->setResizeEnabled(true);
1497 // dw->setCloseMode(Q3DockWindow::Always);
1498 // dw->setCaption(tr("Library Browser"));
1499 //not sure how to fix this one
1500 #warning "QMainWindow::addDockWidget: invalid 'area' argument"
1501 addDockWidget(Qt::NoDockWidgetArea, dw);
1502 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();
1907 if (graphic != NULL)
1909 // Link the graphic's layer list to the pen tool bar
1910 graphic->addLayerListListener(penToolBar);
1911 // Link the layer list to the layer widget
1912 graphic->addLayerListListener(layerWidget);
1913 // Link the block list to the block widget
1914 graphic->addBlockListListener(blockWidget);
1918 // Link the dialog factory to the mouse widget:
1919 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
1920 // Link the dialog factory to the coordinate widget:
1921 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
1922 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
1923 // Link the dialog factory to the option widget:
1924 // QG_DIALOGFACTORY->setOptionWidget(optionWidget);
1925 // Link the dialog factory to the cad tool bar:
1926 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
1927 // Link the dialog factory to the command widget:
1928 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
1929 // Link the dialog factory to the main app window:
1930 QG_DIALOGFACTORY->setMainWindow(this);
1932 #if 1 //bugfix for Qt3->4 conversion
1933 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotFileNew: adding window to workspace...");
1934 // workspace->addWindow(w);
1935 workspace->addSubWindow(w);
1938 RS_DEBUG->print(" showing MDI window");
1941 #warning "w->showMaximized() doesn't seem to do anything here..."
1942 //but then again, the subWindowList isn't going to be empty at this point either...
1943 if (workspace->subWindowList().isEmpty())
1949 #warning "!!! SubWindow is not being activated !!!"
1950 //neither of these is working... Is the event being eaten somewhere???
1951 // workspace->activateNextSubWindow();
1953 //printf("--> ApplicationWindow::slotFileNew(): w %s focus...\n", (w->hasFocus() ? "has" : "DOES NOT HAVE"));
1956 #warning "!!! Parameter to slotWindowActivated() is ignored !!!"
1957 slotWindowActivated(w);
1958 statusBar()->showMessage(tr("New Drawing created."), 2000);
1960 RS_DEBUG->print("ApplicationWindow::slotFileNew() OK");
1967 * Menu file -> open.
1969 void ApplicationWindow::slotFileOpen()
1971 RS_DEBUG->print("ApplicationWindow::slotFileOpen()");
1973 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 001");
1974 RS2::FormatType type = RS2::FormatUnknown;
1975 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 002");
1976 QString fileName = FileDialog::getOpenFileName(this, &type);
1977 RS_DEBUG->print("ApplicationWindow::slotFileOpen() 003");
1978 slotFileOpen(fileName, type);
1979 RS_DEBUG->print("ApplicationWindow::slotFileOpen(): OK");
1983 * Called when a recently opened file is chosen from the list in the
1986 void ApplicationWindow::slotFileOpenRecent(void)
1989 RS_DEBUG->print("ApplicationWindow::slotFileOpenRecent()");
1991 statusBar()->showMessage(tr("Opening recent file..."));
1992 QString fileName = recentFiles->get(id);
1994 if (fileName.endsWith(" (DXF 1)"))
1995 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
1997 slotFileOpen(fileName, RS2::FormatUnknown);
1999 statusBar()->showMessage(tr("Opening recent file..."));
2001 QAction * action = qobject_cast<QAction *>(sender());
2006 QString fileName = action->data().toString();
2008 if (fileName.endsWith(" (DXF 1)"))
2009 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
2011 slotFileOpen(fileName, RS2::FormatUnknown);
2016 * Menu file -> open.
2018 void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType type)
2020 RS_DEBUG->print("ApplicationWindow::slotFileOpen(..)");
2022 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2024 if (!fileName.isEmpty())
2026 RS_DEBUG->print("ApplicationWindow::slotFileOpen: creating new doc window");
2027 // Create new document window:
2028 MDIWindow * w = slotFileNew();
2029 // RS_APP->processEvents(1000);
2030 //Really, is this needed???
2031 // RS_APP->processEvents(QEventLoop::AllEvents, 1000);
2033 RS_DEBUG->print("ApplicationWindow::slotFileOpen: linking layer list");
2034 // link the layer widget to the new document:
2035 layerWidget->setLayerList(w->getDocument()->getLayerList(), false);
2036 // link the block widget to the new document:
2037 blockWidget->setBlockList(w->getDocument()->getBlockList());
2038 // link coordinate widget to graphic
2039 coordinateWidget->setGraphic(w->getGraphic());
2041 // link the layer widget to the new document:
2042 simulationControls->setGraphicView(w->getGraphicView());
2045 RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file");
2047 // RS_APP->processEvents(1000);
2048 //We no longer try to do Qt better than the Qt folks...
2049 // RS_APP->processEvents(QEventLoop::AllEvents, 1000);
2051 // open the file in the new view:
2052 if (w->slotFileOpen(fileName, type) == false)
2055 QApplication::restoreOverrideCursor();
2056 QMessageBox::information(this, QMessageBox::tr("Warning"),
2057 tr("Cannot open the file\n%1\nPlease check the permissions.") .arg(fileName), QMessageBox::Ok);
2058 w->setForceClosing(true);
2063 RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file: OK");
2064 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 1");
2066 // update recent files menu:
2067 if (type == RS2::FormatDXF1)
2068 recentFiles->add(fileName + " (DXF 1)");
2070 recentFiles->add(fileName);
2072 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 2");
2073 // updateRecentFilesMenu();
2074 recentFiles->UpdateGUI();
2076 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: OK");
2078 RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption");
2080 // w->setCaption(fileName);
2081 w->setWindowTitle(fileName);
2082 RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption: OK");
2084 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget");
2085 // update coordinate widget format:
2086 RS_DIALOGFACTORY->updateCoordinateWidget(Vector(0.0, 0.0), Vector(0.0, 0.0), true);
2087 RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget: OK");
2089 // show output of filter (if any):
2090 // commandWidget->processStderr();
2091 QString message = tr("Loaded document: ") + fileName;
2092 commandWidget->appendHistory(message);
2093 statusBar()->showMessage(message, 2000);
2097 statusBar()->showMessage(tr("Opening aborted"), 2000);
2100 QApplication::restoreOverrideCursor();
2101 RS_DEBUG->print("ApplicationWindow::slotFileOpen(..) OK");
2105 * Menu file -> save.
2107 void ApplicationWindow::slotFileSave()
2109 RS_DEBUG->print("ApplicationWindow::slotFileSave()");
2111 statusBar()->showMessage(tr("Saving drawing..."));
2113 MDIWindow * w = getMDIWindow();
2118 if (w->getDocument()->getFilename().isEmpty())
2124 if (w->slotFileSave(cancelled))
2128 name = w->getDocument()->getFilename();
2129 statusBar()->showMessage(tr("Saved drawing: %1").arg(name), 2000);
2135 QMessageBox::information(this, QMessageBox::tr("Warning"),
2136 tr("Cannot save the file\n%1\nPlease check the permissions.")
2137 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2144 * Menu file -> save as.
2146 void ApplicationWindow::slotFileSaveAs()
2148 RS_DEBUG->print("ApplicationWindow::slotFileSaveAs()");
2150 statusBar()->showMessage(tr("Saving drawing under new filename..."));
2152 MDIWindow * w = getMDIWindow();
2159 if (w->slotFileSaveAs(cancelled))
2163 name = w->getDocument()->getFilename();
2164 recentFiles->add(name);
2165 w->setWindowTitle(name);
2171 QMessageBox::information(this, QMessageBox::tr("Warning"),
2172 tr("Cannot save the file\n%1\nPlease check the permissions.")
2173 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2177 // updateRecentFilesMenu();
2178 recentFiles->UpdateGUI();
2180 QString message = tr("Saved drawing: %1").arg(name);
2181 statusBar()->showMessage(message, 2000);
2182 commandWidget->appendHistory(message);
2186 * Menu file -> export.
2188 void ApplicationWindow::slotFileExport()
2190 RS_DEBUG->print("ApplicationWindow::slotFileExport()");
2192 statusBar()->showMessage(tr("Exporting drawing..."));
2194 MDIWindow * w = getMDIWindow();
2199 // read default settings:
2200 settings.beginGroup("Paths");
2201 QString defDir = settings.value("ExportImage", RS_SYSTEM->getHomeDir()).toString();
2202 QString defFilter = settings.value("ExportImageFilter", "Portable Network Graphic (*.png)").toString();
2203 settings.endGroup();
2205 bool cancel = false;
2207 // Q3FileDialog fileDlg(NULL, "", true);
2208 QFileDialog fileDlg(NULL, "", "", "");
2210 #warning "Need to port to Qt4... !!! FIX !!!"
2212 Q3StrList f = QImageIO::outputFormats();
2213 QStringList formats = QStringList::fromStrList(f);
2214 QStringList filters;
2217 for (QStringList::Iterator it = formats.begin();
2218 it!=formats.end(); ++it)
2223 st = QString("%1 (*.%2 *.jpg)")
2224 .arg(QG_DialogFactory::extToFormat(*it))
2225 .arg(QString(*it).lower());
2229 st = QString("%1 (*.%2)")
2230 .arg(QG_DialogFactory::extToFormat(*it))
2231 .arg(QString(*it).lower());
2236 //if (!all.isEmpty()) {
2239 //all += QString("*.%1").arg(QString(*it).lower());
2242 QStringList filters;
2245 fileDlg.setFilters(filters);
2246 // fileDlg.setMode(Q3FileDialog::AnyFile);
2247 fileDlg.setFileMode(QFileDialog::AnyFile);
2248 // fileDlg.setCaption(QObject::tr("Export Image"));
2249 fileDlg.setWindowTitle(QObject::tr("Export Image"));
2250 // fileDlg.setDir(defDir);
2251 fileDlg.setDirectory(defDir);
2252 fileDlg.selectNameFilter(defFilter);
2254 if (fileDlg.exec() == QDialog::Accepted)
2256 // fn = fileDlg.selectedFile();
2257 QStringList files = fileDlg.selectedFiles();
2259 if (!files.isEmpty())
2267 // store new default settings:
2270 settings.beginGroup("Paths");
2271 // settings.writeEntry("/ExportImage", QFileInfo(fn).dirPath(true));
2272 settings.setValue("ExportImage", QFileInfo(fn).absolutePath());
2273 settings.setValue("ExportImageFilter", fileDlg.selectedFilter());
2274 settings.endGroup();
2276 // find out extension:
2277 QString filter = fileDlg.selectedFilter();
2278 QString format = "";
2279 // int i = filter.find("(*.");
2280 int i = filter.indexOf("(*.");
2284 // int i2 = filter.find(QRegExp("[) ]"), i);
2285 int i2 = filter.indexOf(QRegExp("[) ]"), i);
2286 format = filter.mid(i + 3, i2 - (i + 3));
2287 format = format.toUpper();
2290 // append extension to file:
2291 if (!QFileInfo(fn).fileName().contains("."))
2292 fn.append("." + format.toLower());
2294 // show options dialog:
2295 ImageOptionsDialog dlg(this);
2296 dlg.setGraphicSize(w->getGraphic()->getSize());
2300 bool ret = slotFileExport(fn, format, dlg.getSize(), dlg.isBackgroundBlack());
2304 QString message = tr("Exported: %1").arg(fn);
2305 statusBar()->showMessage(message, 2000);
2306 commandWidget->appendHistory(message);
2314 * Exports the drawing as a bitmap.
2316 * @param name File name.
2317 * @param format File format (e.g. "png")
2318 * @param size Size of the bitmap in pixel
2319 * @param black true: Black background, false: white
2320 * @param bw true: black/white export, false: color
2322 bool ApplicationWindow::slotFileExport(const QString & name, const QString & format, QSize size, bool black, bool bw)
2324 MDIWindow * w = getMDIWindow();
2328 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no window opened");
2332 Drawing * graphic = w->getDocument()->getGraphic();
2334 if (graphic == NULL)
2336 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no graphic");
2340 statusBar()->showMessage(tr("Exporting..."));
2341 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2344 QPixmap * buffer = new QPixmap(size);
2345 // RS_PainterQt * painter = new RS_PainterQt(buffer);
2346 QPainter qpntr(buffer);
2347 PaintInterface * painter = new PaintInterface(&qpntr);
2349 // black background:
2351 // painter->setBackgroundColor(RS_Color(0, 0, 0));
2352 // qpntr.setBackgroundColor(RS_Color(0, 0, 0));
2353 qpntr.setBackground(QBrush(QColor(0, 0, 0)));
2354 // white background:
2356 // painter->setBackgroundColor(RS_Color(255, 255, 255));
2357 // qpntr.setBackgroundColor(RS_Color(255, 255, 255));
2358 qpntr.setBackground(QBrush(QColor(255, 255, 255)));
2362 painter->setDrawingMode(RS2::ModeBW);
2364 // painter->eraseRect(0, 0, size.width(), size.height());
2365 qpntr.eraseRect(0, 0, size.width(), size.height());
2367 RS_StaticGraphicView gv(size.width(), size.height(), painter);
2370 gv.setBackground(RS_Color(0, 0, 0));
2372 gv.setBackground(RS_Color(255, 255, 255));
2374 gv.setContainer(graphic);
2376 gv.drawEntity(graphic, true);
2383 iio.setFileName(name);
2384 iio.setFormat(format);
2391 #warning "Need to port to Qt4... !!! FIX !!!"
2394 QApplication::restoreOverrideCursor();
2396 // GraphicView deletes painter
2403 statusBar()->showMessage(tr("Export complete"), 2000);
2405 statusBar()->showMessage(tr("Export failed!"), 2000);
2411 * Menu file -> close.
2413 void ApplicationWindow::slotFileClose()
2415 RS_DEBUG->print("ApplicationWindow::slotFileClose()");
2417 MDIWindow * m = getMDIWindow();
2426 //m->showMaximized();
2427 m->setWindowState(WindowMaximized);
2433 * Called when a MDI window is actually about to close. Used to
2434 * detach widgets from the document.
2436 void ApplicationWindow::slotFileClosing()
2438 RS_DEBUG->print("ApplicationWindow::slotFileClosing()");
2440 RS_DEBUG->print("detaching lists");
2441 layerWidget->setLayerList(NULL, false);
2442 blockWidget->setBlockList(NULL);
2443 coordinateWidget->setGraphic(NULL);
2445 simulationControls->setGraphicView(NULL);
2450 * Menu file -> print.
2452 void ApplicationWindow::slotFilePrint()
2454 RS_DEBUG->print("ApplicationWindow::slotFilePrint()");
2456 MDIWindow * w = getMDIWindow();
2460 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no window opened");
2464 Drawing * graphic = w->getDocument()->getGraphic();
2466 if (graphic == NULL)
2468 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no graphic");
2472 statusBar()->showMessage(tr("Printing..."));
2473 QPrinter * printer = new QPrinter(QPrinter::HighResolution);
2474 bool landscape = false;
2475 printer->setPageSize(RS2::rsToQtPaperFormat(graphic->getPaperFormat(&landscape)));
2478 printer->setOrientation(QPrinter::Landscape);
2480 printer->setOrientation(QPrinter::Portrait);
2482 settings.beginGroup("Print");
2483 printer->setOutputFileName(settings.value("FileName", "").toString());
2484 printer->setColorMode((QPrinter::ColorMode)settings.value("/ColorMode", (int)QPrinter::Color).toInt());
2485 #warning "!!! Need to port QPrinter::setOutputToFile() to Qt4 !!!"
2486 // printer->setOutputToFile((bool)RS_SETTINGS->readNumEntry("/PrintToFile", 0));
2487 settings.endGroup();
2490 // if (printer->setup(this))
2491 QPrintDialog dialog(printer, this);
2494 //printer->setOutputToFile(true);
2495 //printer->setOutputFileName(outputFile);
2497 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2498 printer->setFullPage(true);
2499 //Can call these functions directly from the QPaintDevice...
2500 // Q3PaintDeviceMetrics metr(printer);
2502 // RS_PainterQt * painter = new RS_PainterQt(printer);
2503 QPainter qpntr(printer);
2504 PaintInterface * painter = new PaintInterface(&qpntr);
2505 painter->setDrawingMode(w->getGraphicView()->getDrawingMode());
2507 // RS_StaticGraphicView gv(metr.width(), metr.height(), painter);
2508 RS_StaticGraphicView gv(printer->width(), printer->height(), painter);
2509 gv.setPrinting(true);
2510 gv.setBorders(0, 0, 0, 0);
2512 // double fx = (double)metr.width() / metr.widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2513 // double fy = (double)metr.height() / metr.heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2514 double fx = (double)printer->width() / printer->widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2515 double fy = (double)printer->height() / printer->heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2516 double f = (fx + fy) / 2;
2517 double scale = graphic->getPaperScale();
2519 gv.setOffset((int)(graphic->getPaperInsertionBase().x * f),
2520 (int)(graphic->getPaperInsertionBase().y * f));
2521 gv.setFactor(f * scale);
2522 gv.setContainer(graphic);
2523 gv.drawEntity(graphic, true);
2525 // GraphicView deletes painter
2530 settings.beginGroup("Print");
2531 #warning "!!! Need to port QPrinter::outputToFile() to Qt4 !!!"
2532 // settings.writeEntry("/PrintToFile", (int)printer->outputToFile());
2533 settings.setValue("ColorMode", (int)printer->colorMode());
2534 settings.setValue("FileName", printer->outputFileName());
2535 settings.endGroup();
2536 QApplication::restoreOverrideCursor();
2541 statusBar()->showMessage(tr("Printing complete"), 2000);
2545 * Menu file -> print preview.
2547 void ApplicationWindow::slotFilePrintPreview(bool on)
2549 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview()");
2551 RS_DEBUG->print(" creating MDI window");
2552 MDIWindow * parent = getMDIWindow();
2556 RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrintPreview: no window opened");
2560 // close print preview:
2563 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): off");
2565 if (parent->getGraphicView()->isPrintPreview())
2567 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): close");
2571 // open print preview:
2574 // look for an existing print preview:
2575 MDIWindow * ppv = parent->getPrintPreview();
2579 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): show existing");
2580 slotWindowActivated(ppv);
2585 if (!parent->getGraphicView()->isPrintPreview())
2587 RS_DEBUG->print("ApplicationWindow::slotFilePrintPreview(): create");
2589 MDIWindow * w = new MDIWindow(parent->getDocument(), workspace, 0, Qt::SubWindow);
2590 w->setAttribute(Qt::WA_DeleteOnClose);
2591 parent->addChildWindow(w);
2592 //connect(w, SIGNAL(signalClosing()),
2593 // this, SLOT(slotFileClosing()));
2595 // w->setCaption(tr("Print preview for %1").arg(parent->caption()));
2596 w->setWindowTitle(tr("Print preview for %1").arg(parent->windowTitle()));
2597 // w->setIcon(qPixmapFromMimeSource("document.png"));
2598 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
2599 w->setWindowIcon(QIcon(":/res/document.png"));
2600 w->getGraphicView()->setPrintPreview(true);
2601 w->getGraphicView()->setBackground(RS_Color(255, 255, 255));
2602 w->getGraphicView()->setDefaultAction(new ActionPrintPreview(*w->getDocument(), *w->getGraphicView()));
2604 // only graphics offer block lists, blocks don't
2605 RS_DEBUG->print(" adding listeners");
2606 Drawing * graphic = w->getDocument()->getGraphic();
2611 // Link the layer list to the pen tool bar
2612 graphic->addLayerListListener(penToolBar);
2613 // Link the layer list to the layer widget
2614 graphic->addLayerListListener(layerWidget);
2615 // Link the block list to the block widget
2616 graphic->addBlockListListener(blockWidget);
2618 // Center by default:
2619 graphic->centerToPage();
2622 // Link the graphic view to the mouse widget:
2623 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
2624 // Link the graphic view to the coordinate widget:
2625 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
2626 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
2627 // Link the graphic view to the option widget:
2628 //QG_DIALOGFACTORY->setOptionWidget(optionWidget);
2629 // Link the graphic view to the cad tool bar:
2630 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
2631 // Link the graphic view to the command widget:
2632 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
2634 RS_DEBUG->print(" showing MDI window");
2636 if (workspace->subWindowList().isEmpty())
2641 w->getGraphicView()->zoomPage();
2644 slotWindowActivated(w);
2651 * Menu file -> quit.
2653 void ApplicationWindow::slotFileQuit()
2655 RS_DEBUG->print("ApplicationWindow::slotFileQuit()");
2657 statusBar()->showMessage(tr("Exiting application..."));
2659 if (queryExit(false))
2664 * Forces termination of QCad (demo version).
2666 void ApplicationWindow::slotFileDemoQuit()
2668 statusBar()->showMessage(tr("Exiting application..."));
2675 * Shows / hides the grid.
2677 * @param toggle true: show, false: hide.
2679 void ApplicationWindow::slotViewGrid(bool toggle)
2681 RS_DEBUG->print("ApplicationWindow::slotViewGrid()");
2683 MDIWindow * m = getMDIWindow();
2687 Drawing * g = m->getGraphic();
2690 g->setGridOn(toggle);
2696 RS_DEBUG->print("ApplicationWindow::slotViewGrid() OK");
2700 * Enables / disables the draft mode.
2702 * @param toggle true: enable, false: disable.
2704 void ApplicationWindow::slotViewDraft(bool toggle)
2706 RS_DEBUG->print("ApplicationWindow::slotViewDraft()");
2708 /*MDIWindow* m = getMDIWindow();
2710 Drawing* g = m->getGraphic();
2712 g->setDraftOn(toggle);
2716 settings.beginGroup("Appearance");
2717 settings.setValue("DraftMode", toggle);
2718 settings.endGroup();
2724 * Redraws all mdi windows.
2726 void ApplicationWindow::redrawAll()
2730 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2732 for(int i=0; i<int(windows.count()); ++i)
2734 MDIWindow * m = (MDIWindow *)windows.at(i);
2738 QG_GraphicView * gv = m->getGraphicView();
2748 * Updates all grids of all graphic views.
2750 void ApplicationWindow::updateGrids()
2754 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2756 for(int i=0; i<int(windows.count()); ++i)
2758 MDIWindow * m = (MDIWindow *)windows.at(i);
2762 QG_GraphicView * gv = m->getGraphicView();
2772 * Shows / hides the status bar.
2774 * @param showSB true: show, false: hide.
2776 void ApplicationWindow::slotViewStatusBar(bool showSB)
2778 RS_DEBUG->print("ApplicationWindow::slotViewStatusBar()");
2781 statusBar()->show();
2783 statusBar()->hide();
2787 * Shows / hides the layer list.
2789 * @param toggle true: show, false: hide.
2791 /*void ApplicationWindow::slotViewLayerList(bool toggle) {
2792 RS_DEBUG->print("ApplicationWindow::slotViewLayerList()");
2794 if (toggle==false) {
2795 layerDockWindow->hide();
2797 layerDockWindow->show();
2803 * Shows / hides the block list.
2805 * @param toggle true: show, false: hide.
2808 void ApplicationWindow::slotViewBlockList(bool toggle) {
2809 RS_DEBUG->print("ApplicationWindow::slotViewBlockList()");
2811 if (toggle==false) {
2812 blockDockWindow->hide();
2814 blockDockWindow->show();
2820 * Shows / hides the command line.
2822 * @param toggle true: show, false: hide.
2825 void ApplicationWindow::slotViewCommandLine(bool toggle) {
2826 RS_DEBUG->print("ApplicationWindow::slotViewCommandLine()");
2828 if (toggle==false) {
2829 commandDockWindow->hide();
2830 //QG_GraphicView* graphicView = getGraphicView();
2831 //if (graphicView!=NULL) {
2832 //graphicView->setFocus();
2836 commandDockWindow->show();
2842 * Shows / hides the option toolbar.
2844 * @param toggle true: show, false: hide.
2847 void ApplicationWindow::slotViewOptionToolbar(bool toggle) {
2848 RS_DEBUG->print("ApplicationWindow::slotViewOptionToolbar()");
2850 if (toggle==false) {
2851 optionWidget->hide();
2853 optionWidget->show();
2859 * Creates a new MDI window for editing the selected block.
2862 void ApplicationWindow::slotBlocksEdit() {
2863 RS_DEBUG->print("ApplicationWindow::slotBlocksEdit()");
2865 MDIWindow* parent = getMDIWindow();
2867 RS_BlockList* blist = blockWidget->getBlockList();
2869 RS_Block* blk = blist->getActiveBlock();
2871 MDIWindow* w = slotFileNew(blk);
2872 // the parent needs a pointer to the block window and
2874 parent->addChildWindow(w);
2875 w->getGraphicView()->zoomAuto();
2883 * Shows the dialog for general application preferences.
2885 void ApplicationWindow::slotOptionsGeneral()
2887 RS_DIALOGFACTORY->requestOptionsGeneralDialog();
2889 // update background color of all open drawings:
2890 settings.beginGroup("Appearance");
2891 QColor color(settings.value("BackgroundColor", "#000000").toString());
2892 QColor gridColor(settings.value("GridColor", "Gray").toString());
2893 QColor metaGridColor(settings.value("MetaGridColor", "Darkgray").toString());
2894 QColor selectedColor(settings.value("SelectedColor", "#A54747").toString());
2895 QColor highlightedColor(settings.value("HighlightedColor", "#739373").toString());
2896 settings.endGroup();
2898 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2900 for(int i=0; i<int(windows.count()); ++i)
2902 MDIWindow * m = (MDIWindow *)windows.at(i);
2906 QG_GraphicView * gv = m->getGraphicView();
2910 gv->setBackground(color);
2911 gv->setGridColor(gridColor);
2912 gv->setMetaGridColor(metaGridColor);
2913 gv->setSelectedColor(selectedColor);
2914 gv->setHighlightedColor(highlightedColor);
2923 * Menu script -> show ide
2925 void ApplicationWindow::slotScriptOpenIDE()
2928 scripter->openIDE();
2933 * Menu script -> run
2935 void ApplicationWindow::slotScriptRun()
2938 scripter->runScript();
2943 * Menu help -> about.
2945 void ApplicationWindow::slotHelpAbout()
2947 RS_DEBUG->print("ApplicationWindow::slotHelpAbout()");
2948 QStringList modules;
2955 modules += "Scripting";
2958 QString modulesString;
2960 if (modules.empty() == false)
2961 modulesString = modules.join(", ");
2963 modulesString = tr("None");
2965 QMessageBox box(this);
2966 box.setWindowTitle(tr("About..."));
2967 box.setText(QString("<qt>") + // no center for main stream QCad
2968 #ifdef QC_ABOUT_HEADER
2969 QString("<center>") +
2970 QString(QC_ABOUT_HEADER) +
2972 //FAIL "<h2>"+ QC_APPNAME+ "</h2>" +
2973 "<h2>Architektonas</h2>" +
2975 tr("Version: %1").arg("1.0.0") + "<br>" +
2976 tr("Date: %1").arg(__DATE__) + "<br>" +
2977 QString("© 2010 Underground Software,<br>James Hammons") +
2979 #ifdef QC_ABOUT_ADD_COMPANY
2980 + QString("<br>") + QC_ABOUT_ADD_COMPANY
2982 + QString("</center>")
2984 #ifndef QC_ABOUT_HEADER
2985 #warning "Failure..."
2986 // box.setIcon(qPixmapFromMimeSource(QC_APP_ICON));
2987 box.setFixedWidth(340);
2988 box.setFixedHeight(250);
2994 * Menu help -> help.
2996 void ApplicationWindow::slotHelpManual()
2998 #warning "No help system ported to Qt4... !!! FIX !!!"
3000 RS_DEBUG->print("ApplicationWindow::slotHelpManual()");
3002 if (assistant == NULL)
3004 RS_DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
3005 RS_DEBUG->print("ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
3006 assistant = new QAssistantClient(RS_SYSTEM->getAppDir()+"/bin", this);
3007 connect(assistant, SIGNAL(error(const QString&)), this, SLOT(slotError(const QString&)));
3010 args << QDir::convertSeparators(RS_SYSTEM->getDocPath() + "/qcaddoc.adp");
3011 // args << QString("doc") + QDir::separator() + QString("qcaddoc.adp");
3013 #if QT_VERSION>=0x030200
3014 assistant->setArguments(args);
3017 assistant->openAssistant();
3018 //assistant->showPage("index.html");
3025 void ApplicationWindow::slotTestDumpEntities(RS_EntityContainer * d)
3027 RS_DEBUG->print("ApplicationWindow::slotTestDumpEntities()");
3028 static int level = 0;
3029 std::ofstream dumpFile;
3034 dumpFile.open("debug_entities.html");
3039 dumpFile.open("debug_entities.html", std::ios::app);
3047 dumpFile << "<html>\n";
3048 dumpFile << "<body>\n";
3051 for (RS_Entity* e=d->firstEntity();
3056 dumpFile << "<table border=\"1\">\n";
3057 dumpFile << "<tr><td>Entity: " << e->getId()
3061 << "<tr><td><table><tr>"
3062 << "<td>VIS:" << e->isVisible() << "</td>"
3063 << "<td>UND:" << e->isUndone() << "</td>"
3064 << "<td>SEL:" << e->isSelected() << "</td>"
3065 << "<td>TMP:" << e->getFlag(RS2::FlagTemp) << "</td>";
3066 QString lay = "NULL";
3067 if (e->getLayer()!=NULL) {
3068 lay = e->getLayer()->getName();
3071 //fail << "<td>Layer: " << lay << "</td>"
3072 << "<td>Width: " << (int)e->getPen(false).getWidth() << "</td>"
3073 << "<td>Parent: " << e->getParent()->getId() << "</td>"
3081 case RS2::EntityPoint:
3083 RS_Point* p = (RS_Point*)e;
3085 << "<table><tr><td>"
3097 case RS2::EntityLine:
3099 RS_Line* l = (RS_Line*)e;
3101 << "<table><tr><td>"
3107 << l->getStartpoint()
3116 case RS2::EntityArc: {
3117 RS_Arc* a = (RS_Arc*)e;
3119 << "<table><tr><td>"
3136 << "<td>Startpoint: "
3137 << a->getStartpoint()
3143 << (int)a->isReversed()
3149 case RS2::EntityCircle: {
3150 RS_Circle* c = (RS_Circle*)e;
3152 << "<table><tr><td>"
3167 case RS2::EntityDimAligned: {
3168 RS_DimAligned* d = (RS_DimAligned*)e;
3170 << "<table><tr><td>"
3171 << "<b>Dimension / Aligned:</b>"
3176 << d->getDefinitionPoint()
3179 << d->getExtensionPoint1()
3182 << d->getExtensionPoint2()
3185 << d->getText().toLatin1().data()
3188 << d->getLabel().toLatin1().data()
3194 case RS2::EntityDimLinear:
3196 RS_DimLinear* d = (RS_DimLinear*)e;
3198 << "<table><tr><td>"
3199 << "<b>Dimension / Linear:</b>"
3204 << d->getDefinitionPoint()
3207 << d->getExtensionPoint1()
3210 << d->getExtensionPoint2()
3213 //fail << d->getText()
3216 //fail << d->getLabel()
3222 case RS2::EntityInsert: {
3223 RS_Insert* i = (RS_Insert*)e;
3225 << "<table><tr><td>"
3230 << "<td>Insertion point:"
3231 << i->getInsertionPoint()
3237 case RS2::EntityText: {
3238 RS_Text* t = (RS_Text*)e;
3240 << "<table><tr><td>"
3246 << t->getText().toLatin1().data()
3255 case RS2::EntityHatch: {
3256 RS_Hatch* h = (RS_Hatch*)e;
3258 << "<table><tr><td>"
3264 << h->getPattern().toLatin1().data()
3270 << (int)h->isSolid()
3279 << "<b>Unknown Entity: " << e->rtti() << "</b>"
3284 if (e->isContainer() || e->rtti()==RS2::EntityHatch) {
3285 RS_EntityContainer* ec = (RS_EntityContainer*)e;
3286 dumpFile << "<table><tr><td valign=\"top\"> Contents:</td><td>\n";
3288 slotTestDumpEntities(ec);
3289 dumpFile.open("debug_entities.html", std::ios::app);
3290 dumpFile << "</td></tr></table>\n";
3300 dumpFile << "</body>\n";
3301 dumpFile << "</html>\n";
3311 void ApplicationWindow::slotTestDumpUndo()
3313 RS_DEBUG->print("ApplicationWindow::slotTestDumpUndo()");
3315 RS_Document * d = getDocument();
3319 std::cout << *(RS_Undo*)d;
3320 std::cout << std::endl;
3327 void ApplicationWindow::slotTestUpdateInserts()
3329 RS_DEBUG->print("ApplicationWindow::slotTestUpdateInserts()");
3331 RS_Document * d = getDocument();
3340 void ApplicationWindow::slotTestDrawFreehand()
3342 RS_DEBUG->print("ApplicationWindow::slotTestDrawFreehand()");
3344 //Drawing* g = document->getMarking();
3347 ActionDrawLineFree* action =
3348 new ActionDrawLineFree(*document->getGraphic(),
3351 for (int i=0; i<100; ++i) {
3353 int posx = (random()%600);
3354 int posy = (random()%400);
3356 //RS_MouseEvent rsm1(posx, posy, LEFT);
3357 RS_MouseEvent rsm1(QEvent::MouseButtonPress,
3361 action->mousePressEvent(&rsm1);
3366 for (int k=0; k<100; ++k) {
3367 int accx = (random()%40)-20;
3368 int accy = (random()%40)-20;
3376 //RS_MouseEvent rsm2(posx, posy, LEFT);
3378 RS_MouseEvent rsm2(QEvent::MouseMove,
3382 action->mouseMoveEvent(&rsm2);
3385 action->mouseReleaseEvent(NULL);
3397 void ApplicationWindow::slotTestInsertBlock()
3399 RS_DEBUG->print("ApplicationWindow::slotTestInsertBlock()");
3401 RS_Document * d = getDocument();
3403 if (d != NULL && d->rtti() == RS2::EntityGraphic)
3405 Drawing * graphic = (Drawing *)d;
3407 if (graphic == NULL)
3410 graphic->addLayer(new RS_Layer("default"));
3411 RS_Block * block = new RS_Block(graphic, RS_BlockData("debugblock", Vector(0.0, 0.0), true));
3417 // Add one red line:
3418 line = new RS_Line(block, RS_LineData(Vector(0.0, 0.0), Vector(50.0, 0.0)));
3419 line->setLayerToActive();
3420 line->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3421 block->addEntity(line);
3423 // Add one line with attributes from block:
3424 line = new RS_Line(block, RS_LineData(Vector(50.0, 0.0), Vector(50.0, 50.0)));
3425 line->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3426 block->addEntity(line);
3428 // Add one arc with attributes from block:
3429 RS_ArcData d(Vector(50.0, 0.0), 50.0, M_PI / 2.0, M_PI, false);
3430 arc = new RS_Arc(block, d);
3431 arc->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3432 block->addEntity(arc);
3434 // Add one blue circle:
3435 RS_CircleData circleData(Vector(20.0, 15.0), 12.5);
3436 circle = new RS_Circle(block, circleData);
3437 circle->setLayerToActive();
3438 circle->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width01, RS2::SolidLine));
3439 block->addEntity(circle);
3441 graphic->addBlock(block);
3444 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);
3446 // insert one magenta instance of the block (original):
3447 ins = new RS_Insert(graphic, insData);
3448 ins->setLayerToActive();
3449 ins->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width02, RS2::SolidLine));
3451 graphic->addEntity(ins);
3453 // insert one green instance of the block (rotate):
3454 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);
3455 ins = new RS_Insert(graphic, insData);
3456 ins->setLayerToActive();
3457 ins->setPen(RS_Pen(RS_Color(0, 255, 0), RS2::Width02, RS2::SolidLine));
3459 graphic->addEntity(ins);
3461 // insert one cyan instance of the block (move):
3462 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);
3463 ins = new RS_Insert(graphic, insData);
3464 ins->setLayerToActive();
3465 ins->setPen(RS_Pen(RS_Color(0, 255, 255), RS2::Width02, RS2::SolidLine));
3467 graphic->addEntity(ins);
3469 // insert one blue instance of the block:
3470 for(double a=0.0; a<360.0; a+=45.0)
3472 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);
3473 ins = new RS_Insert(graphic, insData);
3474 ins->setLayerToActive();
3475 ins->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width05, RS2::SolidLine));
3477 graphic->addEntity(ins);
3480 // insert an array of yellow instances of the block:
3481 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);
3482 ins = new RS_Insert(graphic, insData);
3483 ins->setLayerToActive();
3484 ins->setPen(RS_Pen(RS_Color(255, 255, 0), RS2::Width01, RS2::SolidLine));
3486 graphic->addEntity(ins);
3488 GraphicView * v = getGraphicView();
3498 void ApplicationWindow::slotTestInsertEllipse()
3500 RS_DEBUG->print("ApplicationWindow::slotTestInsertEllipse()");
3502 RS_Document * d = getDocument();
3506 Drawing * graphic = (Drawing *)d;
3508 if (graphic == NULL)
3511 RS_Ellipse * ellipse;
3514 for (double a=0.0; a<2*M_PI; a+=0.1)
3517 v.setPolar(50.0, a);
3518 double xp = 1000.0*a;
3520 RS_EllipseData ellipseData(Vector(xp, 0.0), v, 0.5, 0.0, 2 * M_PI, false);
3521 ellipse = new RS_Ellipse(graphic, ellipseData);
3523 ellipse->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width01, RS2::SolidLine));
3525 graphic->addEntity(ellipse);
3526 //graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3527 //graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3529 line = new RS_Line(graphic, RS_LineData(Vector(xp, 0.0), Vector(xp, 0.0) + v));
3530 line->setPen(RS_Pen(RS_Color(128, 128, 128), RS2::Width01, RS2::SolidLine));
3531 graphic->addEntity(line);
3534 for (double mx=-60.0; mx<60.0; mx+=1.0) {
3535 //for (double mx=0.0; mx<1.0; mx+=2.5) {
3536 VectorSolutions sol = ellipse->mapX(xp + mx);
3537 //graphic->addEntity(new RS_Point(graphic,
3538 // sol.vector2 + Vector(a*500.0, 0.0)));
3539 //graphic->addEntity(new RS_Point(graphic,
3540 // sol.vector3 + Vector(a*500.0, 0.0)));
3541 //graphic->addEntity(new RS_Point(graphic,
3542 // sol.vector4 + Vector(a*500.0, 0.0)));
3544 line = new RS_Line(graphic,
3545 RS_LineData(Vector(xp+mx,-50.0),
3546 Vector(xp+mx,50.0)));
3547 line->setPen(RS_Pen(RS_Color(60, 60, 60),
3550 graphic->addEntity(line);
3552 graphic->addEntity(new RS_Point(graphic,
3558 // different minor/minor relations
3561 for (y=-250.0; y<=250.0; y+=50.0) {
3562 for (x=-250.0; x<=250.0; x+=50.0) {
3565 ellipse = new RS_Ellipse(graphic,
3567 Vector((x/5+50.0)/2.0, 0.0),
3572 ellipse->setPen(RS_Pen(RS_Color(255, 255, 0),
3576 graphic->addEntity(ellipse);
3577 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3578 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3580 ellipse = new RS_Ellipse(graphic,
3581 v + Vector(750.0, 0.0),
3582 Vector((x/5+50.0)/2.0, 0.0),
3587 graphic->addEntity(ellipse);
3588 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3589 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3595 // different rotation angles:
3597 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3598 ellipse = new RS_Ellipse(graphic,
3599 Vector(rot*200, 500.0),
3600 Vector(50.0, 0.0).rotate(rot),
3604 graphic->addEntity(ellipse);
3605 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3606 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3610 // different arc angles:
3612 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3613 for (a1=0.0; a1<=2*M_PI+0.1; a1+=(M_PI/8)) {
3614 for (a2=a1+M_PI/8; a2<=2*M_PI+a1+0.1; a2+=(M_PI/8)) {
3615 ellipse = new RS_Ellipse(graphic,
3616 Vector(-500.0-a1*200.0-5000.0*rot,
3618 Vector(50.0, 0.0).rotate(rot),
3622 graphic->addEntity(ellipse);
3623 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3624 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3630 GraphicView * v = getGraphicView();
3640 void ApplicationWindow::slotTestInsertText()
3642 RS_DEBUG->print("ApplicationWindow::slotTestInsertText()");
3644 RS_Document * d = getDocument();
3648 Drawing * graphic = (Drawing *)d;
3650 if (graphic == NULL)
3654 RS_TextData textData;
3656 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);
3657 text = new RS_Text(graphic, textData);
3658 text->setLayerToActive();
3659 text->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3660 graphic->addEntity(text);
3664 for (y=-250.0; y<=250.0; y+=50.0) {
3665 for (x=-250.0; x<=250.0; x+=50.0) {
3668 textData = RS_TextData(v,
3679 text = new RS_Text(graphic, textData);
3681 text->setLayerToActive();
3682 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3685 graphic->addEntity(text);
3690 for (x=0.0; x<M_PI*2.0; x+=0.2) {
3691 Vector v(600.0+cos(x)*50.0, 0.0+sin(x)*50.0);
3693 line = new RS_Line(graphic,
3694 RS_LineData(Vector(600.0,0.0),
3696 line->setLayerToActive();
3697 line->setPenToActive();
3698 graphic->addEntity(line);
3700 textData = RS_TextData(v,
3711 text = new RS_Text(graphic, textData);
3713 text->setLayerToActive();
3714 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3717 graphic->addEntity(text);
3720 RS_SolidData solidData = RS_SolidData(Vector(5.0, 10.0),
3722 Vector(15.0, 30.0));
3724 RS_Solid* s = new RS_Solid(graphic, solidData);
3726 s->setLayerToActive();
3727 s->setPen(RS_Pen(RS_Color(255, 255, 0),
3730 graphic->addEntity(s);
3732 GraphicView* v = getGraphicView();
3743 void ApplicationWindow::slotTestInsertImage()
3745 RS_DEBUG->print("ApplicationWindow::slotTestInsertImage()");
3747 RS_Document * d = getDocument();
3751 Drawing * graphic = (Drawing *)d;
3753 if (graphic == NULL)
3757 RS_ImageData imageData;
3759 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);
3760 image = new RS_Image(graphic, imageData);
3762 image->setLayerToActive();
3763 image->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3764 graphic->addEntity(image);
3771 void ApplicationWindow::slotTestUnicode()
3773 RS_DEBUG->print("ApplicationWindow::slotTestUnicode()");
3775 slotFileOpen("./fonts/unicode.cxf", RS2::FormatCXF);
3776 RS_Document* d = getDocument();
3778 Drawing* graphic = (Drawing*)d;
3779 if (graphic==NULL) {
3787 QChar uCode; // e.g. 65 (or 'A')
3788 QString strCode; // unicde as string e.g. '[0041] A'
3790 graphic->setAutoUpdateBorders(false);
3792 for (col=0x0000; col<=0xFFF0; col+=0x10) {
3793 printf("col: %X\n", col);
3794 for (row=0x0; row<=0xF; row++) {
3795 //printf(" row: %X\n", row);
3797 uCode = QChar(col+row);
3798 //printf(" code: %X\n", uCode.unicode());
3800 strCode.setNum(uCode.unicode(), 16);
3801 while (strCode.length()<4) {
3802 strCode="0"+strCode;
3804 strCode = "[" + strCode + "] " + uCode;
3806 if (graphic->findBlock(strCode)!=NULL) {
3807 RS_InsertData d(strCode,
3808 Vector(col/0x10*20.0,row*20.0),
3809 Vector(1.0,1.0), 0.0,
3810 1, 1, Vector(0.0, 0.0),
3811 NULL, RS2::NoUpdate);
3812 ins = new RS_Insert(graphic, d);
3813 ins->setLayerToActive();
3814 ins->setPen(RS_Pen(RS_Color(255, 255, 255),
3818 graphic->addEntity(ins);
3822 graphic->setAutoUpdateBorders(true);
3823 graphic->calculateBorders();
3830 void ApplicationWindow::slotTestMath01()
3832 RS_DEBUG->print("ApplicationWindow::slotTestMath01()");
3834 RS_Document* d = getDocument();
3836 Drawing* graphic = (Drawing*)d;
3837 if (graphic==NULL) {
3842 graphic->addEntity(new RS_Line(graphic,
3843 RS_LineData(Vector(0.0,0.0),
3844 Vector(2*M_PI,0.0))));
3845 graphic->addEntity(new RS_Line(graphic,
3846 RS_LineData(Vector(0.0,-1.0),
3851 double x = 59.0/ARAD;
3852 double x_0 = 60.0/ARAD;
3853 for (a=0.01; a<2*M_PI; a+=0.01) {
3855 RS_Line* line = new RS_Line(graphic,
3856 RS_LineData(Vector(a-0.01, cos(a-0.01)),
3857 Vector(a, cos(a))));
3858 graphic->addEntity(line);
3861 graphic->addEntity(new RS_Line(graphic,
3862 RS_LineData(Vector(a-0.01,cos(x_0)-sin(x_0)*(a-0.01-x_0)),
3863 Vector(a,cos(x_0)-sin(x_0)*(a-x_0)))));
3867 graphic->addEntity(new RS_Line(graphic,
3868 RS_LineData(Vector(x,0.0),
3872 graphic->addEntity(new RS_Line(graphic,
3873 RS_LineData(Vector(x_0,0.0),
3877 //graphic->addEntity(new RS_Line(graphic,
3878 // Vector(0.0,cos(x_0)-sin(x_0)*(0.0-x_0)),
3879 // Vector(6.0,cos(x_0)-sin(x_0)*(6.0-x_0))));
3882 GraphicView* v = getGraphicView();
3892 void ApplicationWindow::slotTestResize640()
3894 RS_DEBUG->print("ApplicationWindow::slotTestResize640()");
3902 void ApplicationWindow::slotTestResize800()
3904 RS_DEBUG->print("ApplicationWindow::slotTestResize800()");
3912 void ApplicationWindow::slotTestResize1024()
3914 RS_DEBUG->print("ApplicationWindow::slotTestResize1024()");
3920 * overloaded for Message box on last window exit.
3922 bool ApplicationWindow::queryExit(bool force)
3924 RS_DEBUG->print("ApplicationWindow::queryExit()");
3931 QMessageBox::information(this, QMessageBox::tr("Warning"),
3932 tr("This is a %1 version "
3933 "which terminates\n"
3934 "automatically after 10min. This software is\n"
3935 "not intended for production use. Please buy\n"
3936 "a full version of the application from\n%2.\n"
3937 "You can save your work now.")
3938 //FAIL .arg(QC_APPNAME)
3939 .arg("Architektonas")
3940 #ifdef QC_CUSTOM_VENDOR
3941 .arg(QC_CUSTOM_VENDOR),
3943 .arg("RibbonSoft, http://www.ribbonsoft.com"),
3948 QList<QMdiSubWindow *> list = workspace->subWindowList();
3950 // for(QWidget * w=list.first(); w!=NULL; w=list.next())
3951 for(int i=0; i<list.size(); i++)
3953 succ = ((MDIWindow *)list[i])->closeMDI(force);
3962 RS_DEBUG->print("ApplicationWindow::queryExit(): OK");
3968 * Handle hotkeys. Don't let it to the default handler of Qt.
3969 * it will consume them also if a text field is active
3970 * which means it's impossible to enter a command.
3972 void ApplicationWindow::keyPressEvent(QKeyEvent * e)
3974 #warning "!!! keyPressEvent(): Do we need this anymore? !!!"
3976 static QTime ts = QTime();
3977 static QString firstKey = "";
3979 // single key codes:
3983 case Qt::Key_Control:
3986 case Qt::Key_CapsLock:
3988 QMainWindow::keyPressEvent(e);
3990 // forward to actions:
3991 GraphicView * graphicView = getGraphicView();
3994 graphicView->keyPressEvent(e);
4000 case Qt::Key_Escape:
4006 case Qt::Key_Return:
4007 if (firstKey.isEmpty())
4015 if (firstKey.isEmpty())
4017 actionHandler->slotZoomIn();
4023 if (firstKey.isEmpty())
4025 actionHandler->slotZoomOut();
4035 if (e->isAccepted())
4038 QTime now = QTime::currentTime();
4041 if (ts.msecsTo(now) < 2000)
4043 QString code = QString("%1%2").arg(firstKey).arg(QChar(e->key())).toLower();
4045 if (actionHandler->keycode(code) == false)
4049 if (QChar(e->key()).isPrint())
4050 firstKey += e->key();
4059 if (QChar(e->key()).isPrint())
4060 firstKey = e->key();
4063 // Q3MainWindow::keyPressEvent(e);
4064 QMainWindow::keyPressEvent(e);
4067 void ApplicationWindow::keyReleaseEvent(QKeyEvent * e)
4072 case Qt::Key_Control:
4075 case Qt::Key_CapsLock:
4077 // Q3MainWindow::keyReleaseEvent(e);
4078 QMainWindow::keyReleaseEvent(e);
4080 // forward to actions:
4081 GraphicView * graphicView = getGraphicView();
4084 graphicView->keyReleaseEvent(e);
4091 // Q3MainWindow::keyPressEvent(e);
4092 QMainWindow::keyPressEvent(e);
4096 * @return Pointer to application window.
4098 /*static*/ ApplicationWindow * ApplicationWindow::getAppWindow()
4104 * @return Pointer to workspace.
4106 QMdiArea * ApplicationWindow::getWorkspace()
4112 * @return Pointer to the currently active MDI Window or NULL if no
4113 * MDI Window is active.
4115 MDIWindow * ApplicationWindow::getMDIWindow()
4117 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::getMDIWindow: workspace=%08X", workspace);
4121 RS_DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=%08X", workspace->activeSubWindow());
4122 return (MDIWindow *)workspace->activeSubWindow();
4125 RS_DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=??? (workspace == NULL)");
4130 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4132 * @return Pointer to the graphic view of the currently active document
4133 * window or NULL if no window is available.
4135 /*virtual*/ GraphicView * ApplicationWindow::getGraphicView()
4137 MDIWindow * m = getMDIWindow();
4139 return (m ? m->getGraphicView() : NULL);
4143 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4145 * @return Pointer to the graphic document of the currently active document
4146 * window or NULL if no window is available.
4148 /*virtual*/ RS_Document * ApplicationWindow::getDocument()
4150 MDIWindow * m = getMDIWindow();
4152 return (m ? m->getDocument() : NULL);
4156 * Creates a new document. Implementation from RS_MainWindowInterface.
4158 /*virtual*/ void ApplicationWindow::createNewDocument(const QString & fileName/*= QString::null*/,
4159 RS_Document * doc/*= NULL*/)
4163 if (fileName != QString::null && getDocument())
4164 getDocument()->setFilename(fileName);
4168 * Implementation from QG_MainWindowInterface.
4170 * @return Pointer to this.
4172 /*virtual*/ QMainWindow * ApplicationWindow::GetMainWindow()
4178 * @return Pointer to action handler. Implementation from QG_MainWindowInterface.
4180 /*virtual*/ ActionHandler * ApplicationWindow::getActionHandler()
4182 return actionHandler;
4186 * Implementation from QG_MainWindowInterface.
4188 /*virtual*/ void ApplicationWindow::showSimulationControls()
4191 simulationDockWindow->show();
4197 * @return Pointer to the qsa object.
4199 QSProject * ApplicationWindow::getQSAProject()
4201 if (scripter != NULL)
4202 return scripter->getQSAProject();
4209 * Implementation from QG_MainWindowInterface.
4211 /*virtual*/ void ApplicationWindow::setFocus2()