1 // qc_applicationwindow.cpp
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/17/2010 Added this text. :-)
13 // JLH 05/27/2010 Finished refactoring old Qt3 based action handling code to
14 // Qt4's much more sensible action handling
17 #include "qc_applicationwindow.h"
20 #include "rs_application.h"
21 #include "rs_actiondrawlinefree.h"
22 #include "rs_actionprintpreview.h"
23 #include "rs_creation.h"
24 #include "rs_dialogfactory.h"
25 #include "rs_dimaligned.h"
26 #include "rs_dimlinear.h"
27 #include "rs_dimradial.h"
28 #include "rs_ellipse.h"
31 #include "rs_fileio.h"
32 #include "rs_insert.h"
35 #include "rs_script.h"
36 #include "rs_scriptlist.h"
38 #include "rs_staticgraphicview.h"
39 #include "rs_system.h"
40 #include "rs_actionlibraryinsert.h"
42 #include "paintintf.h"
45 #include "rs_camdialog.h"
46 #include "rs_simulationcontrols.h"
49 #include "qg_colorbox.h"
50 #include "qg_filedialog.h"
51 #include "qg_pentoolbar.h"
52 #include "cadtoolbar.h"
53 #include "cadtoolbarmain.h"
54 #include "coordinatewidget.h"
55 #include "dlgimageoptions.h"
56 #include "mousewidget.h"
57 #include "selectionwidget.h"
59 #include "qc_mdiwindow.h"
60 #include "qc_dialogfactory.h"
61 #include "createqtactions.h"
64 QC_ApplicationWindow * QC_ApplicationWindow::appWindow = NULL;
67 # define QC_APP_ICON "qcad.png"
70 # define QC_APP_ICON16 "qcad16.png"
73 extern QSplashScreen * splash;
76 * Constructor. Initializes the app.
78 QC_ApplicationWindow::QC_ApplicationWindow():
79 // Q3MainWindow(0, "", Qt::WDestructiveClose), QG_MainWindowInterface()
80 QMainWindow((QWidget *)NULL/*,this is not a Qt::WindowFlags --> Qt::WA_DeleteOnClose*/), QG_MainWindowInterface()
82 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow");
85 //no assistant = NULL;
88 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: setting icon");
89 // setIcon(qPixmapFromMimeSource(QC_APP_ICON));
90 // setWindowIcon(qPixmapFromMimeSource(QC_APP_ICON));
91 setWindowIcon(QIcon(":/res/" QC_APP_ICON));
93 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: creating action handler");
94 actionHandler = new QG_ActionHandler(this);
95 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: creating action handler: OK");
98 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: creating scripter");
99 scripter = new QS_Scripter(this, this);
100 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: creating scripter: OK");
103 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: init view");
105 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: init toolbar");
107 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: init actions");
109 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: init menu bar");
111 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: init status bar");
114 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: creating dialogFactory");
115 dialogFactory = new QC_DialogFactory(this, optionWidget);
116 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: creating dialogFactory: OK");
117 RS_DEBUG->print("setting dialog factory object");
119 if (RS_DialogFactory::instance() == NULL)
120 RS_DEBUG->print("no RS_DialogFactory instance");
122 RS_DEBUG->print("got RS_DialogFactory instance");
124 RS_DialogFactory::instance()->setFactoryObject(dialogFactory);
125 RS_DEBUG->print("setting dialog factory object: OK");
127 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: init settings");
130 RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: init MDI");
133 // Disable menu and toolbar items
134 emit windowsChanged(FALSE);
136 //FAIL statusBar()->showMessage(QC_APPNAME " Ready", 2000);
137 statusBar()->showMessage("Architektonas Ready", 2000);
138 //setFocusPolicy(WheelFocus);
144 QC_ApplicationWindow::~QC_ApplicationWindow()
146 RS_DEBUG->print("QC_ApplicationWindow::~QC_ApplicationWindow");
148 RS_DEBUG->print("QC_ApplicationWindow::~QC_ApplicationWindow: deleting scripter");
150 RS_DEBUG->print("QC_ApplicationWindow::~QC_ApplicationWindow: deleting scripter: OK");
153 RS_DEBUG->print("QC_ApplicationWindow::~QC_ApplicationWindow: deleting action handler");
154 delete actionHandler;
155 RS_DEBUG->print("QC_ApplicationWindow::~QC_ApplicationWindow: deleting action handler: OK");
157 RS_DEBUG->print("QC_ApplicationWindow::~QC_ApplicationWindow: deleting dialog factory");
158 delete dialogFactory;
159 RS_DEBUG->print("QC_ApplicationWindow::~QC_ApplicationWindow: deleting dialog factory: OK");
161 //no RS_DEBUG->print("QC_ApplicationWindow::~QC_ApplicationWindow: "
162 // "deleting assistant..");
163 // if (assistant!=NULL) {
166 // RS_DEBUG->print("QC_ApplicationWindow::~QC_ApplicationWindow: "
167 // "deleting assistant: OK");
168 RS_DEBUG->print("QC_ApplicationWindow::~QC_ApplicationWindow: OK");
172 * Runs the start script if scripting is available.
174 void QC_ApplicationWindow::slotRunStartScript()
176 slotRunScript("autostart.qs");
180 * Runs a script. The action that triggers this slot has to carry the
181 * name of the script file.
183 void QC_ApplicationWindow::slotRunScript()
185 RS_DEBUG->print("QC_ApplicationWindow::slotRunScript");
187 const QObject * s = sender();
191 QString script = ((QAction *)s)->text();
192 RS_DEBUG->print("QC_ApplicationWindow::slotRunScript: %s", script.toLatin1().data());
193 slotRunScript(script);
198 * Runs the script with the given name.
200 void QC_ApplicationWindow::slotRunScript(const QString & name)
203 RS_DEBUG->print("QC_ApplicationWindow::slotRunScript");
205 if (scripter == NULL)
207 RS_DEBUG->print(RS_Debug::D_WARNING, "QC_ApplicationWindow::slotRunScript: scripter not initialized");
211 statusBar()->showMessage(tr("Running script '%1'").arg(name), 2000);
213 QStringList scriptList = RS_SYSTEM->getScriptList();
214 scriptList.append(RS_SYSTEM->getHomeDir() + "/.qcad/" + name);
216 for (QStringList::Iterator it = scriptList.begin(); it!=scriptList.end(); ++it)
218 RS_DEBUG->print("QC_ApplicationWindow::slotRunScript: checking script '%s'", (*it).toLatin1().data();
221 if (fi.exists() && fi.fileName() == name)
223 RS_DEBUG->print("QC_ApplicationWindow::slotRunScript: running '%s'", (*it).toLatin1().data());
224 scripter->runScript(*it, "main");
231 * Called from toolbar buttons that were added by scripts to
234 void QC_ApplicationWindow::slotInsertBlock()
236 const QObject * s = sender();
240 QString block = ((QAction *)s)->text();
241 RS_DEBUG->print("QC_ApplicationWindow::slotInsertBlock: %s", block.toLatin1().data());
242 slotInsertBlock(block);
247 * Called to insert blocks.
249 void QC_ApplicationWindow::slotInsertBlock(const QString & name)
251 RS_DEBUG->print("QC_ApplicationWindow::slotInsertBlock: '%s'", name.toLatin1().data());
253 statusBar()->showMessage(tr("Inserting block '%1'").arg(name), 2000);
255 RS_GraphicView * graphicView = getGraphicView();
256 RS_Document * document = getDocument();
258 if (graphicView != NULL && document != NULL)
260 RS_ActionLibraryInsert * action = new RS_ActionLibraryInsert(*document, *graphicView);
261 action->setFile(name);
262 graphicView->setCurrentAction(action);
267 * Shows the main application window and a splash screen.
269 void QC_ApplicationWindow::show()
271 #ifdef QSPLASHSCREEN_H
278 #ifdef QSPLASHSCREEN_H
282 qApp->processEvents();
283 splash->clearMessage();
284 # ifdef QC_DELAYED_SPLASH_SCREEN
285 QTimer::singleShot(1000 * 2, this, SLOT(finishSplashScreen()));
287 finishSplashScreen();
294 * Called when the splash screen has to terminate.
296 void QC_ApplicationWindow::finishSplashScreen()
298 #ifdef QSPLASHSCREEN_H
301 splash->finish(this);
309 * Close Event. Called when the user tries to close the app.
311 void QC_ApplicationWindow::closeEvent(QCloseEvent * /*ce*/)
313 RS_DEBUG->print("QC_ApplicationWindow::closeEvent()");
315 RS_DEBUG->print("QC_ApplicationWindow::closeEvent(): OK");
319 * Handles right-clicks for moving back to the last cad tool bar.
321 void QC_ApplicationWindow::mouseReleaseEvent(QMouseEvent * e)
323 if (e->button() == Qt::RightButton && cadToolBar != NULL)
324 cadToolBar->showToolBarMain();
330 * Initializes the MDI workspace.
332 void QC_ApplicationWindow::initMDI()
334 RS_DEBUG->print("QC_ApplicationWindow::initMDI() begin");
336 /* Could use QVBoxLayout instead of Q3VBox, but do we even need to? */
337 // Q3VBox * vb = new Q3VBox(this);
338 // vb->setFrameStyle(Q3Frame::StyledPanel | Q3Frame::Sunken);
339 // workspace = new QMdiArea(vb);
340 workspace = new QMdiArea(this);
341 // workspace->setScrollBarsEnabled(true);
342 // setCentralWidget(vb);
343 setCentralWidget(workspace);//JLH:hmm. (Yes, it works! \o/)
344 RS_DEBUG->print("QC_ApplicationWindow::initMDI(): workspace=%08X", workspace);
346 //#warning "Object::connect: No such signal QMdiArea::windowActivated(QWidget *)"
347 // connect(workspace, SIGNAL(windowActivated(QWidget *)), this, SLOT(slotWindowActivated(QWidget *)));
348 connect(workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this,
349 SLOT(slotWindowActivated(QMdiSubWindow *)));
351 RS_DEBUG->print("QC_ApplicationWindow::initMDI() end");
355 * Initializes all QActions of the application.
356 * (Actually, it creates all application menus & toolbars. All actions are
357 * created in CreateQtActions() and simply referenced here.)
359 void QC_ApplicationWindow::initActions()
361 RS_DEBUG->print("QC_ApplicationWindow::initActions()");
362 CreateQtActions(this);
367 QMenu * menu = new QMenu(tr("&File"), this);
368 QToolBar * tb = fileToolBar;
369 tb->setWindowTitle("File");
370 // tb->setCloseMode(Q3DockWindow::Undocked);
372 menu->addAction(actionFileNew);
373 tb->addAction(actionFileNew);
374 connect(actionFileNew, SIGNAL(activated()), this, SLOT(slotFileNew()));
375 menu->addAction(actionFileOpen);
376 tb->addAction(actionFileOpen);
377 connect(actionFileOpen, SIGNAL(activated()), this, SLOT(slotFileOpen()));
378 menu->addAction(actionFileSave);
379 tb->addAction(actionFileSave);
380 connect(actionFileSave, SIGNAL(activated()), this, SLOT(slotFileSave()));
381 connect(this, SIGNAL(windowsChanged(bool)), actionFileSave, SLOT(setEnabled(bool)));
382 menu->addAction(actionFileSaveAs);
383 connect(actionFileSaveAs, SIGNAL(activated()), this, SLOT(slotFileSaveAs()));
384 connect(this, SIGNAL(windowsChanged(bool)), actionFileSaveAs, SLOT(setEnabled(bool)));
385 menu->addAction(actionFileExport);
386 connect(actionFileExport, SIGNAL(activated()), this, SLOT(slotFileExport()));
387 connect(this, SIGNAL(windowsChanged(bool)), actionFileExport, SLOT(setEnabled(bool)));
389 menu->addSeparator();
391 menu->addAction(actionFileClose);
392 connect(actionFileClose, SIGNAL(activated()), this, SLOT(slotFileClose()));
393 connect(this, SIGNAL(windowsChanged(bool)), actionFileClose, SLOT(setEnabled(bool)));
395 menu->addSeparator();
397 menu->addAction(actionFilePrint);
398 tb->addAction(actionFilePrint);
399 connect(actionFilePrint, SIGNAL(activated()), this, SLOT(slotFilePrint()));
400 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrint, SLOT(setEnabled(bool)));
401 menu->addAction(actionFilePrintPreview);
402 tb->addAction(actionFilePrintPreview);
403 connect(actionFilePrintPreview, SIGNAL(toggled(bool)), this, SLOT(slotFilePrintPreview(bool)));
404 connect(this, SIGNAL(printPreviewChanged(bool)), actionFilePrintPreview, SLOT(setOn(bool)));
405 connect(this, SIGNAL(windowsChanged(bool)), actionFilePrintPreview, SLOT(setEnabled(bool)));
407 menu->addSeparator();
409 menu->addAction(actionFileQuit);
410 connect(actionFileQuit, SIGNAL(activated()), this, SLOT(slotFileQuit()));
412 menu->addSeparator();
414 menuBar()->addMenu(menu);
415 addToolBar(Qt::TopToolBarArea, tb);
421 menu = new QMenu(tr("&Edit"), this);
423 tb->setWindowTitle("Edit");
424 // tb->setCloseMode(Q3DockWindow::Undocked);
426 // action = actionFactory.createAction(RS2::ActionEditUndo, actionHandler);
427 menu->addAction(actionEditUndo);
428 tb->addAction(actionEditUndo);
429 connect(actionEditUndo, SIGNAL(activated()), actionHandler, SLOT(slotEditUndo()));
430 connect(this, SIGNAL(windowsChanged(bool)), actionEditUndo, SLOT(setEnabled(bool)));
431 // action = actionFactory.createAction(RS2::ActionEditRedo, actionHandler);
432 menu->addAction(actionEditRedo);
433 tb->addAction(actionEditRedo);
434 connect(actionEditRedo, SIGNAL(activated()), actionHandler, SLOT(slotEditRedo()));
435 connect(this, SIGNAL(windowsChanged(bool)), actionEditRedo, SLOT(setEnabled(bool)));
438 menu->addSeparator();
440 // action = actionFactory.createAction(RS2::ActionEditCut, actionHandler);
441 menu->addAction(actionEditCut);
442 tb->addAction(actionEditCut);
443 connect(actionEditCut, SIGNAL(activated()), actionHandler, SLOT(slotEditCut()));
444 connect(this, SIGNAL(windowsChanged(bool)), actionEditCut, SLOT(setEnabled(bool)));
445 // action = actionFactory.createAction(RS2::ActionEditCopy, actionHandler);
446 menu->addAction(actionEditCopy);
447 tb->addAction(actionEditCopy);
448 connect(actionEditCopy, SIGNAL(activated()), actionHandler, SLOT(slotEditCopy()));
449 connect(this, SIGNAL(windowsChanged(bool)), actionEditCopy, SLOT(setEnabled(bool)));
450 // action = actionFactory.createAction(RS2::ActionEditPaste, actionHandler);
451 menu->addAction(actionEditPaste);
452 tb->addAction(actionEditPaste);
453 connect(actionEditPaste, SIGNAL(activated()), actionHandler, SLOT(slotEditPaste()));
454 connect(this, SIGNAL(windowsChanged(bool)), actionEditPaste, SLOT(setEnabled(bool)));
456 menu->addSeparator();
458 menu->addAction(actionOptionsGeneral);
459 connect(actionOptionsGeneral, SIGNAL(activated()), this, SLOT(slotOptionsGeneral()));
460 menu->addAction(actionOptionsDrawing);
461 connect(actionOptionsDrawing, SIGNAL(activated()), actionHandler, SLOT(slotOptionsDrawing()));
462 connect(this, SIGNAL(windowsChanged(bool)), actionOptionsDrawing, SLOT(setEnabled(bool)));
464 menuBar()->addMenu(menu);
465 addToolBar(Qt::TopToolBarArea, tb);
469 //menu = new QPopupMenu(this);
470 //menuBar()->insertItem(tr("&Options"), menu);
472 // Viewing / Zooming actions:
474 // menu = new Q3PopupMenu(this);
475 menu = new QMenu(tr("&View"), this);
476 //obsolete: menu->setCheckable(true);
478 tb->setWindowTitle("View");
479 // tb->setCloseMode(Q3DockWindow::Undocked);
481 // action = actionFactory.createAction(RS2::ActionViewGrid, this);
482 menu->addAction(actionViewGrid);
483 tb->addAction(actionViewGrid);
484 actionViewGrid->setChecked(true);
485 connect(actionViewGrid, SIGNAL(toggled(bool)), this, SLOT(slotViewGrid(bool)));
486 connect(this, SIGNAL(gridChanged(bool)), actionViewGrid, SLOT(setOn(bool)));
487 connect(this, SIGNAL(windowsChanged(bool)), actionViewGrid, SLOT(setEnabled(bool)));
489 settings.beginGroup("Appearance");
490 bool draftMode = settings.value("DraftMode", false).toBool();
493 // action = actionFactory.createAction(RS2::ActionViewDraft, this);
494 menu->addAction(actionViewDraft);
495 tb->addAction(actionViewDraft);
496 actionViewDraft->setChecked(draftMode);
497 connect(actionViewDraft, SIGNAL(toggled(bool)), this, SLOT(slotViewDraft(bool)));
498 connect(this, SIGNAL(draftChanged(bool)), actionViewDraft, SLOT(setOn(bool)));
499 connect(this, SIGNAL(windowsChanged(bool)), actionViewDraft, SLOT(setEnabled(bool)));
502 action = actionFactory.createAction(RS2::ActionViewLayerList, this);
504 action->setChecked(true);
505 action = actionFactory.createAction(RS2::ActionViewBlockList, this);
507 action->setChecked(true);
508 action = actionFactory.createAction(RS2::ActionViewOptionToolbar, this);
510 action->setChecked(true);
511 action = actionFactory.createAction(RS2::ActionViewCommandLine, this);
513 action->setChecked(true);*/
515 // action = actionFactory.createAction(RS2::ActionZoomRedraw, actionHandler);
516 menu->addAction(actionZoomRedraw);
517 tb->addAction(actionZoomRedraw);
518 connect(actionZoomRedraw, SIGNAL(activated()), actionHandler, SLOT(slotZoomRedraw()));
519 connect(this, SIGNAL(windowsChanged(bool)), actionZoomRedraw, SLOT(setEnabled(bool)));
520 // action = actionFactory.createAction(RS2::ActionZoomIn, actionHandler);
521 menu->addAction(actionZoomIn);
522 tb->addAction(actionZoomIn);
523 connect(actionZoomIn, SIGNAL(activated()), actionHandler, SLOT(slotZoomIn()));
524 connect(this, SIGNAL(windowsChanged(bool)), actionZoomIn, SLOT(setEnabled(bool)));
525 // action = actionFactory.createAction(RS2::ActionZoomOut, actionHandler);
526 menu->addAction(actionZoomOut);
527 tb->addAction(actionZoomOut);
528 connect(actionZoomOut, SIGNAL(activated()), actionHandler, SLOT(slotZoomOut()));
529 connect(this, SIGNAL(windowsChanged(bool)), actionZoomOut, SLOT(setEnabled(bool)));
530 // action = actionFactory.createAction(RS2::ActionZoomAuto, actionHandler);
531 menu->addAction(actionZoomAuto);
532 tb->addAction(actionZoomAuto);
533 connect(actionZoomAuto, SIGNAL(activated()), actionHandler, SLOT(slotZoomAuto()));
534 connect(this, SIGNAL(windowsChanged(bool)), actionZoomAuto, SLOT(setEnabled(bool)));
535 // action = actionFactory.createAction(RS2::ActionZoomPrevious, actionHandler);
536 menu->addAction(actionZoomPrevious);
537 tb->addAction(actionZoomPrevious);
538 connect(actionZoomPrevious, SIGNAL(activated()), actionHandler, SLOT(slotZoomPrevious()));
539 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPrevious, SLOT(setEnabled(bool)));
540 // action = actionFactory.createAction(RS2::ActionZoomWindow, actionHandler);
541 menu->addAction(actionZoomWindow);
542 tb->addAction(actionZoomWindow);
543 connect(actionZoomWindow, SIGNAL(activated()), actionHandler, SLOT(slotZoomWindow()));
544 connect(this, SIGNAL(windowsChanged(bool)), actionZoomWindow, SLOT(setEnabled(bool)));
545 // action = actionFactory.createAction(RS2::ActionZoomPan, actionHandler);
546 menu->addAction(actionZoomPan);
547 tb->addAction(actionZoomPan);
548 connect(actionZoomPan, SIGNAL(activated()), actionHandler, SLOT(slotZoomPan()));
549 connect(this, SIGNAL(windowsChanged(bool)), actionZoomPan, SLOT(setEnabled(bool)));
551 menu->addSeparator();
553 // action = actionFactory.createAction(RS2::ActionViewStatusBar, this);
554 menu->addAction(actionViewStatusbar);
555 actionViewStatusbar->setChecked(true);
556 connect(actionViewStatusbar, SIGNAL(toggled(bool)), this, SLOT(slotViewStatusBar(bool)));
559 menu->insertItem(tr("Vie&ws"), createDockWindowMenu(NoToolBars));
560 menu->insertItem(tr("Tool&bars"), createDockWindowMenu(OnlyToolBars));
562 //Actually, this isn't really needed... This crap is maintained by Qt...
563 //#warning "!!! More stuff to port to Qt4 !!!"
566 menu->addAction(actionFocusCommandLine);
567 connect(actionFocusCommandLine, SIGNAL(activated()), this, SLOT(slotFocusCommandLine()));
568 connect(this, SIGNAL(windowsChanged(bool)), actionFocusCommandLine, SLOT(setEnabled(bool)));
569 menuBar()->addMenu(menu);
570 //addToolBar(tb, tr("View"));
571 // addDockWindow(tb, tr("View"), Qt::DockTop);
572 addToolBar(Qt::TopToolBarArea, tb);
574 // Selecting actions:
576 menu = new QMenu(tr("&Select"), this);
577 // action = actionFactory.createAction(RS2::ActionDeselectAll, actionHandler);
578 menu->addAction(actionDeselectAll);
579 connect(actionDeselectAll, SIGNAL(activated()), actionHandler, SLOT(slotDeselectAll()));
580 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectAll, SLOT(setEnabled(bool)));
581 // action = actionFactory.createAction(RS2::ActionSelectAll, actionHandler);
582 menu->addAction(actionSelectAll);
583 connect(actionSelectAll, SIGNAL(activated()), actionHandler, SLOT(slotSelectAll()));
584 connect(this, SIGNAL(windowsChanged(bool)), actionSelectAll, SLOT(setEnabled(bool)));
585 // action = actionFactory.createAction(RS2::ActionSelectSingle, actionHandler);
586 menu->addAction(actionSelectSingle);
587 connect(actionSelectSingle, SIGNAL(activated()), actionHandler, SLOT(slotSelectSingle()));
588 connect(this, SIGNAL(windowsChanged(bool)), actionSelectSingle, SLOT(setEnabled(bool)));
589 // action = actionFactory.createAction(RS2::ActionSelectContour, actionHandler);
590 menu->addAction(actionSelectContour);
591 connect(actionSelectContour, SIGNAL(activated()), actionHandler, SLOT(slotSelectContour()));
592 connect(this, SIGNAL(windowsChanged(bool)), actionSelectContour, SLOT(setEnabled(bool)));
593 // action = actionFactory.createAction(RS2::ActionDeselectWindow, actionHandler);
594 menu->addAction(actionDeselectWindow);
595 connect(actionDeselectWindow, SIGNAL(activated()), actionHandler, SLOT(slotDeselectWindow()));
596 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectWindow, SLOT(setEnabled(bool)));
597 // action = actionFactory.createAction(RS2::ActionSelectWindow, actionHandler);
598 menu->addAction(actionSelectWindow);
599 connect(actionSelectWindow, SIGNAL(activated()), actionHandler, SLOT(slotSelectWindow()));
600 connect(this, SIGNAL(windowsChanged(bool)), actionSelectWindow, SLOT(setEnabled(bool)));
601 // action = actionFactory.createAction(RS2::ActionSelectInvert, actionHandler);
602 menu->addAction(actionSelectInvert);
603 connect(actionSelectInvert, SIGNAL(activated()), actionHandler, SLOT(slotSelectInvert()));
604 connect(this, SIGNAL(windowsChanged(bool)), actionSelectInvert, SLOT(setEnabled(bool)));
605 // action = actionFactory.createAction(RS2::ActionSelectIntersected, actionHandler);
606 menu->addAction(actionSelectIntersected);
607 connect(actionSelectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotSelectIntersected()));
608 connect(this, SIGNAL(windowsChanged(bool)), actionSelectIntersected, SLOT(setEnabled(bool)));
609 // action = actionFactory.createAction(RS2::ActionDeselectIntersected, actionHandler);
610 menu->addAction(actionDeselectIntersected);
611 connect(actionDeselectIntersected, SIGNAL(activated()), actionHandler, SLOT(slotDeselectIntersected()));
612 connect(this, SIGNAL(windowsChanged(bool)), actionDeselectIntersected, SLOT(setEnabled(bool)));
613 // action = actionFactory.createAction(RS2::ActionSelectLayer, actionHandler);
614 menu->addAction(actionSelectLayer);
615 connect(actionSelectLayer, SIGNAL(activated()), actionHandler, SLOT(slotSelectLayer()));
616 connect(this, SIGNAL(windowsChanged(bool)), actionSelectLayer, SLOT(setEnabled(bool)));
617 menuBar()->addMenu(menu);
621 menu = new QMenu(tr("&Draw"), this);
624 QMenu * subMenu = new QMenu(tr("&Point"), this);
625 // action = actionFactory.createAction(RS2::ActionDrawPoint, actionHandler);
626 subMenu->addAction(actionDrawPoint);
627 connect(actionDrawPoint, SIGNAL(activated()), actionHandler, SLOT(slotDrawPoint()));
628 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPoint, SLOT(setEnabled(bool)));
629 menu->addMenu(subMenu);
632 subMenu = new QMenu(tr("&Line"), this);
633 // action = actionFactory.createAction(RS2::ActionDrawLine, actionHandler);
634 subMenu->addAction(actionDrawLine);
635 connect(actionDrawLine, SIGNAL(activated()), actionHandler, SLOT(slotDrawLine()));
636 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLine, SLOT(setEnabled(bool)));
637 // action = actionFactory.createAction(RS2::ActionDrawLineAngle, actionHandler);
638 subMenu->addAction(actionDrawLineAngle);
639 connect(actionDrawLineAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineAngle()));
640 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineAngle, SLOT(setEnabled(bool)));
641 // action = actionFactory.createAction(RS2::ActionDrawLineHorizontal, actionHandler);
642 subMenu->addAction(actionDrawLineHorizontal);
643 connect(actionDrawLineHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineHorizontal()));
644 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineHorizontal, SLOT(setEnabled(bool)));
645 // action = actionFactory.createAction(RS2::ActionDrawLineVertical, actionHandler);
646 subMenu->addAction(actionDrawLineVertical);
647 connect(actionDrawLineVertical, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineVertical()));
648 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineVertical, SLOT(setEnabled(bool)));
649 // action = actionFactory.createAction(RS2::ActionDrawLineRectangle, actionHandler);
650 subMenu->addAction(actionDrawLineRectangle);
651 connect(actionDrawLineRectangle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRectangle()));
652 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRectangle, SLOT(setEnabled(bool)));
653 // action = actionFactory.createAction(RS2::ActionDrawLineParallel, actionHandler);
654 subMenu->addAction(actionDrawLineParallel);
655 connect(actionDrawLineParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallel()));
656 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallel, SLOT(setEnabled(bool)));
657 // action = actionFactory.createAction(RS2::ActionDrawLineParallelThrough, actionHandler);
658 subMenu->addAction(actionDrawLineParallelThrough);
659 connect(actionDrawLineParallelThrough, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineParallelThrough()));
660 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineParallelThrough, SLOT(setEnabled(bool)));
661 // action = actionFactory.createAction(RS2::ActionDrawLineBisector, actionHandler);
662 subMenu->addAction(actionDrawLineBisector);
663 connect(actionDrawLineBisector, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineBisector()));
664 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineBisector, SLOT(setEnabled(bool)));
665 // action = actionFactory.createAction(RS2::ActionDrawLineTangent1, actionHandler);
666 subMenu->addAction(actionDrawLineTangent1);
667 connect(actionDrawLineTangent1, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent1()));
668 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent1, SLOT(setEnabled(bool)));
669 // action = actionFactory.createAction(RS2::ActionDrawLineTangent2, actionHandler);
670 subMenu->addAction(actionDrawLineTangent2);
671 connect(actionDrawLineTangent2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineTangent2()));
672 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineTangent2, SLOT(setEnabled(bool)));
673 // action = actionFactory.createAction(RS2::ActionDrawLineOrthogonal, actionHandler);
674 subMenu->addAction(actionDrawLineOrthogonal);
675 connect(actionDrawLineOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineOrthogonal()));
676 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineOrthogonal, SLOT(setEnabled(bool)));
677 // action = actionFactory.createAction(RS2::ActionDrawLineRelAngle, actionHandler);
678 subMenu->addAction(actionDrawLineRelAngle);
679 connect(actionDrawLineRelAngle, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineRelAngle()));
680 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineRelAngle, SLOT(setEnabled(bool)));
681 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon, actionHandler);
682 subMenu->addAction(actionDrawLinePolygon);
683 connect(actionDrawLinePolygon, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon()));
684 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon, SLOT(setEnabled(bool)));
685 // action = actionFactory.createAction(RS2::ActionDrawLinePolygon2, actionHandler);
686 subMenu->addAction(actionDrawLinePolygon2);
687 connect(actionDrawLinePolygon2, SIGNAL(activated()), actionHandler, SLOT(slotDrawLinePolygon2()));
688 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLinePolygon2, SLOT(setEnabled(bool)));
689 // action = actionFactory.createAction(RS2::ActionDrawLineFree, actionHandler);
690 subMenu->addAction(actionDrawLineFree);
691 connect(actionDrawLineFree, SIGNAL(activated()), actionHandler, SLOT(slotDrawLineFree()));
692 connect(this, SIGNAL(windowsChanged(bool)), actionDrawLineFree, SLOT(setEnabled(bool)));
693 menu->addMenu(subMenu);
696 subMenu = new QMenu(tr("&Arc"), this);
697 subMenu->addAction(actionDrawArc);
698 connect(actionDrawArc, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc()));
699 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc, SLOT(setEnabled(bool)));
700 subMenu->addAction(actionDrawArc3P);
701 connect(actionDrawArc3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawArc3P()));
702 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArc3P, SLOT(setEnabled(bool)));
703 subMenu->addAction(actionDrawArcParallel);
704 connect(actionDrawArcParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcParallel()));
705 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcParallel, SLOT(setEnabled(bool)));
706 subMenu->addAction(actionDrawArcTangential);
707 connect(actionDrawArcTangential, SIGNAL(activated()), actionHandler, SLOT(slotDrawArcTangential()));
708 connect(this, SIGNAL(windowsChanged(bool)), actionDrawArcTangential, SLOT(setEnabled(bool)));
709 menu->addMenu(subMenu);
712 subMenu = new QMenu(tr("&Circle"), this);
713 // action = actionFactory.createAction(RS2::ActionDrawCircle, actionHandler);
714 subMenu->addAction(actionDrawCircle);
715 connect(actionDrawCircle, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle()));
716 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle, SLOT(setEnabled(bool)));
717 // action = actionFactory.createAction(RS2::ActionDrawCircleCR, actionHandler);
718 subMenu->addAction(actionDrawCircleCR);
719 connect(actionDrawCircleCR, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleCR()));
720 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleCR, SLOT(setEnabled(bool)));
721 // action = actionFactory.createAction(RS2::ActionDrawCircle2P, actionHandler);
722 subMenu->addAction(actionDrawCircle2P);
723 connect(actionDrawCircle2P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle2P()));
724 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle2P, SLOT(setEnabled(bool)));
725 // action = actionFactory.createAction(RS2::ActionDrawCircle3P, actionHandler);
726 subMenu->addAction(actionDrawCircle3P);
727 connect(actionDrawCircle3P, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircle3P()));
728 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircle3P, SLOT(setEnabled(bool)));
729 // action = actionFactory.createAction(RS2::ActionDrawCircleParallel, actionHandler);
730 subMenu->addAction(actionDrawCircleParallel);
731 connect(actionDrawCircleParallel, SIGNAL(activated()), actionHandler, SLOT(slotDrawCircleParallel()));
732 connect(this, SIGNAL(windowsChanged(bool)), actionDrawCircleParallel, SLOT(setEnabled(bool)));
733 menu->addMenu(subMenu);
736 subMenu = new QMenu(tr("&Ellipse"), this);
737 // action = actionFactory.createAction(RS2::ActionDrawEllipseAxis, actionHandler);
738 subMenu->addAction(actionDrawEllipseAxis);
739 connect(actionDrawEllipseAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseAxis()));
740 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseAxis, SLOT(setEnabled(bool)));
741 // action = actionFactory.createAction(RS2::ActionDrawEllipseArcAxis, actionHandler);
742 subMenu->addAction(actionDrawEllipseArcAxis);
743 connect(actionDrawEllipseArcAxis, SIGNAL(activated()), actionHandler, SLOT(slotDrawEllipseArcAxis()));
744 connect(this, SIGNAL(windowsChanged(bool)), actionDrawEllipseArcAxis, SLOT(setEnabled(bool)));
745 menu->addMenu(subMenu);
748 subMenu = new QMenu(tr("&Spline"), this);
749 // action = actionFactory.createAction(RS2::ActionDrawSpline, actionHandler);
750 subMenu->addAction(actionDrawSpline);
751 connect(actionDrawSpline, SIGNAL(activated()), actionHandler, SLOT(slotDrawSpline()));
752 connect(this, SIGNAL(windowsChanged(bool)), actionDrawSpline, SLOT(setEnabled(bool)));
753 menu->addMenu(subMenu);
756 subMenu = new QMenu(tr("&Polyline"), this);
757 // action = actionFactory.createAction(RS2::ActionDrawPolyline, actionHandler);
758 subMenu->addAction(actionDrawPolyline);
759 connect(actionDrawPolyline, SIGNAL(activated()), actionHandler, SLOT(slotDrawPolyline()));
760 connect(this, SIGNAL(windowsChanged(bool)), actionDrawPolyline, SLOT(setEnabled(bool)));
761 // action = actionFactory.createAction(RS2::ActionPolylineAdd, actionHandler);
762 subMenu->addAction(actionPolylineAdd);
763 connect(actionPolylineAdd, SIGNAL(activated()), actionHandler, SLOT(slotPolylineAdd()));
764 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineAdd, SLOT(setEnabled(bool)));
765 // action = actionFactory.createAction(RS2::ActionPolylineDel, actionHandler);
766 subMenu->addAction(actionPolylineDel);
767 connect(actionPolylineDel, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDel()));
768 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDel, SLOT(setEnabled(bool)));
769 // action = actionFactory.createAction(RS2::ActionPolylineDelBetween, actionHandler);
770 subMenu->addAction(actionPolylineDelBetween);
771 connect(actionPolylineDelBetween, SIGNAL(activated()), actionHandler, SLOT(slotPolylineDelBetween()));
772 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineDelBetween, SLOT(setEnabled(bool)));
773 // action = actionFactory.createAction(RS2::ActionPolylineTrim, actionHandler);
774 subMenu->addAction(actionPolylineTrim);
775 connect(actionPolylineTrim, SIGNAL(activated()), actionHandler, SLOT(slotPolylineTrim()));
776 connect(this, SIGNAL(windowsChanged(bool)), actionPolylineTrim, SLOT(setEnabled(bool)));
777 menu->addMenu(subMenu);
780 // action = actionFactory.createAction(RS2::ActionDrawText, actionHandler);
781 menu->addAction(actionDrawText);
782 connect(actionDrawText, SIGNAL(activated()), actionHandler, SLOT(slotDrawText()));
783 connect(this, SIGNAL(windowsChanged(bool)), actionDrawText, SLOT(setEnabled(bool)));
785 // action = actionFactory.createAction(RS2::ActionDrawHatch, actionHandler);
786 menu->addAction(actionDrawHatch);
787 connect(actionDrawHatch, SIGNAL(activated()), actionHandler, SLOT(slotDrawHatch()));
788 connect(this, SIGNAL(windowsChanged(bool)), actionDrawHatch, SLOT(setEnabled(bool)));
790 // action = actionFactory.createAction(RS2::ActionDrawImage, actionHandler);
791 menu->addAction(actionDrawImage);
792 connect(actionDrawImage, SIGNAL(activated()), actionHandler, SLOT(slotDrawImage()));
793 connect(this, SIGNAL(windowsChanged(bool)), actionDrawImage, SLOT(setEnabled(bool)));
794 // menuBar()->insertItem(tr("&Draw"), menu);
795 menuBar()->addMenu(menu);
797 // Dimensioning actions:
803 menu = new QMenu(tr("&Dimension"), this);
804 // action = actionFactory.createAction(RS2::ActionDimAligned, actionHandler);
805 menu->addAction(actionDimAligned);
806 connect(actionDimAligned, SIGNAL(activated()), actionHandler, SLOT(slotDimAligned()));
807 connect(this, SIGNAL(windowsChanged(bool)), actionDimAligned, SLOT(setEnabled(bool)));
808 // action = actionFactory.createAction(RS2::ActionDimLinear, actionHandler);
809 menu->addAction(actionDimLinear);
810 connect(actionDimLinear, SIGNAL(activated()), actionHandler, SLOT(slotDimLinear()));
811 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinear, SLOT(setEnabled(bool)));
812 // action = actionFactory.createAction(RS2::ActionDimLinearHor, actionHandler);
813 menu->addAction(actionDimLinearHor);
814 connect(actionDimLinearHor, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearHor()));
815 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearHor, SLOT(setEnabled(bool)));
816 // action = actionFactory.createAction(RS2::ActionDimLinearVer, actionHandler);
817 menu->addAction(actionDimLinearVer);
818 connect(actionDimLinearVer, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearVer()));
819 connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearVer, SLOT(setEnabled(bool)));
820 // action = actionFactory.createAction(RS2::ActionDimRadial, actionHandler);
821 menu->addAction(actionDimRadial);
822 connect(actionDimRadial, SIGNAL(activated()), actionHandler, SLOT(slotDimRadial()));
823 connect(this, SIGNAL(windowsChanged(bool)), actionDimRadial, SLOT(setEnabled(bool)));
824 // action = actionFactory.createAction(RS2::ActionDimDiametric, actionHandler);
825 menu->addAction(actionDimDiametric);
826 connect(actionDimDiametric, SIGNAL(activated()), actionHandler, SLOT(slotDimDiametric()));
827 connect(this, SIGNAL(windowsChanged(bool)), actionDimDiametric, SLOT(setEnabled(bool)));
828 // action = actionFactory.createAction(RS2::ActionDimAngular, actionHandler);
829 menu->addAction(actionDimAngular);
830 connect(actionDimAngular, SIGNAL(activated()), actionHandler, SLOT(slotDimAngular()));
831 connect(this, SIGNAL(windowsChanged(bool)), actionDimAngular, SLOT(setEnabled(bool)));
832 // action = actionFactory.createAction(RS2::ActionDimLeader, actionHandler);
833 menu->addAction(actionDimLeader);
834 connect(actionDimLeader, SIGNAL(activated()), actionHandler, SLOT(slotDimLeader()));
835 connect(this, SIGNAL(windowsChanged(bool)), actionDimLeader, SLOT(setEnabled(bool)));
837 m->insertItem(tr("&Dimension"), menu);
839 menuBar()->addMenu(menu);
842 // Modifying actions:
844 menu = new QMenu(tr("&Modify"), this);
845 // action = actionFactory.createAction(RS2::ActionModifyMove, actionHandler);
846 menu->addAction(actionModifyMove);
847 connect(actionModifyMove, SIGNAL(activated()), actionHandler, SLOT(slotModifyMove()));
848 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMove, SLOT(setEnabled(bool)));
849 // action = actionFactory.createAction(RS2::ActionModifyRotate, actionHandler);
850 menu->addAction(actionModifyRotate);
851 connect(actionModifyRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate()));
852 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate, SLOT(setEnabled(bool)));
853 // action = actionFactory.createAction(RS2::ActionModifyScale, actionHandler);
854 menu->addAction(actionModifyScale);
855 connect(actionModifyScale, SIGNAL(activated()), actionHandler, SLOT(slotModifyScale()));
856 connect(this, SIGNAL(windowsChanged(bool)), actionModifyScale, SLOT(setEnabled(bool)));
857 // action = actionFactory.createAction(RS2::ActionModifyMirror, actionHandler);
858 menu->addAction(actionModifyMirror);
859 connect(actionModifyMirror, SIGNAL(activated()), actionHandler, SLOT(slotModifyMirror()));
860 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMirror, SLOT(setEnabled(bool)));
861 // action = actionFactory.createAction(RS2::ActionModifyMoveRotate, actionHandler);
862 menu->addAction(actionModifyMoveRotate);
863 connect(actionModifyMoveRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyMoveRotate()));
864 connect(this, SIGNAL(windowsChanged(bool)), actionModifyMoveRotate, SLOT(setEnabled(bool)));
865 // action = actionFactory.createAction(RS2::ActionModifyRotate2, actionHandler);
866 menu->addAction(actionModifyRotate2);
867 connect(actionModifyRotate2, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate2()));
868 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate2, SLOT(setEnabled(bool)));
869 // action = actionFactory.createAction(RS2::ActionModifyTrim, actionHandler);
870 menu->addAction(actionModifyTrim);
871 connect(actionModifyTrim, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim()));
872 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim, SLOT(setEnabled(bool)));
873 // action = actionFactory.createAction(RS2::ActionModifyTrim2, actionHandler);
874 menu->addAction(actionModifyTrim2);
875 connect(actionModifyTrim2, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim2()));
876 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim2, SLOT(setEnabled(bool)));
877 // action = actionFactory.createAction(RS2::ActionModifyTrimAmount, actionHandler);
878 menu->addAction(actionModifyTrimAmount);
879 connect(actionModifyTrimAmount, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrimAmount()));
880 connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrimAmount, SLOT(setEnabled(bool)));
881 // action = actionFactory.createAction(RS2::ActionModifyBevel, actionHandler);
882 menu->addAction(actionModifyBevel);
883 connect(actionModifyBevel, SIGNAL(activated()), actionHandler, SLOT(slotModifyBevel()));
884 connect(this, SIGNAL(windowsChanged(bool)), actionModifyBevel, SLOT(setEnabled(bool)));
885 // action = actionFactory.createAction(RS2::ActionModifyRound, actionHandler);
886 menu->addAction(actionModifyRound);
887 connect(actionModifyRound, SIGNAL(activated()), actionHandler, SLOT(slotModifyRound()));
888 connect(this, SIGNAL(windowsChanged(bool)), actionModifyRound, SLOT(setEnabled(bool)));
889 // action = actionFactory.createAction(RS2::ActionModifyCut, actionHandler);
890 menu->addAction(actionModifyCut);
891 connect(actionModifyCut, SIGNAL(activated()), actionHandler, SLOT(slotModifyCut()));
892 connect(this, SIGNAL(windowsChanged(bool)), actionModifyCut, SLOT(setEnabled(bool)));
893 // action = actionFactory.createAction(RS2::ActionModifyStretch, actionHandler);
894 menu->addAction(actionModifyStretch);
895 connect(actionModifyStretch, SIGNAL(activated()), actionHandler, SLOT(slotModifyStretch()));
896 connect(this, SIGNAL(windowsChanged(bool)), actionModifyStretch, SLOT(setEnabled(bool)));
897 // action = actionFactory.createAction(RS2::ActionModifyEntity, actionHandler);
898 menu->addAction(actionModifyEntity);
899 connect(actionModifyEntity, SIGNAL(activated()), actionHandler, SLOT(slotModifyEntity()));
900 connect(this, SIGNAL(windowsChanged(bool)), actionModifyEntity, SLOT(setEnabled(bool)));
901 // action = actionFactory.createAction(RS2::ActionModifyAttributes, actionHandler);
902 menu->addAction(actionModifyAttributes);
903 connect(actionModifyAttributes, SIGNAL(activated()), actionHandler, SLOT(slotModifyAttributes()));
904 connect(this, SIGNAL(windowsChanged(bool)), actionModifyAttributes, SLOT(setEnabled(bool)));
905 // action = actionFactory.createAction(RS2::ActionModifyDelete, actionHandler);
906 menu->addAction(actionModifyDelete);
907 connect(actionModifyDelete, SIGNAL(activated()), actionHandler, SLOT(slotModifyDelete()));
908 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDelete, SLOT(setEnabled(bool)));
909 // action = actionFactory.createAction(RS2::ActionModifyDeleteQuick, actionHandler);
910 menu->addAction(actionModifyDeleteQuick);
911 connect(actionModifyDeleteQuick, SIGNAL(activated()), actionHandler, SLOT(slotModifyDeleteQuick()));
912 connect(this, SIGNAL(windowsChanged(bool)), actionModifyDeleteQuick, SLOT(setEnabled(bool)));
913 // action = actionFactory.createAction(RS2::ActionModifyExplodeText, actionHandler);
914 menu->addAction(actionModifyExplodeText);
915 connect(actionModifyExplodeText, SIGNAL(activated()), actionHandler, SLOT(slotModifyExplodeText()));
916 connect(this, SIGNAL(windowsChanged(bool)), actionModifyExplodeText, SLOT(setEnabled(bool)));
917 //// action = actionFactory.createAction(RS2::ActionModifyDeleteFree, actionHandler);
918 //// menu->addAction(action);
919 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
920 menu->addAction(actionBlocksExplode);
921 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
922 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
923 menuBar()->addMenu(menu);
927 menu = new QMenu(tr("&Snap"), this);
928 // action = actionFactory.createAction(RS2::ActionSnapFree, actionHandler);
929 menu->addAction(actionSnapFree);
930 actionHandler->setActionSnapFree(actionSnapFree); // ???Why???
931 connect(actionSnapFree, SIGNAL(activated()), actionHandler, SLOT(slotSnapFree()));
932 connect(this, SIGNAL(windowsChanged(bool)), actionSnapFree, SLOT(setEnabled(bool)));
933 actionSnapFree->setChecked(true);
934 // action = actionFactory.createAction(RS2::ActionSnapGrid, actionHandler);
935 menu->addAction(actionSnapGrid);
936 actionHandler->setActionSnapGrid(actionSnapGrid); // ???Why???
937 connect(actionSnapGrid, SIGNAL(activated()), actionHandler, SLOT(slotSnapGrid()));
938 connect(this, SIGNAL(windowsChanged(bool)), actionSnapGrid, SLOT(setEnabled(bool)));
939 // action = actionFactory.createAction(RS2::ActionSnapEndpoint, actionHandler);
940 menu->addAction(actionSnapEndpoint);
941 actionHandler->setActionSnapEndpoint(actionSnapEndpoint); // ???Why???
942 connect(actionSnapEndpoint, SIGNAL(activated()), actionHandler, SLOT(slotSnapEndpoint()));
943 connect(this, SIGNAL(windowsChanged(bool)), actionSnapEndpoint, SLOT(setEnabled(bool)));
944 // action = actionFactory.createAction(RS2::ActionSnapOnEntity, actionHandler);
945 menu->addAction(actionSnapOnEntity);
946 actionHandler->setActionSnapOnEntity(actionSnapOnEntity); // ???Why???
947 connect(actionSnapOnEntity, SIGNAL(activated()), actionHandler, SLOT(slotSnapOnEntity()));
948 connect(this, SIGNAL(windowsChanged(bool)), actionSnapOnEntity, SLOT(setEnabled(bool)));
949 // action = actionFactory.createAction(RS2::ActionSnapCenter, actionHandler);
950 menu->addAction(actionSnapCenter);
951 actionHandler->setActionSnapCenter(actionSnapCenter); // ???Why???
952 connect(actionSnapCenter, SIGNAL(activated()), actionHandler, SLOT(slotSnapCenter()));
953 connect(this, SIGNAL(windowsChanged(bool)), actionSnapCenter, SLOT(setEnabled(bool)));
954 // action = actionFactory.createAction(RS2::ActionSnapMiddle, actionHandler);
955 menu->addAction(actionSnapMiddle);
956 actionHandler->setActionSnapMiddle(actionSnapMiddle); // ???Why???
957 connect(actionSnapMiddle, SIGNAL(activated()), actionHandler, SLOT(slotSnapMiddle()));
958 connect(this, SIGNAL(windowsChanged(bool)), actionSnapMiddle, SLOT(setEnabled(bool)));
959 // action = actionFactory.createAction(RS2::ActionSnapDist, actionHandler);
960 menu->addAction(actionSnapDist);
961 actionHandler->setActionSnapDist(actionSnapDist); // ???Why???
962 connect(actionSnapDist, SIGNAL(activated()), actionHandler, SLOT(slotSnapDist()));
963 connect(this, SIGNAL(windowsChanged(bool)), actionSnapDist, SLOT(setEnabled(bool)));
964 // action = actionFactory.createAction(RS2::ActionSnapIntersection, actionHandler);
965 menu->addAction(actionSnapIntersection);
966 actionHandler->setActionSnapIntersection(actionSnapIntersection); // ???Why???
967 connect(actionSnapIntersection, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersection()));
968 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersection, SLOT(setEnabled(bool)));
969 // action = actionFactory.createAction(RS2::ActionSnapIntersectionManual, actionHandler);
970 menu->addAction(actionSnapIntersectionManual);
971 actionHandler->setActionSnapIntersectionManual(actionSnapIntersectionManual); // ???Why???
972 connect(actionSnapIntersectionManual, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersectionManual()));
973 connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersectionManual, SLOT(setEnabled(bool)));
975 menu->addSeparator();
977 // action = actionFactory.createAction(RS2::ActionRestrictNothing, actionHandler);
978 menu->addAction(actionRestrictNothing);
979 actionHandler->setActionRestrictNothing(actionRestrictNothing); // ???WHY???
980 connect(actionRestrictNothing, SIGNAL(activated()), actionHandler, SLOT(slotRestrictNothing()));
981 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictNothing, SLOT(setEnabled(bool)));
982 actionRestrictNothing->setChecked(true);
983 // action = actionFactory.createAction(RS2::ActionRestrictOrthogonal, actionHandler);
984 menu->addAction(actionRestrictOrthogonal);
985 actionHandler->setActionRestrictOrthogonal(actionRestrictOrthogonal); // ???WHY???
986 connect(actionRestrictOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictOrthogonal()));
987 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictOrthogonal, SLOT(setEnabled(bool)));
988 // action = actionFactory.createAction(RS2::ActionRestrictHorizontal, actionHandler);
989 menu->addAction(actionRestrictHorizontal);
990 actionHandler->setActionRestrictHorizontal(actionRestrictHorizontal); // ???WHY???
991 connect(actionRestrictHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictHorizontal()));
992 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictHorizontal, SLOT(setEnabled(bool)));
993 // action = actionFactory.createAction(RS2::ActionRestrictVertical, actionHandler);
994 menu->addAction(actionRestrictVertical);
995 actionHandler->setActionRestrictVertical(actionRestrictVertical); // ???WHY???
996 connect(actionRestrictVertical, SIGNAL(activated()), actionHandler, SLOT(slotRestrictVertical()));
997 connect(this, SIGNAL(windowsChanged(bool)), actionRestrictVertical, SLOT(setEnabled(bool)));
999 menu->addSeparator();
1001 // action = actionFactory.createAction(RS2::ActionSetRelativeZero, actionHandler);
1002 menu->addAction(actionSetRelativeZero);
1003 connect(actionSetRelativeZero, SIGNAL(activated()), actionHandler, SLOT(slotSetRelativeZero()));
1004 connect(this, SIGNAL(windowsChanged(bool)), actionSetRelativeZero, SLOT(setEnabled(bool)));
1005 // action = actionFactory.createAction(RS2::ActionLockRelativeZero, actionHandler);
1006 menu->addAction(actionLockRelativeZero);
1007 actionHandler->setActionLockRelativeZero(actionLockRelativeZero);
1008 connect(actionLockRelativeZero, SIGNAL(toggled(bool)), actionHandler, SLOT(slotLockRelativeZero(bool))); // ???WHY???
1009 connect(this, SIGNAL(windowsChanged(bool)), actionLockRelativeZero, SLOT(setEnabled(bool)));
1010 menuBar()->addMenu(menu);
1015 menu = new QMenu(tr("&Info"), this);
1016 //action = actionFactory.createAction(RS2::ActionInfoInside, actionHandler);
1017 //menu->addAction(action);
1018 menu->addAction(actionInfoDist);
1019 connect(actionInfoDist, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist()));
1020 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist, SLOT(setEnabled(bool)));
1021 menu->addAction(actionInfoDist2);
1022 connect(actionInfoDist2, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist2()));
1023 connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist2, SLOT(setEnabled(bool)));
1024 menu->addAction(actionInfoAngle);
1025 connect(actionInfoAngle, SIGNAL(activated()), actionHandler, SLOT(slotInfoAngle()));
1026 connect(this, SIGNAL(windowsChanged(bool)), actionInfoAngle, SLOT(setEnabled(bool)));
1027 menu->addAction(actionInfoTotalLength);
1028 connect(actionInfoTotalLength, SIGNAL(activated()), actionHandler, SLOT(slotInfoTotalLength()));
1029 connect(this, SIGNAL(windowsChanged(bool)), actionInfoTotalLength, SLOT(setEnabled(bool)));
1030 menu->addAction(actionInfoArea);
1031 connect(actionInfoArea, SIGNAL(activated()), actionHandler, SLOT(slotInfoArea()));
1032 connect(this, SIGNAL(windowsChanged(bool)), actionInfoArea, SLOT(setEnabled(bool)));
1033 menuBar()->addMenu(menu);
1038 menu = new QMenu(tr("&Layer"), this);
1039 // action = actionFactory.createAction(RS2::ActionLayersDefreezeAll, actionHandler);
1040 menu->addAction(actionLayersDefreezeAll);
1041 connect(actionLayersDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersDefreezeAll()));
1042 connect(this, SIGNAL(windowsChanged(bool)), actionLayersDefreezeAll, SLOT(setEnabled(bool)));
1043 // action = actionFactory.createAction(RS2::ActionLayersFreezeAll, actionHandler);
1044 menu->addAction(actionLayersFreezeAll);
1045 connect(actionLayersFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersFreezeAll()));
1046 connect(this, SIGNAL(windowsChanged(bool)), actionLayersFreezeAll, SLOT(setEnabled(bool)));
1047 // action = actionFactory.createAction(RS2::ActionLayersAdd, actionHandler);
1048 menu->addAction(actionLayersAdd);
1049 connect(actionLayersAdd, SIGNAL(activated()), actionHandler, SLOT(slotLayersAdd()));
1050 connect(this, SIGNAL(windowsChanged(bool)), actionLayersAdd, SLOT(setEnabled(bool)));
1051 // action = actionFactory.createAction(RS2::ActionLayersRemove, actionHandler);
1052 menu->addAction(actionLayersRemove);
1053 connect(actionLayersRemove, SIGNAL(activated()), actionHandler, SLOT(slotLayersRemove()));
1054 connect(this, SIGNAL(windowsChanged(bool)), actionLayersRemove, SLOT(setEnabled(bool)));
1055 // action = actionFactory.createAction(RS2::ActionLayersEdit, actionHandler);
1056 menu->addAction(actionLayersEdit);
1057 connect(actionLayersEdit, SIGNAL(activated()), actionHandler, SLOT(slotLayersEdit()));
1058 connect(this, SIGNAL(windowsChanged(bool)), actionLayersEdit, SLOT(setEnabled(bool)));
1059 // action = actionFactory.createAction(RS2::ActionLayersToggleView, actionHandler);
1060 menu->addAction(actionLayersToggleView);
1061 connect(actionLayersToggleView, SIGNAL(activated()), actionHandler, SLOT(slotLayersToggleView()));
1062 connect(this, SIGNAL(windowsChanged(bool)), actionLayersToggleView, SLOT(setEnabled(bool)));
1063 menuBar()->addMenu(menu);
1067 menu = new QMenu(tr("&Block"), this);
1068 // action = actionFactory.createAction(RS2::ActionBlocksDefreezeAll, actionHandler);
1069 menu->addAction(actionBlocksDefreezeAll);
1070 connect(actionBlocksDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksDefreezeAll()));
1071 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksDefreezeAll, SLOT(setEnabled(bool)));
1072 // action = actionFactory.createAction(RS2::ActionBlocksFreezeAll, actionHandler);
1073 menu->addAction(actionBlocksFreezeAll);
1074 connect(actionBlocksFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksFreezeAll()));
1075 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksFreezeAll, SLOT(setEnabled(bool)));
1076 // action = actionFactory.createAction(RS2::ActionBlocksAdd, actionHandler);
1077 menu->addAction(actionBlocksAdd);
1078 connect(actionBlocksAdd, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAdd()));
1079 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAdd, SLOT(setEnabled(bool)));
1080 // action = actionFactory.createAction(RS2::ActionBlocksRemove, actionHandler);
1081 menu->addAction(actionBlocksRemove);
1082 connect(actionBlocksRemove, SIGNAL(activated()), actionHandler, SLOT(slotBlocksRemove()));
1083 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksRemove, SLOT(setEnabled(bool)));
1084 // action = actionFactory.createAction(RS2::ActionBlocksAttributes, actionHandler);
1085 menu->addAction(actionBlocksAttributes);
1086 connect(actionBlocksAttributes, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAttributes()));
1087 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAttributes, SLOT(setEnabled(bool)));
1088 // action = actionFactory.createAction(RS2::ActionBlocksInsert, actionHandler);
1089 menu->addAction(actionBlocksInsert);
1090 connect(actionBlocksInsert, SIGNAL(activated()), actionHandler, SLOT(slotBlocksInsert()));
1091 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksInsert, SLOT(setEnabled(bool)));
1092 // action = actionFactory.createAction(RS2::ActionBlocksEdit, actionHandler);
1093 menu->addAction(actionBlocksEdit);
1094 connect(actionBlocksEdit, SIGNAL(activated()), actionHandler, SLOT(slotBlocksEdit()));
1095 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksEdit, SLOT(setEnabled(bool)));
1096 // action = actionFactory.createAction(RS2::ActionBlocksCreate, actionHandler);
1097 menu->addAction(actionBlocksCreate);
1098 connect(actionBlocksCreate, SIGNAL(activated()), actionHandler, SLOT(slotBlocksCreate()));
1099 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksCreate, SLOT(setEnabled(bool)));
1100 // action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler);
1101 menu->addAction(actionBlocksExplode);
1102 connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode()));
1103 connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool)));
1104 menuBar()->addMenu(menu);
1106 //will *this* make a toolbar break for us???
1107 addToolBarBreak(Qt::TopToolBarArea);
1108 // addDockWindow(penToolBar, tr("Pen"), Qt::DockTop);
1109 // addDockWindow(optionWidget, tr("Tool Options"), Qt::DockTop, true);
1110 addToolBar(Qt::TopToolBarArea, (QToolBar *)penToolBar); // hmm.
1111 addToolBar(Qt::TopToolBarArea, optionWidget);
1116 scriptMenu = new QMenu(this);
1117 scriptOpenIDE = actionFactory.createAction(RS2::ActionScriptOpenIDE, this);
1118 scriptOpenIDE->addTo(scriptMenu);
1119 scriptRun = actionFactory.createAction(RS2::ActionScriptRun, this);
1120 scriptRun->addTo(scriptMenu);
1123 scriptOpenIDE = NULL;
1129 menu = new QMenu(tr("&CAM"), this);
1130 action = actionFactory.createAction(RS2::ActionCamExportAuto, actionHandler);
1131 menu->addAction(action);
1132 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1133 action = actionFactory.createAction(RS2::ActionCamReorder, actionHandler);
1134 menu->addAction(action);
1135 connect(this, SIGNAL(windowsChanged(bool)), action, SLOT(setEnabled(bool)));
1136 menuBar()->addMenu(menu);
1141 helpAboutApp = new QAction(QIcon(QC_APP_ICON16), tr("&About Architektonas"), this);
1142 // helpAboutApp = new QAction(tr("About"), qPixmapFromMimeSource(QC_APP_ICON16), tr("&About %1").arg(QC_APPNAME), 0, this);
1143 helpAboutApp->setStatusTip(tr("About the application"));
1144 //helpAboutApp->setWhatsThis(tr("About\n\nAbout the application"));
1145 connect(helpAboutApp, SIGNAL(activated()), this, SLOT(slotHelpAbout()));
1147 helpManual = new QAction(QIcon(":/res/contents.png"), tr("&Manual"), this);
1148 helpManual->setShortcut(Qt::Key_F1);
1149 // helpManual = new QAction(qPixmapFromMimeSource("contents.png"), tr("&Manual"), Qt::Key_F1, this);
1150 helpManual->setStatusTip(tr("Launch the online manual"));
1151 connect(helpManual, SIGNAL(activated()), this, SLOT(slotHelpManual()));
1153 testDumpEntities = new QAction("Dump &Entities", this);
1154 // testDumpEntities = new QAction("Dump Entities", "Dump &Entities", 0, this);
1155 connect(testDumpEntities, SIGNAL(activated()), this, SLOT(slotTestDumpEntities()));
1157 testDumpUndo = new QAction("Undo Info", this);
1158 // testDumpUndo = new QAction("Dump Undo Info", "Undo Info", 0, this);
1159 connect(testDumpUndo, SIGNAL(activated()), this, SLOT(slotTestDumpUndo()));
1161 testUpdateInserts = new QAction("&Update Inserts", this);
1162 // testUpdateInserts = new QAction("Update Inserts", "&Update Inserts", 0, this);
1163 connect(testUpdateInserts, SIGNAL(activated()), this, SLOT(slotTestUpdateInserts()));
1165 testDrawFreehand = new QAction("Draw Freehand", this);
1166 // testDrawFreehand = new QAction("Draw Freehand", "Draw Freehand", 0, this);
1167 connect(testDrawFreehand, SIGNAL(activated()), this, SLOT(slotTestDrawFreehand()));
1169 testInsertBlock = new QAction("Insert Block", this);
1170 // testInsertBlock = new QAction("Insert Block", "Insert Block", 0, this);
1171 connect(testInsertBlock, SIGNAL(activated()), this, SLOT(slotTestInsertBlock()));
1173 testInsertText = new QAction("Insert Text", this);
1174 // testInsertText = new QAction("Insert Text", "Insert Text", 0, this);
1175 connect(testInsertText, SIGNAL(activated()), this, SLOT(slotTestInsertText()));
1177 testInsertImage = new QAction("Insert Image", this);
1178 // testInsertImage = new QAction("Insert Image", "Insert Image", 0, this);
1179 connect(testInsertImage, SIGNAL(activated()), this, SLOT(slotTestInsertImage()));
1181 testUnicode = new QAction("Unicode", this);
1182 // testUnicode = new QAction("Unicode", "Unicode", 0, this);
1183 connect(testUnicode, SIGNAL(activated()), this, SLOT(slotTestUnicode()));
1185 testInsertEllipse = new QAction("Insert Ellipse", this);
1186 // testInsertEllipse = new QAction("Insert Ellipse", "Insert Ellipse", 0, this);
1187 connect(testInsertEllipse, SIGNAL(activated()), this, SLOT(slotTestInsertEllipse()));
1189 testMath01 = new QAction("Math01", this);
1190 // testMath01 = new QAction("Math01", "Math01", 0, this);
1191 connect(testMath01, SIGNAL(activated()), this, SLOT(slotTestMath01()));
1193 testResize640 = new QAction("Resize 1", this);
1194 // testResize640 = new QAction("Resize to 640x480", "Resize 1", 0, this);
1195 connect(testResize640, SIGNAL(activated()), this, SLOT(slotTestResize640()));
1197 testResize800 = new QAction("Resize 2", this);
1198 // testResize800 = new QAction("Resize to 800x600", "Resize 2", 0, this);
1199 connect(testResize800, SIGNAL(activated()), this, SLOT(slotTestResize800()));
1201 testResize1024 = new QAction("Resize 3", this);
1202 // testResize1024 = new QAction("Resize to 1024x768", "Resize 3", 0, this);
1203 connect(testResize1024, SIGNAL(activated()), this, SLOT(slotTestResize1024()));
1207 * Initializes the menu bar.
1209 void QC_ApplicationWindow::initMenuBar()
1211 RS_DEBUG->print("QC_ApplicationWindow::initMenuBar()");
1213 // menuBar entry windowsMenu
1214 windowsMenu = new QMenu(tr("&Window"), this);
1215 //according to docs, this is obsolete: windowsMenu->setCheckable(true);
1216 connect(windowsMenu, SIGNAL(aboutToShow()), this, SLOT(slotWindowsMenuAboutToShow()));
1218 // menuBar entry scriptMenu
1219 //scriptMenu = new QPopupMenu(this);
1220 //scriptMenu->setCheckable(true);
1221 //scriptOpenIDE->addTo(scriptMenu);
1222 //scriptRun->addTo(scriptMenu);
1223 //connect(scriptMenu, SIGNAL(aboutToShow()), this, SLOT(slotScriptMenuAboutToShow()));
1225 // menuBar entry helpMenu
1226 helpMenu = new QMenu(tr("&Help"), this);
1227 helpMenu->addAction(helpManual);//helpManual->addTo(helpMenu);
1229 // helpMenu->insertSeparator(helpManual);
1230 helpMenu->addSeparator();
1232 helpMenu->addAction(helpAboutApp);//helpAboutApp->addTo(helpMenu);
1234 // menuBar entry test menu
1235 testMenu = new QMenu(tr("De&bugging"), this);
1236 testMenu->addAction(testDumpEntities);//testDumpEntities->addTo(testMenu);
1237 testMenu->addAction(testDumpUndo);//testDumpUndo->addTo(testMenu);
1238 testMenu->addAction(testUpdateInserts);//testUpdateInserts->addTo(testMenu);
1239 testMenu->addAction(testDrawFreehand);//testDrawFreehand->addTo(testMenu);
1240 testMenu->addAction(testInsertBlock);//testInsertBlock->addTo(testMenu);
1241 testMenu->addAction(testInsertText);//testInsertText->addTo(testMenu);
1242 testMenu->addAction(testInsertImage);//testInsertImage->addTo(testMenu);
1243 testMenu->addAction(testInsertEllipse);//testInsertEllipse->addTo(testMenu);
1244 testMenu->addAction(testUnicode);//testUnicode->addTo(testMenu);
1245 testMenu->addAction(testMath01);//testMath01->addTo(testMenu);
1246 testMenu->addAction(testResize640);//testResize640->addTo(testMenu);
1247 testMenu->addAction(testResize800);//testResize800->addTo(testMenu);
1248 testMenu->addAction(testResize1024);//testResize1024->addTo(testMenu);
1250 // menuBar configuration
1252 // menuBar()->insertItem(tr("&Scripts"), scriptMenu);
1253 menuBar()->addMenu(scriptMenu);
1255 // menuBar()->insertItem(tr("&Window"), windowsMenu);
1256 menuBar()->addMenu(windowsMenu);
1258 // menuBar()->insertSeparator();
1259 // menuBar()->insertItem(tr("&Help"), helpMenu);
1260 menuBar()->addMenu(helpMenu);
1263 // menuBar()->insertItem(tr("De&bugging"), testMenu);
1264 menuBar()->addMenu(testMenu);
1266 recentFiles = new QG_RecentFiles(this, fileMenu);
1270 * Initializes the tool bars (file tool bar and pen tool bar).
1272 void QC_ApplicationWindow::initToolBar()
1274 RS_DEBUG->print("QC_ApplicationWindow::initToolBar()");
1276 // fileToolBar = new Q3ToolBar(this, "File Operations");
1277 fileToolBar = addToolBar(tr("File Operations"));
1278 fileToolBar->setObjectName("file");
1279 // editToolBar = new Q3ToolBar(this, "Edit Operations");
1280 editToolBar = addToolBar(tr("Edit Operations"));
1281 editToolBar->setObjectName("edit");
1282 // zoomToolBar = new Q3ToolBar(this, "Zoom Operations");
1283 zoomToolBar = addToolBar(tr("Zoom Operations"));
1284 zoomToolBar->setObjectName("zoom");
1285 penToolBar = new QG_PenToolBar(this, "Pen Selection");
1286 penToolBar->setObjectName("pen");
1288 connect(penToolBar, SIGNAL(penChanged(RS_Pen)), this, SLOT(slotPenChanged(RS_Pen)));
1290 // optionWidget = new Q3ToolBar(this, "Tool Options");
1291 //addToolBarBreak() does nothing...
1292 #warning "!!! add/insertToolBarBreak() does nothing !!!"
1293 // addToolBarBreak(Qt::TopToolBarArea);
1294 optionWidget = addToolBar(tr("Tool Options"));
1295 optionWidget->setObjectName("tooloptions");
1296 optionWidget->setMinimumHeight(26);
1297 optionWidget->setMaximumHeight(26);
1298 #warning "!!! No analogue found for setHorizontallyStretchable yet !!!"
1299 //Maybe sizePolicy or somesuch??
1300 optionWidget->setMinimumWidth(150);
1301 optionWidget->setMaximumWidth(800);
1302 #warning "Following line commented out..."
1303 // optionWidget->setFixedExtentHeight(26);
1304 // optionWidget->setHorizontallyStretchable(true);
1305 // addDockWindow(optionWidget, DockTop, true);
1307 // CAD toolbar left:
1308 // Q3ToolBar * t = new Q3ToolBar(this, "CAD Tools");
1309 QToolBar * t = addToolBar(tr("CAD Tools"));
1310 t->setObjectName("cadtools");
1311 #warning "Following two lines commented out..."
1312 // t->setFixedExtentWidth(59);
1313 t->setMinimumWidth(59);
1314 t->setMaximumWidth(59);
1315 // t->setVerticallyStretchable(true);
1316 // addDockWindow(t, Qt::DockLeft, false);
1317 addToolBar(Qt::LeftToolBarArea, t);
1319 cadToolBar = new CadToolBar(t);//, "CAD Tools");
1320 cadToolBar->createSubToolBars(actionHandler);
1322 connect(cadToolBar, SIGNAL(signalBack()), this, SLOT(slotBack()));
1323 connect(this, SIGNAL(windowsChanged(bool)), cadToolBar, SLOT(setEnabled(bool)));
1325 // QG_CadToolBarMain * cadToolBarMain = new QG_CadToolBarMain(cadToolBar);
1326 //No, no break inserted here either...
1327 // insertToolBarBreak(optionWidget);
1331 * Initializes the status bar at the bottom.
1333 void QC_ApplicationWindow::initStatusBar()
1335 RS_DEBUG->print("QC_ApplicationWindow::initStatusBar()");
1337 statusBar()->setMinimumHeight(32);
1338 coordinateWidget = new CoordinateWidget(statusBar());//, "coordinates");
1339 statusBar()->addWidget(coordinateWidget);
1340 mouseWidget = new MouseWidget(statusBar());//, "mouse info");
1341 statusBar()->addWidget(mouseWidget);
1342 selectionWidget = new SelectionWidget(statusBar());//, "selections");
1343 statusBar()->addWidget(selectionWidget);
1347 * Initializes the global application settings from the
1348 * config file (unix, mac) or registry (windows).
1350 void QC_ApplicationWindow::initSettings()
1352 RS_DEBUG->print("QC_ApplicationWindow::initSettings()");
1353 settings.beginGroup("RecentFiles");
1355 for(int i=0; i<recentFiles->Maximum(); ++i)
1357 QString filename = settings.value(QString("File") + QString::number(i + 1)).toString();
1359 if (!filename.isEmpty())
1360 // recentFiles->add(filename);
1361 recentFiles->add(filename);
1364 settings.endGroup();
1366 if (recentFiles->count() > 0)
1367 // updateRecentFilesMenu();
1368 recentFiles->UpdateGUI();
1370 settings.beginGroup("Geometry");
1371 QSize windowSize = settings.value("WindowSize", QSize(950, 700)).toSize();
1372 QPoint windowPos = settings.value("WindowPos", QPoint(0, 30)).toPoint();
1373 restoreState(settings.value("DockWindows").toByteArray());
1374 settings.endGroup();
1377 // if (windowY < 30)
1379 if (windowSize.y() < 30)
1380 windowSize.y() = 30;
1388 * Stores the global application settings to file or registry.
1390 void QC_ApplicationWindow::storeSettings()
1392 RS_DEBUG->print("QC_ApplicationWindow::storeSettings()");
1394 settings.beginGroup("RecentFiles");
1396 for(int i=0; i<recentFiles->count(); ++i)
1397 settings.setValue(QString("File") + QString::number(i + 1), recentFiles->get(i));
1399 settings.endGroup();
1401 settings.beginGroup("Geometry");
1402 settings.setValue("WindowSize", size());
1403 settings.setValue("WindowPos", pos());
1404 settings.setValue("DockWindows", saveState());
1405 settings.endGroup();
1407 RS_DEBUG->print("QC_ApplicationWindow::storeSettings(): OK");
1411 * Initializes the view.
1413 void QC_ApplicationWindow::initView()
1415 RS_DEBUG->print("QC_ApplicationWindow::initView()");
1417 RS_DEBUG->print("init view..");
1421 libraryWidget = NULL;
1422 commandWidget = NULL;
1424 simulationControls = NULL;
1428 RS_DEBUG->print(" simulation widget..");
1429 dw = new QDockWidget(QDockWidget::InDock, this, "Simulation");
1430 simulationControls = new RS_SimulationControls(dw, "Simulation");
1431 simulationControls->setFocusPolicy(Qt::NoFocus);
1432 connect(simulationControls, SIGNAL(escape()), this, SLOT(slotFocus()));
1433 connect(this, SIGNAL(windowsChanged(bool)), simulationControls, SLOT(setEnabled(bool)));
1434 dw->setWidget(simulationControls);
1435 dw->resize(240, 80);
1436 dw->setResizeEnabled(true);
1437 dw->setFixedExtentWidth(120);
1438 dw->setFixedHeight(80);
1439 dw->setCaption(tr("Simulation Controls"));
1440 dw->setCloseMode(Q3DockWindow::Always);
1441 addDockWindow(dw, Qt::DockRight);
1442 simulationDockWindow = dw;
1443 //simulationDockWindow->hide();
1446 RS_DEBUG->print(" layer widget..");
1447 // dw = new QDockWidget(QDockWidget::InDock, this, "Layer");
1448 dw = new QDockWidget(tr("Layer List"), this);
1449 dw->setObjectName("layer");
1450 layerWidget = new QG_LayerWidget(actionHandler, dw, "Layer");
1451 layerWidget->setFocusPolicy(Qt::NoFocus);
1452 connect(layerWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1453 connect(this, SIGNAL(windowsChanged(bool)), layerWidget, SLOT(setEnabled(bool)));
1454 dw->setWidget(layerWidget);
1455 #warning "following four lines commented out..."
1456 // dw->setFixedExtentWidth(120);
1457 // dw->setResizeEnabled(true);
1458 // dw->setCloseMode(Q3DockWindow::Always);
1459 // dw->setCaption(tr("Layer List"));
1460 addDockWidget(Qt::RightDockWidgetArea, dw);
1461 layerDockWindow = dw;
1463 RS_DEBUG->print(" block widget..");
1464 // dw = new QDockWidget(QDockWidget::InDock, this, "Block");
1465 dw = new QDockWidget(tr("Block List"), this);
1466 dw->setObjectName("block");
1467 blockWidget = new QG_BlockWidget(actionHandler, dw, "Block");
1468 blockWidget->setFocusPolicy(Qt::NoFocus);
1469 connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1470 connect(this, SIGNAL(windowsChanged(bool)), blockWidget, SLOT(setEnabled(bool)));
1471 dw->setWidget(blockWidget);
1472 #warning "following four lines commented out..."
1473 // dw->setFixedExtentWidth(120);
1474 // dw->setResizeEnabled(true);
1475 // dw->setCloseMode(Q3DockWindow::Always);
1476 // dw->setCaption(tr("Block List"));
1477 addDockWidget(Qt::RightDockWidgetArea, dw);
1478 blockDockWindow = dw;
1480 RS_DEBUG->print(" library widget..");
1481 // dw = new QDockWidget(QDockWidget::OutsideDock, this, "Library");
1482 dw = new QDockWidget(tr("Library Browser"), this);
1483 dw->setObjectName("library");
1484 libraryWidget = new LibraryWidget(dw);//WAS:, "Library");
1485 libraryWidget->setActionHandler(actionHandler);
1486 libraryWidget->setFocusPolicy(Qt::NoFocus);
1487 connect(libraryWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1489 // connect(this, SIGNAL(windowsChanged(bool)), (QObject *)libraryWidget->bInsert, SLOT(setEnabled(bool)));
1490 dw->setWidget(libraryWidget);
1491 dw->resize(240, 400);
1492 #warning "following three lines commented out..."
1493 // dw->setResizeEnabled(true);
1494 // dw->setCloseMode(Q3DockWindow::Always);
1495 // dw->setCaption(tr("Library Browser"));
1496 //not sure how to fix this one
1497 #warning "QMainWindow::addDockWidget: invalid 'area' argument"
1498 addDockWidget(Qt::NoDockWidgetArea, dw);
1499 libraryDockWindow = dw;
1500 libraryDockWindow->hide();
1502 RS_DEBUG->print(" command widget..");
1503 // dw = new QDockWidget(QDockWidget::InDock, this, "Command");
1504 dw = new QDockWidget(tr("Command line"), this);
1505 dw->setObjectName("command");
1506 commandWidget = new CommandWidget(dw);//WAS:, "Command");
1507 commandWidget->setActionHandler(actionHandler);
1508 // commandWidget->redirectStderr();
1509 // std::cerr << "Ready.\n";
1510 // commandWidget->processStderr();
1511 connect(this, SIGNAL(windowsChanged(bool)), commandWidget, SLOT(setEnabled(bool)));
1512 dw->setWidget(commandWidget);
1513 #warning "following four lines commented out..."
1514 // dw->setFixedExtentHeight(45);
1515 // dw->setResizeEnabled(true);
1516 // dw->setCloseMode(QDockWidget::Always);
1517 // dw->setCaption(tr("Command line"));
1518 commandDockWindow = dw;
1519 addDockWidget(Qt::BottomDockWidgetArea, dw);
1521 RS_DEBUG->print(" done");
1525 * Creates a new toolbar.
1526 * Implementation from QG_MainWindowInterface.
1527 * Can be called from scripts to add individual GUI elements.
1529 /*QToolBar* QC_ApplicationWindow::createToolBar(const QString& name) {
1530 QToolBar* tb = new QToolBar(this, name);
1536 * Creates a new button in the given tool bar for running a script.
1538 /*void QC_ApplicationWindow::addToolBarButton(QToolBar* tb) {
1540 QAction* action = new QAction("Blah",
1541 QPixmap::fromMimeSource("zoomwindow.png"),
1542 "&Blah", QKeySequence(), NULL);
1543 action->setStatusTip("Blah blah");
1548 #warning "!!! QC_ApplicationWindow::updateRecentFilesMenu() is DEPRECATED !!!"
1550 * Updates the recent file list in the file menu.
1552 void QC_ApplicationWindow::updateRecentFilesMenu()
1554 RS_DEBUG->print("QC_ApplicationWindow::updateRecentFilesMenu()");
1555 RS_DEBUG->print("Updating recent file menu...");
1558 for(int i=0; i<recentFiles->getNumber(); ++i)
1560 QString label = QString("&%1 %2").arg(i + 1).arg(recentFiles->get(i));
1562 if (fileMenu->findItem(i))
1564 RS_DEBUG->print("Changeing item %d", i);
1565 fileMenu->changeItem(i, label);
1567 else if (i < int(recentFiles->count()))
1569 RS_DEBUG->print("Adding item %d", i);
1570 fileMenu->insertItem(label, this, SLOT(slotFileOpenRecent(int)), 0, i);
1574 //#warning "!!! Need to fix QC_ApplicationWindow::updateRecentFilesMenu() !!!"
1575 recentFiles->UpdateGUI();
1580 * Goes back to the previous menu or one step in the current action.
1582 void QC_ApplicationWindow::slotBack()
1584 RS_GraphicView * graphicView = getGraphicView();
1586 if (graphicView != NULL)
1587 graphicView->back();
1590 if (cadToolBar != NULL)
1591 cadToolBar->showToolBar(RS2::ToolBarMain);
1596 * Goes one step further in the current action.
1598 void QC_ApplicationWindow::slotEnter()
1600 if (commandWidget == NULL || !commandWidget->checkFocus())
1602 if (cadToolBar != NULL)
1603 cadToolBar->forceNext();
1606 RS_GraphicView * graphicView = getGraphicView();
1608 if (graphicView != NULL)
1609 graphicView->enter();
1615 * Sets the keyboard focus on the command line.
1617 void QC_ApplicationWindow::slotFocusCommandLine()
1619 if (commandWidget->isVisible())
1620 commandWidget->setFocus();
1624 * Shows the given error on the command line.
1626 void QC_ApplicationWindow::slotError(const QString & msg)
1628 commandWidget->appendHistory(msg);
1632 * Hands focus back to the application window. In the rare event
1633 * of a escape press from the layer widget (e.g after switching desktops
1636 void QC_ApplicationWindow::slotFocus()
1638 //QG_GraphicView* graphicView = getGraphicView();
1639 /*if (graphicView!=NULL) {
1640 graphicView->setFocus();
1648 * Called when a document window was activated.
1650 //void QC_ApplicationWindow::slotWindowActivated(QWidget *)
1651 void QC_ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/)
1653 RS_DEBUG->print("QC_ApplicationWindow::slotWindowActivated begin");
1655 //the following does: return (QC_MDIWindow *)workspace->activeSubWindow();
1656 //which means the subwindow is NOT being activated!!!
1657 QC_MDIWindow * m = getMDIWindow();
1658 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "QC_ApplicationWindow::slotWindowActivated m=%08X", m);
1660 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "QC_ApplicationWindow::slotWindowActivated m->getDoc=%08X", m->getDocument());
1662 if (m != NULL && m->getDocument() != NULL)
1664 //m->setWindowState(WindowMaximized);
1666 RS_DEBUG->print("QC_ApplicationWindow::slotWindowActivated: document: %d", m->getDocument()->getId());
1668 bool showByBlock = m->getDocument()->rtti() == RS2::EntityBlock;
1669 layerWidget->setLayerList(m->getDocument()->getLayerList(), showByBlock);
1670 coordinateWidget->setGraphic(m->getGraphic());
1673 simulationControls->setGraphicView(m->getGraphicView());
1676 // Only graphics show blocks. (blocks don't)
1677 if (m->getDocument()->rtti() == RS2::EntityGraphic)
1678 blockWidget->setBlockList(m->getDocument()->getBlockList());
1680 blockWidget->setBlockList(NULL);
1682 // Update all inserts in this graphic (blocks might have changed):
1683 m->getDocument()->updateInserts();
1684 m->getGraphicView()->redraw();
1686 // set snapmode from snapping menu
1687 actionHandler->updateSnapMode();
1689 // set pen from pen toolbar
1690 slotPenChanged(penToolBar->getPen());
1692 // update toggle button status:
1693 if (m->getGraphic() != NULL)
1695 emit(gridChanged(m->getGraphic()->isGridOn()));
1696 emit(printPreviewChanged(m->getGraphicView()->isPrintPreview()));
1700 //Seems to work now.
1701 //#warning "This is failing... !!! FIX !!!"
1702 // Disable/Enable menu and toolbar items
1703 emit windowsChanged(m != NULL && m->getDocument() != NULL);
1705 RS_DEBUG->print("QC_ApplicationWindow::slotWindowActivated end");
1709 * Called when the menu 'windows' is about to be shown.
1710 * This is used to update the window list in the menu.
1712 void QC_ApplicationWindow::slotWindowsMenuAboutToShow()
1714 RS_DEBUG->print("QC_ApplicationWindow::slotWindowsMenuAboutToShow");
1716 windowsMenu->clear();
1718 int cascadeId = windowsMenu->insertItem(tr("&Cascade"), workspace, SLOT(cascade()));
1719 int tileId = windowsMenu->insertItem(tr("&Tile"), this, SLOT(slotTileVertical()));
1720 int horTileId = windowsMenu->insertItem(tr("Tile &Horizontally"), this, SLOT(slotTileHorizontal()));
1722 if (workspace->subWindowList().isEmpty())
1724 windowsMenu->setItemEnabled(cascadeId, false);
1725 windowsMenu->setItemEnabled(tileId, false);
1726 windowsMenu->setItemEnabled(horTileId, false);
1729 windowsMenu->insertSeparator();
1731 #warning "!!! Qt4 implementation of insertItem is vastly different from Qt3--FIX !!!"
1733 QList<QMdiSubWindow *> windows = workspace->subWindowList();
1735 //#warning "Need to add window numbers underlined so can access windows via keyboard. !!! FIX !!!"
1737 for(int i=0; i<int(windows.count()); ++i)
1739 // int id = windowsMenu->insertItem(windows.at(i)->caption(), this, SLOT(slotWindowsMenuActivated(int)));
1740 //For some reason the triggered() signal created here is type bool... Dunno why...
1741 //It's signalling using the QAction signal, which is type bool (checked or not).
1743 QString actionName = QString("&%1 %2").arg(i + 1).arg(windows.at(i)->windowTitle());
1744 // QAction * action = new QAction(windows.at(i)->windowTitle(), this);
1745 QAction * action = new QAction(actionName, this);
1746 action->setCheckable(true);
1748 action->setChecked(workspace->activeSubWindow() == windows.at(i));
1749 windowsMenu->addAction(action);
1750 connect(windowsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotWindowsMenuActivated(QAction *)));
1751 // connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus()));
1753 QAction * id = windowsMenu->addAction(windows.at(i)->windowTitle(), this,
1754 // SLOT(slotWindowsMenuActivated(int)));
1755 SLOT(slotWindowsMenuActivated(QAction *)));
1757 // windowsMenu->setItemParameter(id, i);
1758 // windowsMenu->setItemChecked(id, workspace->activeSubWindow() == windows.at(i));
1760 id->setChecked(workspace->activeSubWindow() == windows.at(i));
1766 * Called when the user selects a document window from the
1769 //void QC_ApplicationWindow::slotWindowsMenuActivated(int id)
1770 void QC_ApplicationWindow::slotWindowsMenuActivated(QAction * id)
1772 RS_DEBUG->print("QC_ApplicationWindow::slotWindowsMenuActivated");
1774 // QMdiSubWindow * w = workspace->subWindowList().at(id);
1775 QMdiSubWindow * w = workspace->subWindowList().at(id->data().toInt());
1783 * Tiles MDI windows horizontally.
1785 void QC_ApplicationWindow::slotTileHorizontal()
1787 RS_DEBUG->print("QC_ApplicationWindow::slotTileHorizontal");
1790 // primitive horizontal tiling
1791 QWidgetList windows = workspace->windowList();
1793 if (windows.count() == 0)
1796 int heightForEach = workspace->height() / windows.count();
1799 for(int i=0; i<int(windows.count()); ++i)
1801 QWidget * window = windows.at(i);
1803 #warning "Need to port to Qt4... !!! FIX !!!"
1805 if (window->testWState(WState_Maximized))
1809 window->showNormal();
1813 int preferredHeight = window->minimumHeight() + window->parentWidget()->baseSize().height();
1814 int actHeight = QMAX(heightForEach, preferredHeight);
1816 // window->parentWidget()->resize(workspace->width(), actHeight);
1817 window->parentWidget()->setGeometry(0, y, workspace->width(), actHeight);
1821 workspace->tileSubWindows();
1826 * Tiles MDI windows vertically.
1828 void QC_ApplicationWindow::slotTileVertical()
1834 QWidgetList windows = workspace->windowList();
1835 if (windows.count()==0) {
1839 //int heightForEach = workspace->height() / windows.count();
1841 for (int i=0; i<int(windows.count()); ++i) {
1842 QWidget *window = windows.at(i);
1843 if (window->testWState(WState_Maximized)) {
1846 window->showNormal();
1848 //int preferredHeight = window->minimumHeight()
1849 // + window->parentWidget()->baseSize().height();
1850 //int actHeight = QMAX(heightForEach, preferredHeight);
1852 //window->parentWidget()->setGeometry(0, y,
1853 // workspace->width(), actHeight);
1854 //window->parentWidget()->resize(window->parentWidget()->width(),
1855 // window->parentWidget()->height());
1856 //window->resize(window->width(), window->height());
1861 workspace->tileSubWindows();
1870 void QC_ApplicationWindow::slotCamExportAuto() {
1871 printf("CAM export..\n");
1873 RS_Document* d = getDocument();
1875 RS_Graphic* graphic = (RS_Graphic*)d;
1877 RS_CamDialog dlg(graphic, this);
1885 * Called when something changed in the pen tool bar
1886 * (e.g. color, width, style).
1888 void QC_ApplicationWindow::slotPenChanged(RS_Pen pen)
1890 RS_DEBUG->print("QC_ApplicationWindow::slotPenChanged() begin");
1891 RS_DEBUG->print("Setting active pen...");
1892 QC_MDIWindow * m = getMDIWindow();
1895 m->slotPenChanged(pen);
1897 RS_DEBUG->print("QC_ApplicationWindow::slotPenChanged() end");
1901 * Creates a new MDI window with the given document or a new
1902 * document if 'doc' is NULL.
1904 QC_MDIWindow * QC_ApplicationWindow::slotFileNew(RS_Document * doc)
1906 RS_DEBUG->print("QC_ApplicationWindow::slotFileNew() begin");
1911 statusBar()->showMessage(tr("Creating new file..."));
1913 #warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible"
1914 RS_DEBUG->print(" creating MDI window");
1915 // QC_MDIWindow * w = new QC_MDIWindow(doc, workspace, 0, Qt::WA_DeleteOnClose);
1916 QC_MDIWindow * w = new QC_MDIWindow(doc, workspace, 0, Qt::SubWindow);
1917 w->setAttribute(Qt::WA_DeleteOnClose);
1918 // w->setWindowState(WindowMaximized);
1919 connect(w, SIGNAL(signalClosing()), this, SLOT(slotFileClosing()));
1921 if (w->getDocument()->rtti() == RS2::EntityBlock)
1922 // w->setCaption(tr("Block '%1'").arg(((RS_Block *)(w->getDocument()))->getName()));
1923 w->setWindowTitle(tr("Block '%1'").arg(((RS_Block *)(w->getDocument()))->getName()));
1925 // w->setCaption(tr("unnamed document %1").arg(id));
1926 w->setWindowTitle(tr("unnamed document %1").arg(id));
1928 // w->setIcon(qPixmapFromMimeSource("document.png"));
1929 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
1930 w->setWindowIcon(QIcon(":/res/document.png"));
1932 // only graphics offer block lists, blocks don't
1933 RS_DEBUG->print(" adding listeners");
1934 RS_Graphic * graphic = w->getDocument()->getGraphic();
1936 if (graphic != NULL)
1938 // Link the graphic's layer list to the pen tool bar
1939 graphic->addLayerListListener(penToolBar);
1940 // Link the layer list to the layer widget
1941 graphic->addLayerListListener(layerWidget);
1942 // Link the block list to the block widget
1943 graphic->addBlockListListener(blockWidget);
1946 // Link the dialog factory to the mouse widget:
1947 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
1948 // Link the dialog factory to the coordinate widget:
1949 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
1950 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
1951 // Link the dialog factory to the option widget:
1952 // QG_DIALOGFACTORY->setOptionWidget(optionWidget);
1953 // Link the dialog factory to the cad tool bar:
1954 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
1955 // Link the dialog factory to the command widget:
1956 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
1957 // Link the dialog factory to the main app window:
1958 QG_DIALOGFACTORY->setMainWindow(this);
1960 #if 1 //bugfix for Qt3->4 conversion
1961 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "QC_ApplicationWindow::slotFileNew: adding window to workspace...");
1962 // workspace->addWindow(w);
1963 workspace->addSubWindow(w);
1966 RS_DEBUG->print(" showing MDI window");
1969 #warning "w->showMaximized() doesn't seem to do anything here..."
1970 //but then again, the subWindowList isn't going to be empty at this point either...
1971 if (workspace->subWindowList().isEmpty())
1977 #warning "!!! SubWindow is not being activated !!!"
1978 //neither of these is working... Is the event being eaten somewhere???
1979 // workspace->activateNextSubWindow();
1981 //printf("--> QC_ApplicationWindow::slotFileNew(): w %s focus...\n", (w->hasFocus() ? "has" : "DOES NOT HAVE"));
1984 #warning "!!! Parameter to slotWindowActivated() is ignored !!!"
1985 slotWindowActivated(w);
1986 statusBar()->showMessage(tr("New Drawing created."), 2000);
1988 RS_DEBUG->print("QC_ApplicationWindow::slotFileNew() OK");
1995 * Menu file -> open.
1997 void QC_ApplicationWindow::slotFileOpen()
1999 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen()");
2001 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen() 001");
2002 RS2::FormatType type = RS2::FormatUnknown;
2003 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen() 002");
2004 QString fileName = QG_FileDialog::getOpenFileName(this, &type);
2005 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen() 003");
2006 slotFileOpen(fileName, type);
2007 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen(): OK");
2011 * Called when a recently opened file is chosen from the list in the
2014 //void QC_ApplicationWindow::slotFileOpenRecent(int id)
2015 void QC_ApplicationWindow::slotFileOpenRecent(void)
2018 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpenRecent()");
2020 statusBar()->showMessage(tr("Opening recent file..."));
2021 QString fileName = recentFiles->get(id);
2023 if (fileName.endsWith(" (DXF 1)"))
2024 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
2026 slotFileOpen(fileName, RS2::FormatUnknown);
2028 statusBar()->showMessage(tr("Opening recent file..."));
2030 QAction * action = qobject_cast<QAction *>(sender());
2035 QString fileName = action->data().toString();
2037 if (fileName.endsWith(" (DXF 1)"))
2038 slotFileOpen(fileName.left(fileName.length() - 8), RS2::FormatDXF1);
2040 slotFileOpen(fileName, RS2::FormatUnknown);
2045 * Menu file -> open.
2047 void QC_ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType type)
2049 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen(..)");
2051 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2053 if (!fileName.isEmpty())
2055 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen: creating new doc window");
2056 // Create new document window:
2057 QC_MDIWindow * w = slotFileNew();
2058 // RS_APP->processEvents(1000);
2059 //Really, is this needed???
2060 // RS_APP->processEvents(QEventLoop::AllEvents, 1000);
2062 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen: linking layer list");
2063 // link the layer widget to the new document:
2064 layerWidget->setLayerList(w->getDocument()->getLayerList(), false);
2065 // link the block widget to the new document:
2066 blockWidget->setBlockList(w->getDocument()->getBlockList());
2067 // link coordinate widget to graphic
2068 coordinateWidget->setGraphic(w->getGraphic());
2070 // link the layer widget to the new document:
2071 simulationControls->setGraphicView(w->getGraphicView());
2074 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen: open file");
2076 // RS_APP->processEvents(1000);
2077 //We no longer try to do Qt better than the Qt folks...
2078 // RS_APP->processEvents(QEventLoop::AllEvents, 1000);
2080 // open the file in the new view:
2081 if (w->slotFileOpen(fileName, type) == false)
2084 QApplication::restoreOverrideCursor();
2085 QMessageBox::information(this, QMessageBox::tr("Warning"),
2086 tr("Cannot open the file\n%1\nPlease check the permissions.") .arg(fileName), QMessageBox::Ok);
2087 w->setForceClosing(true);
2092 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen: open file: OK");
2093 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen: update recent file menu: 1");
2095 // update recent files menu:
2096 if (type == RS2::FormatDXF1)
2097 recentFiles->add(fileName + " (DXF 1)");
2099 recentFiles->add(fileName);
2101 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen: update recent file menu: 2");
2102 // updateRecentFilesMenu();
2103 recentFiles->UpdateGUI();
2105 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen: update recent file menu: OK");
2107 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen: set caption");
2109 // w->setCaption(fileName);
2110 w->setWindowTitle(fileName);
2111 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen: set caption: OK");
2113 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen: update coordinate widget");
2114 // update coordinate widget format:
2115 RS_DIALOGFACTORY->updateCoordinateWidget(Vector(0.0, 0.0), Vector(0.0, 0.0), true);
2116 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen: update coordinate widget: OK");
2118 // show output of filter (if any):
2119 // commandWidget->processStderr();
2120 QString message = tr("Loaded document: ") + fileName;
2121 commandWidget->appendHistory(message);
2122 statusBar()->showMessage(message, 2000);
2126 statusBar()->showMessage(tr("Opening aborted"), 2000);
2129 QApplication::restoreOverrideCursor();
2130 RS_DEBUG->print("QC_ApplicationWindow::slotFileOpen(..) OK");
2134 * Menu file -> save.
2136 void QC_ApplicationWindow::slotFileSave()
2138 RS_DEBUG->print("QC_ApplicationWindow::slotFileSave()");
2140 statusBar()->showMessage(tr("Saving drawing..."));
2142 QC_MDIWindow * w = getMDIWindow();
2147 if (w->getDocument()->getFilename().isEmpty())
2153 if (w->slotFileSave(cancelled))
2157 name = w->getDocument()->getFilename();
2158 statusBar()->showMessage(tr("Saved drawing: %1").arg(name), 2000);
2164 QMessageBox::information(this, QMessageBox::tr("Warning"),
2165 tr("Cannot save the file\n%1\nPlease check the permissions.")
2166 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2173 * Menu file -> save as.
2175 void QC_ApplicationWindow::slotFileSaveAs()
2177 RS_DEBUG->print("QC_ApplicationWindow::slotFileSaveAs()");
2179 statusBar()->showMessage(tr("Saving drawing under new filename..."));
2181 QC_MDIWindow * w = getMDIWindow();
2188 if (w->slotFileSaveAs(cancelled))
2192 name = w->getDocument()->getFilename();
2193 recentFiles->add(name);
2194 w->setWindowTitle(name);
2200 QMessageBox::information(this, QMessageBox::tr("Warning"),
2201 tr("Cannot save the file\n%1\nPlease check the permissions.")
2202 .arg(w->getDocument()->getFilename()), QMessageBox::Ok);
2206 // updateRecentFilesMenu();
2207 recentFiles->UpdateGUI();
2209 QString message = tr("Saved drawing: %1").arg(name);
2210 statusBar()->showMessage(message, 2000);
2211 commandWidget->appendHistory(message);
2215 * Menu file -> export.
2217 void QC_ApplicationWindow::slotFileExport()
2219 RS_DEBUG->print("QC_ApplicationWindow::slotFileExport()");
2221 statusBar()->showMessage(tr("Exporting drawing..."));
2223 QC_MDIWindow * w = getMDIWindow();
2228 // read default settings:
2229 settings.beginGroup("Paths");
2230 QString defDir = settings.value("ExportImage", RS_SYSTEM->getHomeDir()).toString();
2231 QString defFilter = settings.value("ExportImageFilter", "Portable Network Graphic (*.png)").toString();
2232 settings.endGroup();
2234 bool cancel = false;
2236 // Q3FileDialog fileDlg(NULL, "", true);
2237 QFileDialog fileDlg(NULL, "", "", "");
2239 #warning "Need to port to Qt4... !!! FIX !!!"
2241 Q3StrList f = QImageIO::outputFormats();
2242 QStringList formats = QStringList::fromStrList(f);
2243 QStringList filters;
2246 for (QStringList::Iterator it = formats.begin();
2247 it!=formats.end(); ++it)
2252 st = QString("%1 (*.%2 *.jpg)")
2253 .arg(QG_DialogFactory::extToFormat(*it))
2254 .arg(QString(*it).lower());
2258 st = QString("%1 (*.%2)")
2259 .arg(QG_DialogFactory::extToFormat(*it))
2260 .arg(QString(*it).lower());
2265 //if (!all.isEmpty()) {
2268 //all += QString("*.%1").arg(QString(*it).lower());
2271 QStringList filters;
2274 fileDlg.setFilters(filters);
2275 // fileDlg.setMode(Q3FileDialog::AnyFile);
2276 fileDlg.setFileMode(QFileDialog::AnyFile);
2277 // fileDlg.setCaption(QObject::tr("Export Image"));
2278 fileDlg.setWindowTitle(QObject::tr("Export Image"));
2279 // fileDlg.setDir(defDir);
2280 fileDlg.setDirectory(defDir);
2281 fileDlg.selectNameFilter(defFilter);
2283 if (fileDlg.exec() == QDialog::Accepted)
2285 // fn = fileDlg.selectedFile();
2286 QStringList files = fileDlg.selectedFiles();
2288 if (!files.isEmpty())
2296 // store new default settings:
2299 settings.beginGroup("Paths");
2300 // settings.writeEntry("/ExportImage", QFileInfo(fn).dirPath(true));
2301 settings.setValue("ExportImage", QFileInfo(fn).absolutePath());
2302 settings.setValue("ExportImageFilter", fileDlg.selectedFilter());
2303 settings.endGroup();
2305 // find out extension:
2306 QString filter = fileDlg.selectedFilter();
2307 QString format = "";
2308 // int i = filter.find("(*.");
2309 int i = filter.indexOf("(*.");
2313 // int i2 = filter.find(QRegExp("[) ]"), i);
2314 int i2 = filter.indexOf(QRegExp("[) ]"), i);
2315 format = filter.mid(i + 3, i2 - (i + 3));
2316 format = format.toUpper();
2319 // append extension to file:
2320 if (!QFileInfo(fn).fileName().contains("."))
2321 fn.append("." + format.toLower());
2323 // show options dialog:
2324 ImageOptionsDialog dlg(this);
2325 dlg.setGraphicSize(w->getGraphic()->getSize());
2329 bool ret = slotFileExport(fn, format, dlg.getSize(), dlg.isBackgroundBlack());
2333 QString message = tr("Exported: %1").arg(fn);
2334 statusBar()->showMessage(message, 2000);
2335 commandWidget->appendHistory(message);
2343 * Exports the drawing as a bitmap.
2345 * @param name File name.
2346 * @param format File format (e.g. "png")
2347 * @param size Size of the bitmap in pixel
2348 * @param black true: Black background, false: white
2349 * @param bw true: black/white export, false: color
2351 bool QC_ApplicationWindow::slotFileExport(const QString & name, const QString & format, QSize size, bool black, bool bw)
2353 QC_MDIWindow * w = getMDIWindow();
2357 RS_DEBUG->print(RS_Debug::D_WARNING, "QC_ApplicationWindow::slotFileExport: no window opened");
2361 RS_Graphic * graphic = w->getDocument()->getGraphic();
2363 if (graphic == NULL)
2365 RS_DEBUG->print(RS_Debug::D_WARNING, "QC_ApplicationWindow::slotFileExport: no graphic");
2369 statusBar()->showMessage(tr("Exporting..."));
2370 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2373 QPixmap * buffer = new QPixmap(size);
2374 // RS_PainterQt * painter = new RS_PainterQt(buffer);
2375 QPainter qpntr(buffer);
2376 PaintInterface * painter = new PaintInterface(&qpntr);
2378 // black background:
2380 // painter->setBackgroundColor(RS_Color(0, 0, 0));
2381 // qpntr.setBackgroundColor(RS_Color(0, 0, 0));
2382 qpntr.setBackground(QBrush(QColor(0, 0, 0)));
2383 // white background:
2385 // painter->setBackgroundColor(RS_Color(255, 255, 255));
2386 // qpntr.setBackgroundColor(RS_Color(255, 255, 255));
2387 qpntr.setBackground(QBrush(QColor(255, 255, 255)));
2391 painter->setDrawingMode(RS2::ModeBW);
2393 // painter->eraseRect(0, 0, size.width(), size.height());
2394 qpntr.eraseRect(0, 0, size.width(), size.height());
2396 RS_StaticGraphicView gv(size.width(), size.height(), painter);
2399 gv.setBackground(RS_Color(0, 0, 0));
2401 gv.setBackground(RS_Color(255, 255, 255));
2403 gv.setContainer(graphic);
2405 gv.drawEntity(graphic, true);
2412 iio.setFileName(name);
2413 iio.setFormat(format);
2420 #warning "Need to port to Qt4... !!! FIX !!!"
2423 QApplication::restoreOverrideCursor();
2425 // GraphicView deletes painter
2432 statusBar()->showMessage(tr("Export complete"), 2000);
2434 statusBar()->showMessage(tr("Export failed!"), 2000);
2440 * Menu file -> close.
2442 void QC_ApplicationWindow::slotFileClose()
2444 RS_DEBUG->print("QC_ApplicationWindow::slotFileClose()");
2446 QC_MDIWindow * m = getMDIWindow();
2455 //m->showMaximized();
2456 m->setWindowState(WindowMaximized);
2462 * Called when a MDI window is actually about to close. Used to
2463 * detach widgets from the document.
2465 void QC_ApplicationWindow::slotFileClosing()
2467 RS_DEBUG->print("QC_ApplicationWindow::slotFileClosing()");
2469 RS_DEBUG->print("detaching lists");
2470 layerWidget->setLayerList(NULL, false);
2471 blockWidget->setBlockList(NULL);
2472 coordinateWidget->setGraphic(NULL);
2474 simulationControls->setGraphicView(NULL);
2479 * Menu file -> print.
2481 void QC_ApplicationWindow::slotFilePrint()
2483 RS_DEBUG->print("QC_ApplicationWindow::slotFilePrint()");
2485 QC_MDIWindow * w = getMDIWindow();
2489 RS_DEBUG->print(RS_Debug::D_WARNING, "QC_ApplicationWindow::slotFilePrint: no window opened");
2493 RS_Graphic * graphic = w->getDocument()->getGraphic();
2495 if (graphic == NULL)
2497 RS_DEBUG->print(RS_Debug::D_WARNING, "QC_ApplicationWindow::slotFilePrint: no graphic");
2501 statusBar()->showMessage(tr("Printing..."));
2502 QPrinter * printer = new QPrinter(QPrinter::HighResolution);
2503 bool landscape = false;
2504 printer->setPageSize(RS2::rsToQtPaperFormat(graphic->getPaperFormat(&landscape)));
2507 printer->setOrientation(QPrinter::Landscape);
2509 printer->setOrientation(QPrinter::Portrait);
2511 settings.beginGroup("Print");
2512 printer->setOutputFileName(settings.value("FileName", "").toString());
2513 printer->setColorMode((QPrinter::ColorMode)settings.value("/ColorMode", (int)QPrinter::Color).toInt());
2514 #warning "!!! Need to port QPrinter::setOutputToFile() to Qt4 !!!"
2515 // printer->setOutputToFile((bool)RS_SETTINGS->readNumEntry("/PrintToFile", 0));
2516 settings.endGroup();
2519 // if (printer->setup(this))
2520 QPrintDialog dialog(printer, this);
2523 //printer->setOutputToFile(true);
2524 //printer->setOutputFileName(outputFile);
2526 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2527 printer->setFullPage(true);
2528 //Can call these functions directly from the QPaintDevice...
2529 // Q3PaintDeviceMetrics metr(printer);
2531 // RS_PainterQt * painter = new RS_PainterQt(printer);
2532 QPainter qpntr(printer);
2533 PaintInterface * painter = new PaintInterface(&qpntr);
2534 painter->setDrawingMode(w->getGraphicView()->getDrawingMode());
2536 // RS_StaticGraphicView gv(metr.width(), metr.height(), painter);
2537 RS_StaticGraphicView gv(printer->width(), printer->height(), painter);
2538 gv.setPrinting(true);
2539 gv.setBorders(0, 0, 0, 0);
2541 // double fx = (double)metr.width() / metr.widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2542 // double fy = (double)metr.height() / metr.heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2543 double fx = (double)printer->width() / printer->widthMM() * RS_Units::getFactorToMM(graphic->getUnit());
2544 double fy = (double)printer->height() / printer->heightMM() * RS_Units::getFactorToMM(graphic->getUnit());
2545 double f = (fx + fy) / 2;
2546 double scale = graphic->getPaperScale();
2548 gv.setOffset((int)(graphic->getPaperInsertionBase().x * f),
2549 (int)(graphic->getPaperInsertionBase().y * f));
2550 gv.setFactor(f * scale);
2551 gv.setContainer(graphic);
2552 gv.drawEntity(graphic, true);
2554 // GraphicView deletes painter
2559 settings.beginGroup("Print");
2560 #warning "!!! Need to port QPrinter::outputToFile() to Qt4 !!!"
2561 // settings.writeEntry("/PrintToFile", (int)printer->outputToFile());
2562 settings.setValue("ColorMode", (int)printer->colorMode());
2563 settings.setValue("FileName", printer->outputFileName());
2564 settings.endGroup();
2565 QApplication::restoreOverrideCursor();
2570 statusBar()->showMessage(tr("Printing complete"), 2000);
2574 * Menu file -> print preview.
2576 void QC_ApplicationWindow::slotFilePrintPreview(bool on)
2578 RS_DEBUG->print("QC_ApplicationWindow::slotFilePrintPreview()");
2580 RS_DEBUG->print(" creating MDI window");
2581 QC_MDIWindow * parent = getMDIWindow();
2585 RS_DEBUG->print(RS_Debug::D_WARNING, "QC_ApplicationWindow::slotFilePrintPreview: no window opened");
2589 // close print preview:
2592 RS_DEBUG->print("QC_ApplicationWindow::slotFilePrintPreview(): off");
2594 if (parent->getGraphicView()->isPrintPreview())
2596 RS_DEBUG->print("QC_ApplicationWindow::slotFilePrintPreview(): close");
2600 // open print preview:
2603 // look for an existing print preview:
2604 QC_MDIWindow * ppv = parent->getPrintPreview();
2608 RS_DEBUG->print("QC_ApplicationWindow::slotFilePrintPreview(): show existing");
2609 slotWindowActivated(ppv);
2614 if (!parent->getGraphicView()->isPrintPreview())
2616 RS_DEBUG->print("QC_ApplicationWindow::slotFilePrintPreview(): create");
2618 QC_MDIWindow * w = new QC_MDIWindow(parent->getDocument(), workspace, 0, Qt::SubWindow);
2619 w->setAttribute(Qt::WA_DeleteOnClose);
2620 parent->addChildWindow(w);
2621 //connect(w, SIGNAL(signalClosing()),
2622 // this, SLOT(slotFileClosing()));
2624 // w->setCaption(tr("Print preview for %1").arg(parent->caption()));
2625 w->setWindowTitle(tr("Print preview for %1").arg(parent->windowTitle()));
2626 // w->setIcon(qPixmapFromMimeSource("document.png"));
2627 // w->setWindowIcon(qPixmapFromMimeSource("document.png"));
2628 w->setWindowIcon(QIcon(":/res/document.png"));
2629 w->getGraphicView()->setPrintPreview(true);
2630 w->getGraphicView()->setBackground(RS_Color(255, 255, 255));
2631 w->getGraphicView()->setDefaultAction(new RS_ActionPrintPreview(*w->getDocument(), *w->getGraphicView()));
2633 // only graphics offer block lists, blocks don't
2634 RS_DEBUG->print(" adding listeners");
2635 RS_Graphic * graphic = w->getDocument()->getGraphic();
2637 if (graphic != NULL)
2639 // Link the layer list to the pen tool bar
2640 graphic->addLayerListListener(penToolBar);
2641 // Link the layer list to the layer widget
2642 graphic->addLayerListListener(layerWidget);
2643 // Link the block list to the block widget
2644 graphic->addBlockListListener(blockWidget);
2645 // Center by default:
2646 graphic->centerToPage();
2649 // Link the graphic view to the mouse widget:
2650 QG_DIALOGFACTORY->setMouseWidget(mouseWidget);
2651 // Link the graphic view to the coordinate widget:
2652 QG_DIALOGFACTORY->setCoordinateWidget(coordinateWidget);
2653 QG_DIALOGFACTORY->setSelectionWidget(selectionWidget);
2654 // Link the graphic view to the option widget:
2655 //QG_DIALOGFACTORY->setOptionWidget(optionWidget);
2656 // Link the graphic view to the cad tool bar:
2657 QG_DIALOGFACTORY->setCadToolBar(cadToolBar);
2658 // Link the graphic view to the command widget:
2659 QG_DIALOGFACTORY->setCommandWidget(commandWidget);
2661 RS_DEBUG->print(" showing MDI window");
2663 if (workspace->subWindowList().isEmpty())
2668 w->getGraphicView()->zoomPage();
2671 slotWindowActivated(w);
2678 * Menu file -> quit.
2680 void QC_ApplicationWindow::slotFileQuit()
2682 RS_DEBUG->print("QC_ApplicationWindow::slotFileQuit()");
2684 statusBar()->showMessage(tr("Exiting application..."));
2686 if (queryExit(false))
2691 * Forces termination of QCad (demo version).
2693 void QC_ApplicationWindow::slotFileDemoQuit()
2695 statusBar()->showMessage(tr("Exiting application..."));
2702 * Shows / hides the grid.
2704 * @param toggle true: show, false: hide.
2706 void QC_ApplicationWindow::slotViewGrid(bool toggle)
2708 RS_DEBUG->print("QC_ApplicationWindow::slotViewGrid()");
2710 QC_MDIWindow * m = getMDIWindow();
2714 RS_Graphic * g = m->getGraphic();
2717 g->setGridOn(toggle);
2723 RS_DEBUG->print("QC_ApplicationWindow::slotViewGrid() OK");
2727 * Enables / disables the draft mode.
2729 * @param toggle true: enable, false: disable.
2731 void QC_ApplicationWindow::slotViewDraft(bool toggle)
2733 RS_DEBUG->print("QC_ApplicationWindow::slotViewDraft()");
2735 /*QC_MDIWindow* m = getMDIWindow();
2737 RS_Graphic* g = m->getGraphic();
2739 g->setDraftOn(toggle);
2743 settings.beginGroup("Appearance");
2744 settings.setValue("DraftMode", toggle);
2745 settings.endGroup();
2751 * Redraws all mdi windows.
2753 void QC_ApplicationWindow::redrawAll()
2755 if (workspace != NULL)
2757 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2759 for(int i=0; i<int(windows.count()); ++i)
2761 QC_MDIWindow * m = (QC_MDIWindow *)windows.at(i);
2765 QG_GraphicView * gv = m->getGraphicView();
2775 * Updates all grids of all graphic views.
2777 void QC_ApplicationWindow::updateGrids()
2779 if (workspace != NULL)
2781 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2783 for(int i=0; i<int(windows.count()); ++i)
2785 QC_MDIWindow * m = (QC_MDIWindow *)windows.at(i);
2789 QG_GraphicView * gv = m->getGraphicView();
2799 * Shows / hides the status bar.
2801 * @param showSB true: show, false: hide.
2803 void QC_ApplicationWindow::slotViewStatusBar(bool showSB)
2805 RS_DEBUG->print("QC_ApplicationWindow::slotViewStatusBar()");
2808 statusBar()->show();
2810 statusBar()->hide();
2814 * Shows / hides the layer list.
2816 * @param toggle true: show, false: hide.
2818 /*void QC_ApplicationWindow::slotViewLayerList(bool toggle) {
2819 RS_DEBUG->print("QC_ApplicationWindow::slotViewLayerList()");
2821 if (toggle==false) {
2822 layerDockWindow->hide();
2824 layerDockWindow->show();
2830 * Shows / hides the block list.
2832 * @param toggle true: show, false: hide.
2835 void QC_ApplicationWindow::slotViewBlockList(bool toggle) {
2836 RS_DEBUG->print("QC_ApplicationWindow::slotViewBlockList()");
2838 if (toggle==false) {
2839 blockDockWindow->hide();
2841 blockDockWindow->show();
2847 * Shows / hides the command line.
2849 * @param toggle true: show, false: hide.
2852 void QC_ApplicationWindow::slotViewCommandLine(bool toggle) {
2853 RS_DEBUG->print("QC_ApplicationWindow::slotViewCommandLine()");
2855 if (toggle==false) {
2856 commandDockWindow->hide();
2857 //QG_GraphicView* graphicView = getGraphicView();
2858 //if (graphicView!=NULL) {
2859 //graphicView->setFocus();
2863 commandDockWindow->show();
2869 * Shows / hides the option toolbar.
2871 * @param toggle true: show, false: hide.
2874 void QC_ApplicationWindow::slotViewOptionToolbar(bool toggle) {
2875 RS_DEBUG->print("QC_ApplicationWindow::slotViewOptionToolbar()");
2877 if (toggle==false) {
2878 optionWidget->hide();
2880 optionWidget->show();
2886 * Creates a new MDI window for editing the selected block.
2889 void QC_ApplicationWindow::slotBlocksEdit() {
2890 RS_DEBUG->print("QC_ApplicationWindow::slotBlocksEdit()");
2892 QC_MDIWindow* parent = getMDIWindow();
2894 RS_BlockList* blist = blockWidget->getBlockList();
2896 RS_Block* blk = blist->getActiveBlock();
2898 QC_MDIWindow* w = slotFileNew(blk);
2899 // the parent needs a pointer to the block window and
2901 parent->addChildWindow(w);
2902 w->getGraphicView()->zoomAuto();
2910 * Shows the dialog for general application preferences.
2912 void QC_ApplicationWindow::slotOptionsGeneral()
2914 RS_DIALOGFACTORY->requestOptionsGeneralDialog();
2916 // update background color of all open drawings:
2917 settings.beginGroup("Appearance");
2918 QColor color(settings.value("BackgroundColor", "#000000").toString());
2919 QColor gridColor(settings.value("GridColor", "Gray").toString());
2920 QColor metaGridColor(settings.value("MetaGridColor", "Darkgray").toString());
2921 QColor selectedColor(settings.value("SelectedColor", "#A54747").toString());
2922 QColor highlightedColor(settings.value("HighlightedColor", "#739373").toString());
2923 settings.endGroup();
2925 QList<QMdiSubWindow *> windows = workspace->subWindowList();
2927 for(int i=0; i<int(windows.count()); ++i)
2929 QC_MDIWindow * m = (QC_MDIWindow *)windows.at(i);
2933 QG_GraphicView * gv = m->getGraphicView();
2937 gv->setBackground(color);
2938 gv->setGridColor(gridColor);
2939 gv->setMetaGridColor(metaGridColor);
2940 gv->setSelectedColor(selectedColor);
2941 gv->setHighlightedColor(highlightedColor);
2950 * Menu script -> show ide
2952 void QC_ApplicationWindow::slotScriptOpenIDE()
2955 scripter->openIDE();
2960 * Menu script -> run
2962 void QC_ApplicationWindow::slotScriptRun()
2965 scripter->runScript();
2970 * Menu help -> about.
2972 void QC_ApplicationWindow::slotHelpAbout()
2974 RS_DEBUG->print("QC_ApplicationWindow::slotHelpAbout()");
2979 //demo; // = " [Demo]";
2982 edition = " [Professional]";
2984 edition = " [Community Edition]";
2988 QStringList modules;
2995 modules += "Scripting";
2998 QString modulesString;
3000 if (modules.empty() == false)
3001 modulesString = modules.join(", ");
3003 modulesString = tr("None");
3005 QMessageBox box(this);
3006 // box.setCaption(tr("About..."));
3007 box.setWindowTitle(tr("About..."));
3008 box.setText(QString("<qt>") + // no center for main stream QCad
3009 #ifdef QC_ABOUT_HEADER
3010 QString("<center>") +
3011 QString(QC_ABOUT_HEADER) +
3013 //FAIL "<h2>"+ QC_APPNAME+ "</h2>" +
3014 "<h2>Architektonas</h2>" +
3016 tr("Version: %1 %2").arg(QC_VERSION).arg(edition) + "<br>" +
3017 tr("Date: %1").arg(__DATE__) + "<br>" +
3018 QString("(c) 2001-2005 by RibbonSoft,<br> Andrew Mustun") +
3020 tr("Modules: %1").arg(modulesString) + "<br>" +
3021 QString("http://www.ribbonsoft.com")
3022 #ifdef QC_ABOUT_ADD_COMPANY
3023 + QString("<br>") + QC_ABOUT_ADD_COMPANY
3024 + QString("</center>")
3027 #ifndef QC_ABOUT_HEADER
3028 #warning "Failure..."
3029 // box.setIcon(qPixmapFromMimeSource(QC_APP_ICON));
3030 box.setFixedWidth(340);
3031 box.setFixedHeight(250);
3037 * Menu help -> help.
3039 void QC_ApplicationWindow::slotHelpManual()
3041 #warning "No help system ported to Qt4... !!! FIX !!!"
3043 RS_DEBUG->print("QC_ApplicationWindow::slotHelpManual()");
3045 if (assistant == NULL)
3047 RS_DEBUG->print("QC_ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
3048 RS_DEBUG->print("QC_ApplicationWindow::slotHelpManual(): appdir: %s", RS_SYSTEM->getAppDir().toLatin1().data());
3049 assistant = new QAssistantClient(RS_SYSTEM->getAppDir()+"/bin", this);
3050 connect(assistant, SIGNAL(error(const QString&)), this, SLOT(slotError(const QString&)));
3053 args << QDir::convertSeparators(RS_SYSTEM->getDocPath() + "/qcaddoc.adp");
3054 // args << QString("doc") + QDir::separator() + QString("qcaddoc.adp");
3056 #if QT_VERSION>=0x030200
3057 assistant->setArguments(args);
3060 assistant->openAssistant();
3061 //assistant->showPage("index.html");
3068 void QC_ApplicationWindow::slotTestDumpEntities(RS_EntityContainer * d)
3070 RS_DEBUG->print("QC_ApplicationWindow::slotTestDumpEntities()");
3071 static int level = 0;
3072 std::ofstream dumpFile;
3077 dumpFile.open("debug_entities.html");
3082 dumpFile.open("debug_entities.html", std::ios::app);
3090 dumpFile << "<html>\n";
3091 dumpFile << "<body>\n";
3094 for (RS_Entity* e=d->firstEntity();
3099 dumpFile << "<table border=\"1\">\n";
3100 dumpFile << "<tr><td>Entity: " << e->getId()
3104 << "<tr><td><table><tr>"
3105 << "<td>VIS:" << e->isVisible() << "</td>"
3106 << "<td>UND:" << e->isUndone() << "</td>"
3107 << "<td>SEL:" << e->isSelected() << "</td>"
3108 << "<td>TMP:" << e->getFlag(RS2::FlagTemp) << "</td>";
3109 QString lay = "NULL";
3110 if (e->getLayer()!=NULL) {
3111 lay = e->getLayer()->getName();
3114 //fail << "<td>Layer: " << lay << "</td>"
3115 << "<td>Width: " << (int)e->getPen(false).getWidth() << "</td>"
3116 << "<td>Parent: " << e->getParent()->getId() << "</td>"
3124 case RS2::EntityPoint:
3126 RS_Point* p = (RS_Point*)e;
3128 << "<table><tr><td>"
3140 case RS2::EntityLine:
3142 RS_Line* l = (RS_Line*)e;
3144 << "<table><tr><td>"
3150 << l->getStartpoint()
3159 case RS2::EntityArc: {
3160 RS_Arc* a = (RS_Arc*)e;
3162 << "<table><tr><td>"
3179 << "<td>Startpoint: "
3180 << a->getStartpoint()
3186 << (int)a->isReversed()
3192 case RS2::EntityCircle: {
3193 RS_Circle* c = (RS_Circle*)e;
3195 << "<table><tr><td>"
3210 case RS2::EntityDimAligned: {
3211 RS_DimAligned* d = (RS_DimAligned*)e;
3213 << "<table><tr><td>"
3214 << "<b>Dimension / Aligned:</b>"
3219 << d->getDefinitionPoint()
3222 << d->getExtensionPoint1()
3225 << d->getExtensionPoint2()
3228 << d->getText().toLatin1().data()
3231 << d->getLabel().toLatin1().data()
3237 case RS2::EntityDimLinear:
3239 RS_DimLinear* d = (RS_DimLinear*)e;
3241 << "<table><tr><td>"
3242 << "<b>Dimension / Linear:</b>"
3247 << d->getDefinitionPoint()
3250 << d->getExtensionPoint1()
3253 << d->getExtensionPoint2()
3256 //fail << d->getText()
3259 //fail << d->getLabel()
3265 case RS2::EntityInsert: {
3266 RS_Insert* i = (RS_Insert*)e;
3268 << "<table><tr><td>"
3273 << "<td>Insertion point:"
3274 << i->getInsertionPoint()
3280 case RS2::EntityText: {
3281 RS_Text* t = (RS_Text*)e;
3283 << "<table><tr><td>"
3289 << t->getText().toLatin1().data()
3298 case RS2::EntityHatch: {
3299 RS_Hatch* h = (RS_Hatch*)e;
3301 << "<table><tr><td>"
3307 << h->getPattern().toLatin1().data()
3313 << (int)h->isSolid()
3322 << "<b>Unknown Entity: " << e->rtti() << "</b>"
3327 if (e->isContainer() || e->rtti()==RS2::EntityHatch) {
3328 RS_EntityContainer* ec = (RS_EntityContainer*)e;
3329 dumpFile << "<table><tr><td valign=\"top\"> Contents:</td><td>\n";
3331 slotTestDumpEntities(ec);
3332 dumpFile.open("debug_entities.html", std::ios::app);
3333 dumpFile << "</td></tr></table>\n";
3343 dumpFile << "</body>\n";
3344 dumpFile << "</html>\n";
3354 void QC_ApplicationWindow::slotTestDumpUndo()
3356 RS_DEBUG->print("QC_ApplicationWindow::slotTestDumpUndo()");
3358 RS_Document * d = getDocument();
3362 std::cout << *(RS_Undo*)d;
3363 std::cout << std::endl;
3370 void QC_ApplicationWindow::slotTestUpdateInserts()
3372 RS_DEBUG->print("QC_ApplicationWindow::slotTestUpdateInserts()");
3374 RS_Document * d = getDocument();
3383 void QC_ApplicationWindow::slotTestDrawFreehand()
3385 RS_DEBUG->print("QC_ApplicationWindow::slotTestDrawFreehand()");
3387 //RS_Graphic* g = document->getMarking();
3390 RS_ActionDrawLineFree* action =
3391 new RS_ActionDrawLineFree(*document->getGraphic(),
3394 for (int i=0; i<100; ++i) {
3396 int posx = (random()%600);
3397 int posy = (random()%400);
3399 //RS_MouseEvent rsm1(posx, posy, LEFT);
3400 RS_MouseEvent rsm1(QEvent::MouseButtonPress,
3404 action->mousePressEvent(&rsm1);
3409 for (int k=0; k<100; ++k) {
3410 int accx = (random()%40)-20;
3411 int accy = (random()%40)-20;
3419 //RS_MouseEvent rsm2(posx, posy, LEFT);
3421 RS_MouseEvent rsm2(QEvent::MouseMove,
3425 action->mouseMoveEvent(&rsm2);
3428 action->mouseReleaseEvent(NULL);
3440 void QC_ApplicationWindow::slotTestInsertBlock()
3442 RS_DEBUG->print("QC_ApplicationWindow::slotTestInsertBlock()");
3444 RS_Document * d = getDocument();
3446 if (d != NULL && d->rtti() == RS2::EntityGraphic)
3448 RS_Graphic * graphic = (RS_Graphic *)d;
3450 if (graphic == NULL)
3453 graphic->addLayer(new RS_Layer("default"));
3454 RS_Block * block = new RS_Block(graphic, RS_BlockData("debugblock", Vector(0.0, 0.0), true));
3460 // Add one red line:
3461 line = new RS_Line(block, RS_LineData(Vector(0.0, 0.0), Vector(50.0, 0.0)));
3462 line->setLayerToActive();
3463 line->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3464 block->addEntity(line);
3466 // Add one line with attributes from block:
3467 line = new RS_Line(block, RS_LineData(Vector(50.0, 0.0), Vector(50.0, 50.0)));
3468 line->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3469 block->addEntity(line);
3471 // Add one arc with attributes from block:
3472 RS_ArcData d(Vector(50.0, 0.0), 50.0, M_PI / 2.0, M_PI, false);
3473 arc = new RS_Arc(block, d);
3474 arc->setPen(RS_Pen(RS_Color(RS2::FlagByBlock), RS2::WidthByBlock, RS2::LineByBlock));
3475 block->addEntity(arc);
3477 // Add one blue circle:
3478 RS_CircleData circleData(Vector(20.0, 15.0), 12.5);
3479 circle = new RS_Circle(block, circleData);
3480 circle->setLayerToActive();
3481 circle->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width01, RS2::SolidLine));
3482 block->addEntity(circle);
3484 graphic->addBlock(block);
3487 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);
3489 // insert one magenta instance of the block (original):
3490 ins = new RS_Insert(graphic, insData);
3491 ins->setLayerToActive();
3492 ins->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width02, RS2::SolidLine));
3494 graphic->addEntity(ins);
3496 // insert one green instance of the block (rotate):
3497 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);
3498 ins = new RS_Insert(graphic, insData);
3499 ins->setLayerToActive();
3500 ins->setPen(RS_Pen(RS_Color(0, 255, 0), RS2::Width02, RS2::SolidLine));
3502 graphic->addEntity(ins);
3504 // insert one cyan instance of the block (move):
3505 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);
3506 ins = new RS_Insert(graphic, insData);
3507 ins->setLayerToActive();
3508 ins->setPen(RS_Pen(RS_Color(0, 255, 255), RS2::Width02, RS2::SolidLine));
3510 graphic->addEntity(ins);
3512 // insert one blue instance of the block:
3513 for(double a=0.0; a<360.0; a+=45.0)
3515 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);
3516 ins = new RS_Insert(graphic, insData);
3517 ins->setLayerToActive();
3518 ins->setPen(RS_Pen(RS_Color(0, 0, 255), RS2::Width05, RS2::SolidLine));
3520 graphic->addEntity(ins);
3523 // insert an array of yellow instances of the block:
3524 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);
3525 ins = new RS_Insert(graphic, insData);
3526 ins->setLayerToActive();
3527 ins->setPen(RS_Pen(RS_Color(255, 255, 0), RS2::Width01, RS2::SolidLine));
3529 graphic->addEntity(ins);
3531 RS_GraphicView * v = getGraphicView();
3541 void QC_ApplicationWindow::slotTestInsertEllipse()
3543 RS_DEBUG->print("QC_ApplicationWindow::slotTestInsertEllipse()");
3545 RS_Document * d = getDocument();
3549 RS_Graphic * graphic = (RS_Graphic *)d;
3551 if (graphic == NULL)
3554 RS_Ellipse * ellipse;
3557 for (double a=0.0; a<2*M_PI; a+=0.1)
3560 v.setPolar(50.0, a);
3561 double xp = 1000.0*a;
3563 RS_EllipseData ellipseData(Vector(xp, 0.0), v, 0.5, 0.0, 2 * M_PI, false);
3564 ellipse = new RS_Ellipse(graphic, ellipseData);
3566 ellipse->setPen(RS_Pen(RS_Color(255, 0, 255), RS2::Width01, RS2::SolidLine));
3568 graphic->addEntity(ellipse);
3569 //graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3570 //graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3572 line = new RS_Line(graphic, RS_LineData(Vector(xp, 0.0), Vector(xp, 0.0) + v));
3573 line->setPen(RS_Pen(RS_Color(128, 128, 128), RS2::Width01, RS2::SolidLine));
3574 graphic->addEntity(line);
3577 for (double mx=-60.0; mx<60.0; mx+=1.0) {
3578 //for (double mx=0.0; mx<1.0; mx+=2.5) {
3579 VectorSolutions sol = ellipse->mapX(xp + mx);
3580 //graphic->addEntity(new RS_Point(graphic,
3581 // sol.vector2 + Vector(a*500.0, 0.0)));
3582 //graphic->addEntity(new RS_Point(graphic,
3583 // sol.vector3 + Vector(a*500.0, 0.0)));
3584 //graphic->addEntity(new RS_Point(graphic,
3585 // sol.vector4 + Vector(a*500.0, 0.0)));
3587 line = new RS_Line(graphic,
3588 RS_LineData(Vector(xp+mx,-50.0),
3589 Vector(xp+mx,50.0)));
3590 line->setPen(RS_Pen(RS_Color(60, 60, 60),
3593 graphic->addEntity(line);
3595 graphic->addEntity(new RS_Point(graphic,
3601 // different minor/minor relations
3604 for (y=-250.0; y<=250.0; y+=50.0) {
3605 for (x=-250.0; x<=250.0; x+=50.0) {
3608 ellipse = new RS_Ellipse(graphic,
3610 Vector((x/5+50.0)/2.0, 0.0),
3615 ellipse->setPen(RS_Pen(RS_Color(255, 255, 0),
3619 graphic->addEntity(ellipse);
3620 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3621 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3623 ellipse = new RS_Ellipse(graphic,
3624 v + Vector(750.0, 0.0),
3625 Vector((x/5+50.0)/2.0, 0.0),
3630 graphic->addEntity(ellipse);
3631 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3632 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3638 // different rotation angles:
3640 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3641 ellipse = new RS_Ellipse(graphic,
3642 Vector(rot*200, 500.0),
3643 Vector(50.0, 0.0).rotate(rot),
3647 graphic->addEntity(ellipse);
3648 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3649 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3653 // different arc angles:
3655 for (rot=0.0; rot<=2*M_PI+0.1; rot+=(M_PI/8)) {
3656 for (a1=0.0; a1<=2*M_PI+0.1; a1+=(M_PI/8)) {
3657 for (a2=a1+M_PI/8; a2<=2*M_PI+a1+0.1; a2+=(M_PI/8)) {
3658 ellipse = new RS_Ellipse(graphic,
3659 Vector(-500.0-a1*200.0-5000.0*rot,
3661 Vector(50.0, 0.0).rotate(rot),
3665 graphic->addEntity(ellipse);
3666 graphic->addEntity(new RS_Point(graphic, ellipse->getMax()));
3667 graphic->addEntity(new RS_Point(graphic, ellipse->getMin()));
3673 RS_GraphicView * v = getGraphicView();
3683 void QC_ApplicationWindow::slotTestInsertText()
3685 RS_DEBUG->print("QC_ApplicationWindow::slotTestInsertText()");
3687 RS_Document * d = getDocument();
3691 RS_Graphic * graphic = (RS_Graphic *)d;
3693 if (graphic == NULL)
3697 RS_TextData textData;
3699 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);
3700 text = new RS_Text(graphic, textData);
3701 text->setLayerToActive();
3702 text->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3703 graphic->addEntity(text);
3707 for (y=-250.0; y<=250.0; y+=50.0) {
3708 for (x=-250.0; x<=250.0; x+=50.0) {
3711 textData = RS_TextData(v,
3722 text = new RS_Text(graphic, textData);
3724 text->setLayerToActive();
3725 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3728 graphic->addEntity(text);
3733 for (x=0.0; x<M_PI*2.0; x+=0.2) {
3734 Vector v(600.0+cos(x)*50.0, 0.0+sin(x)*50.0);
3736 line = new RS_Line(graphic,
3737 RS_LineData(Vector(600.0,0.0),
3739 line->setLayerToActive();
3740 line->setPenToActive();
3741 graphic->addEntity(line);
3743 textData = RS_TextData(v,
3754 text = new RS_Text(graphic, textData);
3756 text->setLayerToActive();
3757 text->setPen(RS_Pen(RS_Color(255, 0, 0),
3760 graphic->addEntity(text);
3763 RS_SolidData solidData = RS_SolidData(Vector(5.0, 10.0),
3765 Vector(15.0, 30.0));
3767 RS_Solid* s = new RS_Solid(graphic, solidData);
3769 s->setLayerToActive();
3770 s->setPen(RS_Pen(RS_Color(255, 255, 0),
3773 graphic->addEntity(s);
3775 RS_GraphicView* v = getGraphicView();
3786 void QC_ApplicationWindow::slotTestInsertImage()
3788 RS_DEBUG->print("QC_ApplicationWindow::slotTestInsertImage()");
3790 RS_Document * d = getDocument();
3794 RS_Graphic * graphic = (RS_Graphic *)d;
3796 if (graphic == NULL)
3800 RS_ImageData imageData;
3802 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);
3803 image = new RS_Image(graphic, imageData);
3805 image->setLayerToActive();
3806 image->setPen(RS_Pen(RS_Color(255, 0, 0), RS2::Width01, RS2::SolidLine));
3807 graphic->addEntity(image);
3814 void QC_ApplicationWindow::slotTestUnicode()
3816 RS_DEBUG->print("QC_ApplicationWindow::slotTestUnicode()");
3818 slotFileOpen("./fonts/unicode.cxf", RS2::FormatCXF);
3819 RS_Document* d = getDocument();
3821 RS_Graphic* graphic = (RS_Graphic*)d;
3822 if (graphic==NULL) {
3830 QChar uCode; // e.g. 65 (or 'A')
3831 QString strCode; // unicde as string e.g. '[0041] A'
3833 graphic->setAutoUpdateBorders(false);
3835 for (col=0x0000; col<=0xFFF0; col+=0x10) {
3836 printf("col: %X\n", col);
3837 for (row=0x0; row<=0xF; row++) {
3838 //printf(" row: %X\n", row);
3840 uCode = QChar(col+row);
3841 //printf(" code: %X\n", uCode.unicode());
3843 strCode.setNum(uCode.unicode(), 16);
3844 while (strCode.length()<4) {
3845 strCode="0"+strCode;
3847 strCode = "[" + strCode + "] " + uCode;
3849 if (graphic->findBlock(strCode)!=NULL) {
3850 RS_InsertData d(strCode,
3851 Vector(col/0x10*20.0,row*20.0),
3852 Vector(1.0,1.0), 0.0,
3853 1, 1, Vector(0.0, 0.0),
3854 NULL, RS2::NoUpdate);
3855 ins = new RS_Insert(graphic, d);
3856 ins->setLayerToActive();
3857 ins->setPen(RS_Pen(RS_Color(255, 255, 255),
3861 graphic->addEntity(ins);
3865 graphic->setAutoUpdateBorders(true);
3866 graphic->calculateBorders();
3873 void QC_ApplicationWindow::slotTestMath01()
3875 RS_DEBUG->print("QC_ApplicationWindow::slotTestMath01()");
3877 RS_Document* d = getDocument();
3879 RS_Graphic* graphic = (RS_Graphic*)d;
3880 if (graphic==NULL) {
3885 graphic->addEntity(new RS_Line(graphic,
3886 RS_LineData(Vector(0.0,0.0),
3887 Vector(2*M_PI,0.0))));
3888 graphic->addEntity(new RS_Line(graphic,
3889 RS_LineData(Vector(0.0,-1.0),
3894 double x = 59.0/ARAD;
3895 double x_0 = 60.0/ARAD;
3896 for (a=0.01; a<2*M_PI; a+=0.01) {
3898 RS_Line* line = new RS_Line(graphic,
3899 RS_LineData(Vector(a-0.01, cos(a-0.01)),
3900 Vector(a, cos(a))));
3901 graphic->addEntity(line);
3904 graphic->addEntity(new RS_Line(graphic,
3905 RS_LineData(Vector(a-0.01,cos(x_0)-sin(x_0)*(a-0.01-x_0)),
3906 Vector(a,cos(x_0)-sin(x_0)*(a-x_0)))));
3910 graphic->addEntity(new RS_Line(graphic,
3911 RS_LineData(Vector(x,0.0),
3915 graphic->addEntity(new RS_Line(graphic,
3916 RS_LineData(Vector(x_0,0.0),
3920 //graphic->addEntity(new RS_Line(graphic,
3921 // Vector(0.0,cos(x_0)-sin(x_0)*(0.0-x_0)),
3922 // Vector(6.0,cos(x_0)-sin(x_0)*(6.0-x_0))));
3925 RS_GraphicView* v = getGraphicView();
3935 void QC_ApplicationWindow::slotTestResize640()
3937 RS_DEBUG->print("QC_ApplicationWindow::slotTestResize640()");
3945 void QC_ApplicationWindow::slotTestResize800()
3947 RS_DEBUG->print("QC_ApplicationWindow::slotTestResize800()");
3955 void QC_ApplicationWindow::slotTestResize1024()
3957 RS_DEBUG->print("QC_ApplicationWindow::slotTestResize1024()");
3963 * overloaded for Message box on last window exit.
3965 bool QC_ApplicationWindow::queryExit(bool force)
3967 RS_DEBUG->print("QC_ApplicationWindow::queryExit()");
3974 QMessageBox::information(this, QMessageBox::tr("Warning"),
3975 tr("This is a %1 version "
3976 "which terminates\n"
3977 "automatically after 10min. This software is\n"
3978 "not intended for production use. Please buy\n"
3979 "a full version of the application from\n%2.\n"
3980 "You can save your work now.")
3981 //FAIL .arg(QC_APPNAME)
3982 .arg("Architektonas")
3983 #ifdef QC_CUSTOM_VENDOR
3984 .arg(QC_CUSTOM_VENDOR),
3986 .arg("RibbonSoft, http://www.ribbonsoft.com"),
3991 QList<QMdiSubWindow *> list = workspace->subWindowList();
3993 // for(QWidget * w=list.first(); w!=NULL; w=list.next())
3994 for(int i=0; i<list.size(); i++)
3996 succ = ((QC_MDIWindow *)list[i])->closeMDI(force);
4005 RS_DEBUG->print("QC_ApplicationWindow::queryExit(): OK");
4011 * Handle hotkeys. Don't let it to the default handler of Qt.
4012 * it will consume them also if a text field is active
4013 * which means it's impossible to enter a command.
4015 void QC_ApplicationWindow::keyPressEvent(QKeyEvent * e)
4018 static QTime ts = QTime();
4019 static QString firstKey = "";
4021 // single key codes:
4025 case Qt::Key_Control:
4028 case Qt::Key_CapsLock:
4030 // Q3MainWindow::keyPressEvent(e);
4031 QMainWindow::keyPressEvent(e);
4033 // forward to actions:
4034 RS_GraphicView * graphicView = getGraphicView();
4036 if (graphicView != NULL)
4037 graphicView->keyPressEvent(e);
4043 case Qt::Key_Escape:
4049 case Qt::Key_Return:
4050 if (firstKey.isEmpty())
4058 if (firstKey.isEmpty())
4060 actionHandler->slotZoomIn();
4066 if (firstKey.isEmpty())
4068 actionHandler->slotZoomOut();
4078 if (e->isAccepted())
4081 QTime now = QTime::currentTime();
4084 if (ts.msecsTo(now) < 2000)
4086 QString code = QString("%1%2").arg(firstKey).arg(QChar(e->key())).toLower();
4088 if (actionHandler->keycode(code) == false)
4092 if (QChar(e->key()).isPrint())
4093 firstKey += e->key();
4102 if (QChar(e->key()).isPrint())
4103 firstKey = e->key();
4106 // Q3MainWindow::keyPressEvent(e);
4107 QMainWindow::keyPressEvent(e);
4110 void QC_ApplicationWindow::keyReleaseEvent(QKeyEvent * e)
4115 case Qt::Key_Control:
4118 case Qt::Key_CapsLock:
4120 // Q3MainWindow::keyReleaseEvent(e);
4121 QMainWindow::keyReleaseEvent(e);
4123 // forward to actions:
4124 RS_GraphicView * graphicView = getGraphicView();
4126 if (graphicView != NULL)
4127 graphicView->keyReleaseEvent(e);
4134 // Q3MainWindow::keyPressEvent(e);
4135 QMainWindow::keyPressEvent(e);
4139 * @return Pointer to application window.
4141 /*static*/ QC_ApplicationWindow * QC_ApplicationWindow::getAppWindow()
4147 * @return Pointer to workspace.
4149 QMdiArea * QC_ApplicationWindow::getWorkspace()
4155 * @return Pointer to the currently active MDI Window or NULL if no
4156 * MDI Window is active.
4158 QC_MDIWindow * QC_ApplicationWindow::getMDIWindow()
4160 RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "QC_ApplicationWindow::getMDIWindow: workspace=%08X", workspace);
4162 if (workspace != NULL)
4164 RS_DEBUG->print("QC_ApplicationWindow::getMDIWindow: activeSubWindow=%08X", workspace->activeSubWindow());
4165 return (QC_MDIWindow *)workspace->activeSubWindow();
4168 RS_DEBUG->print("QC_ApplicationWindow::getMDIWindow: activeSubWindow=??? (workspace == NULL)");
4173 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4175 * @return Pointer to the graphic view of the currently active document
4176 * window or NULL if no window is available.
4178 /*virtual*/ RS_GraphicView * QC_ApplicationWindow::getGraphicView()
4180 QC_MDIWindow * m = getMDIWindow();
4183 return m->getGraphicView();
4189 * Implementation from RS_MainWindowInterface (and QS_ScripterHostInterface).
4191 * @return Pointer to the graphic document of the currently active document
4192 * window or NULL if no window is available.
4194 /*virtual*/ RS_Document * QC_ApplicationWindow::getDocument()
4196 QC_MDIWindow * m = getMDIWindow();
4199 return m->getDocument();
4205 * Creates a new document. Implementation from RS_MainWindowInterface.
4207 /*virtual*/ void QC_ApplicationWindow::createNewDocument(const QString & fileName/*= QString::null*/,
4208 RS_Document * doc/*= NULL*/)
4212 if (fileName != QString::null && getDocument() != NULL)
4213 getDocument()->setFilename(fileName);
4217 * Implementation from QG_MainWindowInterface.
4219 * @return Pointer to this.
4221 // /*virtual*/ Q3MainWindow * QC_ApplicationWindow::GetMainWindow()
4222 /*virtual*/ QMainWindow * QC_ApplicationWindow::GetMainWindow()
4228 * @return Pointer to action handler. Implementation from QG_MainWindowInterface.
4230 /*virtual*/ QG_ActionHandler * QC_ApplicationWindow::getActionHandler()
4232 return actionHandler;
4236 * Implementation from QG_MainWindowInterface.
4238 /*virtual*/ void QC_ApplicationWindow::showSimulationControls()
4241 simulationDockWindow->show();
4247 * @return Pointer to the qsa object.
4249 QSProject * QC_ApplicationWindow::getQSAProject()
4251 if (scripter != NULL)
4252 return scripter->getQSAProject();
4259 * Implementation from QG_MainWindowInterface.
4261 /*virtual*/ void QC_ApplicationWindow::setFocus2()