qoccmainwindow.cpp

Go to the documentation of this file.
00001 /************************************************************************************
00002 **
00003 ** This file is part of the QtOPENCASCADE Toolkit.
00004 **
00005 ** Copyright (C) 2006, 2007, 2008 QtOCC Team Members
00006 **               Peter Dolbey, Marc Britten, Stephane Routelous
00007 **               Stefan Boeykens, Pawel Dobrolowski, Walter Steffe
00008 **               Álvaro Castro Castilla, Dirk Burski, Fotis Sioutis
00009 **
00010 ** This library is free software; you can redistribute it and/or
00011 ** modify it under the terms of the GNU Lesser General Public
00012 ** License as published by the Free Software Foundation; either
00013 ** version 2.1 of the License, or (at your option) any later version.
00014 ** 
00015 ** This library is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 ** Lesser General Public License for more details.
00019 ** 
00020 ** You should have received a copy of the GNU Lesser General Public
00021 ** License along with this library; if not, write to the Free Software
00022 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023 **
00024 ***********************************************************************************/
00025 
00026 #include <QtGui/QtGui>
00027 #include <QtGui/QFileDialog>
00028 #include <QtCore/QTextStream>
00029 #include <QtCore/QFileInfo>
00030 #include <QtCore/QString>
00031 
00032 #include <Aspect_RectangularGrid.hxx>
00033 #include <V3d_View.hxx>
00034 
00035 #include "qoccapplication.h"
00036 #include "qoccdocument.h"
00037 #include "qoccmainwindow.h"
00038 #include "qocccommands.h"
00039 
00040 void LoadBottle ( Handle(AIS_InteractiveContext) theContext );
00041 void ShowOrigin ( Handle(AIS_InteractiveContext) theContext );
00042 void AddVertex  ( double x, double y, double z, Handle(AIS_InteractiveContext) theContext );
00043 
00044 QoccMainWindow::QoccMainWindow()
00045 : myLastFolder(tr(""))
00046 {
00047 
00048         QoccDocument* doc = qGeomApp->createDocument();
00049         myController  = new QoccController( doc );
00050 
00051         myTabWidget = new QTabWidget( this );
00052     myTabWidget->setObjectName( QString::fromUtf8( "myTabWidget" ) );
00053     myTabWidget->setTabShape( QTabWidget::Rounded );
00054 
00055         mySketchFrame = new QoccFrame( myController, this );
00056         myTabWidget->addTab( mySketchFrame, tr( "Sketch" ) );
00057 
00058         setCentralWidget( myTabWidget );
00059 
00060 #if 0
00061         QAction* anAction = new QAction(tr("&Faces"), this);
00062         anAction->setStatusTip(tr("Highlight faces"));
00063         anAction->setIcon(QIcon(QString::fromUtf8(":/icons/actions/22x22/viewmagall.png")));
00064 #endif 
00065                 
00066         createActions();
00067     createMenus();
00068         createToolBars();
00069 
00070     statusBar()->showMessage(tr("A context menu is available by right-clicking"));
00071 
00072     setWindowTitle(tr("QtOPENCASCADE"));
00073     setMinimumSize(160, 160);
00074 
00075 #if 0
00076         // Make a circle nothing more just a circle
00077         
00078         int doc_id = myController->getDocument()->id();
00079         double radius = 50.;
00080 
00081         qGeomApp->basicOps( doc_id )->StartOperation();
00082         Handle(GEOM_Object) centre = qGeomApp->basicOps( doc_id )->MakePointXYZ( 50., 50., 0.); 
00083         Handle(GEOM_Object) vector = qGeomApp->basicOps( doc_id )->MakeVectorDXDYDZ( 0., 0., 100.); 
00084         Handle(GEOM_Object) line = qGeomApp->basicOps( doc_id )->MakeLine(centre, vector);
00085         myController->getDocument()->RegisterPresentation(centre);
00086         myController->getDocument()->RegisterPresentation(line);
00087         qGeomApp->basicOps( doc_id )->FinishOperation();
00088 
00089         qGeomApp->curvesOps( doc_id )->StartOperation();
00090         Handle(GEOM_Object) circle = qGeomApp->curvesOps( doc_id )->MakeCirclePntVecR(centre, vector, radius);
00091         myController->getDocument()->RegisterPresentation(circle);
00092         qGeomApp->curvesOps( doc_id )->FinishOperation();
00093 
00094 #endif
00095 
00096 #if 0
00097 
00098         //step 1 example (create a box) and present it
00099         qGeomEngine->GetI3DPrimOperations( doc->id() )->StartOperation();
00100         Handle(GEOM_Object) anObj1 = qGeomEngine->GetI3DPrimOperations( doc->id() )->MakeBoxDXDYDZ(100.,100.,200.);
00101         doc->RegisterPresentation(anObj1);
00102         qGeomEngine->GetI3DPrimOperations(1)->FinishOperation();
00103 
00104         //step 2 (create a cylinder) and present it
00105         qGeomEngine->GetI3DPrimOperations( doc->id() )->StartOperation();
00106         Handle(GEOM_Object) anObj2 = qGeomEngine->GetI3DPrimOperations( doc->id() )->MakeCylinderRH(50.,100.);
00107         doc->RegisterPresentation(anObj2);
00108         qGeomEngine->GetI3DPrimOperations(1)->FinishOperation();
00109 
00110         //step 3 (Cut the box using as tool the cylinder)
00111         qGeomEngine->GetI3DPrimOperations( doc->id() )->StartOperation();
00112         Handle(GEOM_Object) anObj3 = qGeomEngine->GetIBooleanOperations( doc->id() )->MakeBoolean(anObj1,anObj2,2);
00113 
00114         //here because of shape evolution we have to remove box and cylinder presentations
00115         doc->RemovePresentation(anObj1);
00116         doc->RemovePresentation(anObj2);
00117 
00118         //and display the cut object
00119         doc->RegisterPresentation(anObj3);
00120         qGeomEngine->GetIBooleanOperations( doc->id() )->FinishOperation();
00121 
00122         //step 4 (Create a fillet on the cut object)
00123         qGeomEngine->GetILocalOperations( doc->id() )->StartOperation();
00124         Handle(GEOM_Object) anObj4 = qGeomEngine->GetILocalOperations( doc->id() )->MakeFilletAll(anObj3,5.);
00125 
00126         //here because of shape evolution we have to remove the cut object
00127         doc->RemovePresentation(anObj3);
00128 
00129         //and display the filleted object
00130         doc->RegisterPresentation(anObj4);
00131         qGeomEngine->GetILocalOperations( doc->id() )->FinishOperation();
00132 
00133 #endif 
00134 
00135 }
00136 
00137 void QoccMainWindow::fileNew()
00138 {
00139     statusBar()->showMessage(tr("Invoked File|New"));
00140         myController->clearCommand ();
00141         myController->clearAllLocalContexts();
00142         myController->deleteAllObjects();
00143 }
00144 
00145 void QoccMainWindow::fileOpen()
00146 {
00147         QString         fileName;
00148         QString         fileType;
00149         QFileInfo       fileInfo;
00150 
00151         QoccInputOutput::FileFormat format;
00152         QoccInputOutput reader;
00153 
00154     statusBar()->showMessage(tr("Invoked File|Open"));
00155         myController->clearCommand ();
00156 
00157         fileName = QFileDialog::getOpenFileName ( this,
00158                                                                                           tr("Open File"),
00159                                                                                           myLastFolder,
00160                                                                                           tr( "All drawing types (*.brep *.rle *.igs *iges *.stp *.step *stl);;"
00161                                                                                               "BREP (*.brep *.rle);;"
00162                                                                                                   "STEP (*.step *.stp);;"
00163                                                                                                   "IGES (*.iges *.igs);;"
00164                                                                                                   "STL (*.stl)" ));
00165         if (!fileName.isEmpty())
00166         {
00167                 fileInfo.setFile(fileName);
00168                 fileType = fileInfo.suffix();
00169                 if (fileType.toLower() == tr("brep") || fileType.toLower() == tr("rle"))
00170                 {
00171                         format = QoccInputOutput::FormatBREP;
00172                 }
00173                 if (fileType.toLower() == tr("step") || fileType.toLower() == tr("stp"))
00174                 {
00175                         format = QoccInputOutput::FormatSTEP;
00176                 }
00177                 if (fileType.toLower() == tr("iges") || fileType.toLower() == tr("igs"))
00178                 {
00179                         format = QoccInputOutput::FormatIGES;
00180                 }
00181                 if (fileType.toLower() == tr("stl"))
00182                 {
00183                         format = QoccInputOutput::FormatSTL;
00184                 }
00185                 myController->clearAllLocalContexts();
00186                 myLastFolder = fileInfo.absolutePath();
00187                 emit fileOpening();
00188                 reader.importModel ( fileInfo.absoluteFilePath(), format, myController->getContext() );
00189                 emit fileOpened();
00190         }
00191 }
00192 
00193 void QoccMainWindow::fileSave()
00194 {
00195     statusBar()->showMessage(tr("Invoked File|Save"));
00196         myController->clearCommand ();
00197 }
00198 
00199 void QoccMainWindow::filePrint()
00200 {
00201     statusBar()->showMessage(tr("Invoked File|Print"));
00202         myController->clearCommand ();
00203 }
00204 
00205 void QoccMainWindow::fileClose()
00206 {
00207     statusBar()->showMessage(tr("Invoked File|Close"));
00208         myController->clearCommand ();
00209 }
00210 
00211 void QoccMainWindow::undo()
00212 {
00213     statusBar()->showMessage(tr("Invoked Edit|Undo"));
00214         myController->undo();
00215         myController->clearCommand ();
00216 }
00217 
00218 void QoccMainWindow::redo()
00219 {
00220     statusBar()->showMessage(tr("Invoked Edit|Redo"));
00221         myController->redo();
00222         myController->clearCommand ();
00223 }
00224 
00225 void QoccMainWindow::cut()
00226 {
00227     statusBar()->showMessage(tr("Invoked Edit|Cut"));
00228         myController->clearCommand ();
00229 }
00230 
00231 void QoccMainWindow::copy()
00232 {
00233     statusBar()->showMessage(tr("Invoked Edit|Copy"));
00234         myController->clearCommand ();
00235 }
00236 
00237 void QoccMainWindow::paste()
00238 {
00239     statusBar()->showMessage(tr("Invoked Edit|Paste"));
00240         myController->clearCommand ();
00241 }
00242 
00243 void QoccMainWindow::about()
00244 {
00245     statusBar()->showMessage(tr("Invoked Help|About"));
00246         myController->clearCommand ();
00247     QMessageBox::about(this, tr("About Menu"),
00248                        tr("This Qt<b>OPENCASCADE</b> example shows "
00249                                               "how to create a simple Qt4 Viewer."));
00250 }
00251 
00252 void QoccMainWindow::aboutQt()
00253 {
00254         statusBar()->showMessage(tr("Invoked Help|About Qt"));
00255         qApp->aboutQt();
00256 }
00257 
00258 void QoccMainWindow::selectNeutralPoint()
00259 {
00260         statusBar()->showMessage(tr("Invoked Select|Clear Filters"));
00261         myController->clearAllLocalContexts();
00262 }
00263 void QoccMainWindow::selectFaces()
00264 {
00265         statusBar()->showMessage(tr("Invoked Select|Faces"));
00266         myController->setLocalContext(TopAbs_FACE);
00267 }
00268 
00269 void QoccMainWindow::selectVertices()
00270 {
00271         statusBar()->showMessage(tr("Invoked Select|Vertices"));
00272         myController->setLocalContext(TopAbs_VERTEX);
00273 }
00274 
00275 void QoccMainWindow::selectEdges()
00276 {
00277         statusBar()->showMessage(tr("Invoked Select|Edges"));
00278         myController->setLocalContext(TopAbs_EDGE);
00279 }
00280 void QoccMainWindow::selectWires()
00281 {
00282         statusBar()->showMessage(tr("Invoked Select|Wires"));
00283         myController->setLocalContext(TopAbs_WIRE);
00284 }
00285 void QoccMainWindow::selectShells()
00286 {
00287         statusBar()->showMessage(tr("Invoked Select|Shells"));
00288         myController->setLocalContext(TopAbs_SHELL);
00289 }
00290 void QoccMainWindow::selectSolids()
00291 {
00292         statusBar()->showMessage(tr("Invoked Select|Solids"));
00293         myController->setLocalContext(TopAbs_SOLID);
00294 }
00295 void QoccMainWindow::selectCompSolids()
00296 {
00297         statusBar()->showMessage(tr("Invoked Select|Compound Solids"));
00298         myController->setLocalContext(TopAbs_COMPSOLID);
00299 }
00300 void QoccMainWindow::selectCompounds()
00301 {
00302         statusBar()->showMessage(tr("Invoked Select|Compounds"));
00303         myController->setLocalContext(TopAbs_COMPOUND);
00304 }
00305 void QoccMainWindow::selectShapes()
00306 {
00307         statusBar()->showMessage(tr("Invoked Select|Shapes"));
00308         myController->setLocalContext(TopAbs_SHAPE);
00309 }
00310 
00311 void QoccMainWindow::circleCentre()
00312 {
00313         statusBar()->showMessage(tr("Invoked Draw|Circle Centre"));
00314         QoccCommand* cc = new QoccCmdCircle2Pt( circle2PtAction );
00315         myController->setCommand ( cc );
00316 }
00317 
00318 void QoccMainWindow::line2Pt()
00319 {
00320         statusBar()->showMessage(tr("Invoked Draw|Line"));
00321         QoccCommand* cc = new QoccCmdLine2Pt( line2PtAction );
00322         myController->setCommand ( cc );
00323 }
00324 
00325 void QoccMainWindow::vertex()
00326 {
00327         statusBar()->showMessage(tr("Invoked Draw|Vertex"));
00328         QoccCmdPoint* cc = new QoccCmdPoint( pointAction );
00329         myController->setCommand ( cc );
00330 }
00331 
00332 void QoccMainWindow::cancelDraw()
00333 {
00334         statusBar()->showMessage(tr("Cancel Draw"));
00335         myController->clearCommand ( );
00336 }
00337 
00338 void QoccMainWindow::bottle()
00339 {
00340     statusBar()->showMessage(tr("Invoked File|Load Bottle"));
00341         myController->clearCommand ( );
00342         QApplication::setOverrideCursor( Qt::WaitCursor );
00343         myController->clearAllLocalContexts();
00344         myController->deleteAllObjects ();
00345         // Call the "bottle factory" to load and display the shape
00346         LoadBottle (myController->getContext());
00347         QApplication::restoreOverrideCursor();
00348 }
00349 /*
00350 void QoccMainWindow::xyzPosition ( Qocc3dWidget* widget)
00351 {
00352         QString aString;
00353         QTextStream ts(&aString);
00354         ts << widget->x() << "," << widget->y() << "," << widget->z();
00355         statusBar()->showMessage(aString);
00356 }
00357 */
00358 /*
00359 void QoccMainWindow::addPoint (V3d_Coordinate X,
00360                                                        V3d_Coordinate Y,
00361                                                        V3d_Coordinate Z)
00362 {
00363         AddVertex ( X, Y, Z, myController->getContext() );
00364 }
00365 */
00366 void QoccMainWindow::statusMessage (const QString aMessage)
00367 {
00368         statusBar()->showMessage(aMessage);
00369 }
00370 /*!
00371 \brief  This routine is a utility function for creating actions. Use tr("str")
00372                 in the calling function to provide support for language translations.
00373 \param  caption         the menu caption.
00374 \param  shortcut        keyboard shot.
00375 \param  tip                     the tool tip text.
00376 \param  slot            the slot function to be called, e.g. use SLOT(fooBar()) .
00377 \param  target          the QObject target of the connection, if not this object.
00378 */
00379 QAction* QoccMainWindow::createAction(const QString& caption,
00380                                                                           const QString& shortcut,
00381                                                                           const QString& tip,
00382                                                                           const char* slot,
00383                                                                           const QObject* target)
00384 {
00385         QAction* anAction = new QAction( caption, this );
00386     anAction->setShortcut( shortcut );
00387     anAction->setStatusTip( tip );
00388         connect( anAction, SIGNAL(triggered()), target == NULL ? this : target, slot );
00389         return anAction;
00390 }
00391 
00392 void QoccMainWindow::createActions()
00393 {
00394     newAction   = createAction( tr("&New"),     tr("Ctrl+N"), tr("Create a new file"),         SLOT(fileNew()) );
00395     openAction  = createAction( tr("&Open..."), tr("Ctrl+O"), tr("Open an existing file"),     SLOT(fileOpen()) );
00396     saveAction  = createAction( tr("&Save"),    tr("Ctrl+S"), tr("Save the document to disk"), SLOT(fileSave()) );
00397     printAction = createAction( tr("&Print..."),tr("Ctrl+P"), tr("Print the document"),        SLOT(filePrint()) );
00398 
00399     exitAction  = createAction( tr("E&xit"),    tr("Ctrl+X"), tr("Exit the application"),      SLOT(close()) );
00400 
00401     undoAction  = createAction( tr("&Undo"),    tr("Ctrl+Z"), tr("Undo the last operation"),   SLOT(undo()) );
00402     redoAction  = createAction( tr("&Redo"),    tr("Ctrl+Y"), tr("Redo the last operation"),   SLOT(redo()) );
00403     cutAction   = createAction( tr("Cu&t"),     tr("Ctrl+X"), tr("Cut to the clipboard"),      SLOT(cut()) );
00404     copyAction  = createAction( tr("&Copy"),    tr("Ctrl+C"), tr("Copy to the clipboard"),     SLOT(copy()) );
00405     pasteAction = createAction( tr("&Paste"),   tr("Ctrl+V"), tr("Paste the clipboard"),       SLOT(paste()) );
00406 
00407     aboutAction   = createAction( tr("&About"),    tr(""), tr("Show the application's About box"),  SLOT(about()) );
00408     aboutQtAction = createAction( tr("About &Qt"), tr(""), tr("Show the Qt library's About box"),   SLOT(aboutQt()) );
00409         gridOnAction  = createAction( tr("&Grid On"),  tr("Ctrl+G"), tr("Turn the grid on"), SLOT(gridOn()),  myController );
00410         gridOffAction = createAction( tr("Gri&d Off"), tr("Ctrl+D"), tr("Turn the grid off"), SLOT(gridOff()), myController );
00411 
00412         gridXYAction = createAction( tr("XY Grid"), tr(""), tr("Grid on XY Plane"), SLOT(gridXY()), myController );
00413         gridXZAction = createAction( tr("XZ Grid"), tr(""), tr("Grid on XZ Plane"), SLOT(gridXZ()), myController );
00414         gridYZAction = createAction( tr("YZ Grid"), tr(""), tr("Grid on YZ Plane"), SLOT(gridYZ()), myController );
00415 
00416         gridRectAction = createAction( tr("Rectangular"), tr(""), tr("Retangular grid"), SLOT(gridRect()), myController );
00417         gridCircAction = createAction( tr("Circular"),    tr(""), tr("Circular grid"),   SLOT(gridCirc()), myController );
00418 
00419         
00420         pointAction = new QAction(tr("&Points"), this);
00421     pointAction->setStatusTip(tr("Points"));
00422         pointAction->setIcon(QIcon(QString::fromUtf8(":/icons/icons/point.png")));
00423         connect( pointAction, SIGNAL( triggered() ), this, SLOT( vertex()) );
00424         
00425         circle2PtAction = new QAction(tr("&Circle Centre, Radius"), this);
00426     circle2PtAction->setStatusTip(tr("Circle - centre, radius"));
00427         circle2PtAction->setIcon(QIcon(QString::fromUtf8(":/icons/icons/circlecentre.png")));
00428         connect( circle2PtAction, SIGNAL( triggered() ), this, SLOT( circleCentre()) );
00429 
00430         line2PtAction = new QAction(tr("&Line"), this);
00431     line2PtAction->setStatusTip(tr("Line - 2 point"));
00432         line2PtAction->setIcon(QIcon(QString::fromUtf8(":/icons/icons/line.png")));
00433         connect( line2PtAction, SIGNAL( triggered() ), this, SLOT( line2Pt()) );
00434 
00435         cancelDrawAction = new QAction(tr("Cancel"), this);
00436     circle2PtAction->setStatusTip(tr("Cancel"));
00437 
00438         connect( cancelDrawAction, SIGNAL( triggered() ), this, SLOT( cancelDraw()) );
00439 
00440 
00441 /*      To be completed
00442         QAction *selectNeutralAction;
00443         QAction *selectCompoundAction;  
00444         QAction *selectCompSolidAction; 
00445         QAction *selectCompSolid;               
00446         QAction *selectShapeAction;             
00447 */
00448         selectVertexAction  = createAction(tr("&Vertices"), "", tr("Select Vertices"),     SLOT(selectVertices()));
00449         selectEdgeAction    = createAction(tr("&Edges"),    "", tr("Select Edges"),        SLOT(selectEdges()));
00450         selectWireAction    = createAction(tr("&Wires"),    "", tr("Select Wires"),        SLOT(selectWires()));
00451         selectFaceAction    = createAction(tr("&Faces"),    "", tr("Select Faces"),        SLOT(selectFaces()));
00452         selectShellAction   = createAction(tr("&Shells"),   "", tr("Select Shells"),       SLOT(selectShells()));
00453         selectNeutralAction = createAction(tr("&Normal"),   "", tr("No selection filter"), SLOT(selectNeutralPoint()));
00454 
00455         // And the bottle example
00456 
00457         bottleAction = new QAction(tr("Load &Bottle"), this);
00458         bottleAction->setShortcut(tr("Ctrl+B"));
00459     bottleAction->setStatusTip(tr("Bottle sample."));
00460     connect(bottleAction, SIGNAL(triggered()), this, SLOT(bottle()));
00461 
00462 }
00463 
00464 void QoccMainWindow::createMenus()
00465 {
00466     fileMenu = menuBar()->addMenu( tr("&File") );
00467                 fileMenu->addAction( newAction );
00468                 fileMenu->addAction( openAction );
00469                 fileMenu->addAction( saveAction );
00470                 fileMenu->addAction( printAction );
00471 /*
00472                 Comment out the 2 lines below to hide the
00473                 Load Bottle menu option - still left in for
00474                 now as a demo feature.
00475 */
00476                 fileMenu->addSeparator();
00477                 fileMenu->addAction( bottleAction );
00478 
00479                 fileMenu->addSeparator();
00480                 fileMenu->addAction( exitAction );
00481 
00482     editMenu = menuBar()->addMenu( tr("&Edit") );
00483                 editMenu->addAction( undoAction );
00484                 editMenu->addAction( redoAction );
00485                 editMenu->addSeparator();
00486                 editMenu->addAction( cutAction );
00487                 editMenu->addAction( copyAction );
00488                 editMenu->addAction( pasteAction );
00489 
00490         drawMenu = menuBar()->addMenu( tr("&Draw") );
00491                 drawMenu->addAction( pointAction );
00492                 drawMenu->addAction( line2PtAction );
00493                 drawMenu->addAction( circle2PtAction );
00494                 drawMenu->addSeparator();
00495                 drawMenu->addAction( cancelDrawAction );
00496 
00497         selectMenu = menuBar()->addMenu( tr("&Select") );
00498                 selectMenu->addAction( selectVertexAction );
00499                 selectMenu->addAction( selectEdgeAction );
00500                 selectMenu->addAction( selectWireAction );
00501                 selectMenu->addAction( selectFaceAction );
00502                 selectMenu->addAction( selectShellAction );
00503                 selectMenu->addSeparator();
00504                 selectMenu->addAction( selectNeutralAction );
00505 
00506         viewMenu = menuBar()->addMenu( tr("&View") );
00507 /*
00508                 viewDisplayMenu = viewMenu->addMenu( tr("&Display") );
00509                         viewDisplayMenu->addAction( viewFrontAction );
00510                         viewDisplayMenu->addAction( viewBackAction );
00511                         viewDisplayMenu->addAction( viewTopAction );
00512                         viewDisplayMenu->addAction( viewBottomAction );
00513                         viewDisplayMenu->addAction( viewLeftAction );
00514                         viewDisplayMenu->addAction( viewRightAction );
00515                         viewDisplayMenu->addSeparator();
00516                         viewDisplayMenu->addAction( viewAxoAction );
00517                         viewDisplayMenu->addAction( viewGridAction );
00518                         viewDisplayMenu->addSeparator();
00519                         viewDisplayMenu->addAction( viewResetAction );
00520                         viewDisplayMenu->addSeparator();
00521                         viewDisplayMenu->addAction( backgroundAction );
00522 */
00523 /*
00524                 viewActionsMenu = viewMenu->addMenu( tr("&Actions") );
00525                         viewActionsMenu->addAction( fitAction );
00526                         viewActionsMenu->addAction( fitAllAction );
00527                         viewActionsMenu->addAction( zoomAction );
00528                         viewActionsMenu->addAction( panAction );
00529                         viewActionsMenu->addAction( rotAction );
00530 */
00531 
00532                 gridMenu = viewMenu->addMenu( tr("&Grid") );
00533                         gridMenu->addAction( gridOnAction );
00534                         gridMenu->addAction( gridOffAction );
00535                         gridMenu->addSeparator();
00536                         gridMenu->addAction( gridXYAction );
00537                         gridMenu->addAction( gridXZAction );
00538                         gridMenu->addAction( gridYZAction );
00539                         gridMenu->addSeparator();
00540                         gridMenu->addAction( gridRectAction );
00541                         gridMenu->addAction( gridCircAction );
00542 
00543     helpMenu = menuBar()->addMenu(tr("&Help"));
00544     helpMenu->addAction(aboutAction);
00545     helpMenu->addAction(aboutQtAction);
00546 }
00547 
00548 // Now for the old QtOCCViewWidget slots (still to be completed)
00549 /*
00550         fitAction = new QAction(tr("&Fit Window"), this);
00551         fitAction->setShortcut(tr("Ctrl+F"));
00552     fitAction->setStatusTip(tr("Fit to window"));
00553     connect(fitAction, SIGNAL(triggered()), myOCC, SLOT(fitExtents()));
00554 
00555         fitAllAction = new QAction(tr("Fit &All"), this);
00556         fitAllAction->setShortcut(tr("Ctrl+A"));
00557     fitAllAction->setStatusTip(tr("Fit contents to viewport"));
00558     connect(fitAllAction, SIGNAL(triggered()), myOCC, SLOT(fitAll()));
00559 
00560         zoomAction = new QAction(tr("&Zoom"), this);
00561         zoomAction->setStatusTip(tr("Zoom in window"));
00562     connect(zoomAction, SIGNAL(triggered()), myOCC, SLOT(fitArea()));
00563 
00564         panAction = new QAction(tr("&Pan"), this);
00565     panAction->setStatusTip(tr("Window panning"));
00566     connect(panAction, SIGNAL(triggered()), myOCC, SLOT(pan()));
00567 
00568         rotAction = new QAction(tr("&Rotate"), this);
00569         rotAction->setShortcut(tr("Ctrl+R"));
00570     rotAction->setStatusTip(tr("Window rotation"));
00571     connect(rotAction, SIGNAL(triggered()), myOCC, SLOT(rotation()));
00572 */
00573 
00574 
00575         // Standard View
00576 /*
00577         viewFrontAction = new QAction(tr("Front"), this);
00578         viewFrontAction->setStatusTip(tr("View From Front"));
00579     connect(viewFrontAction, SIGNAL(triggered()), myOCC, SLOT(viewFront()));
00580 
00581         viewBackAction = new QAction(tr("Back"), this);
00582         viewBackAction->setStatusTip(tr("View From Back"));
00583     connect(viewBackAction, SIGNAL(triggered()), myOCC, SLOT(viewBack()));
00584 
00585         viewTopAction = new QAction(tr("Top"), this);
00586         viewTopAction->setStatusTip(tr("View From Top"));
00587     connect(viewTopAction, SIGNAL(triggered()), myOCC, SLOT(viewTop()));
00588 
00589         viewBottomAction = new QAction(tr("Bottom"), this);
00590         viewBottomAction->setStatusTip(tr("View From Bottom"));
00591     connect(viewBottomAction, SIGNAL(triggered()), myOCC, SLOT(viewBottom()));
00592 
00593         viewLeftAction = new QAction(tr("Left"), this);
00594         viewLeftAction->setStatusTip(tr("View From Left"));
00595     connect(viewLeftAction, SIGNAL(triggered()), myOCC, SLOT(viewLeft()));
00596 
00597         viewRightAction = new QAction(tr("Right"), this);
00598         viewRightAction->setStatusTip(tr("View From Right"));
00599     connect(viewRightAction, SIGNAL(triggered()), myOCC, SLOT(viewRight()));
00600 
00601         viewAxoAction = new QAction(tr("Axonometric"), this);
00602         viewAxoAction->setStatusTip(tr("Axonometric view"));
00603     connect(viewAxoAction, SIGNAL(triggered()), myOCC, SLOT(viewAxo()));
00604 
00605         viewGridAction = new QAction(tr("Grid"), this);
00606         viewGridAction->setStatusTip(tr("View from grid"));
00607     connect(viewGridAction, SIGNAL(triggered()), myOCC, SLOT(viewGrid()));
00608 
00609         viewResetAction = new QAction(tr("Reset"), this);
00610         viewResetAction->setStatusTip(tr("Reset the view"));
00611     connect(viewResetAction, SIGNAL(triggered()), myOCC, SLOT(viewReset()));
00612 
00613         backgroundAction = new QAction( tr("&Background"), this );
00614         backgroundAction->setStatusTip(tr("Change the background colour"));
00615         connect(backgroundAction, SIGNAL(triggered()), myOCC, SLOT(background()));
00616 
00617         // The co-ordinates from the view
00618         connect( myOCC, SIGNAL(mouseMoved(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)),
00619                      this,   SLOT(xyzPosition(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)) );
00620 
00621         // Add a point from the view
00622         connect( myOCC, SIGNAL(pointClicked(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)),
00623                      this,   SLOT (addPoint    (V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)) );
00624 
00625         connect( myOCC, SIGNAL(sendStatus(const QString)),
00626                      this,  SLOT  (statusMessage(const QString)) );
00627 */
00628 
00629 
00630 void QoccMainWindow::createToolBars()
00631 {
00632         drawToolBar = new QToolBar (tr("Drawing tools"), this);
00633         this->addToolBar(Qt::LeftToolBarArea, drawToolBar);
00634         drawToolBar->setObjectName(QString::fromUtf8("drawToolBar"));
00635     drawToolBar->setCursor(QCursor(Qt::PointingHandCursor));
00636     drawToolBar->setOrientation(Qt::Vertical);
00637 
00638         drawToolBar->addAction( pointAction );
00639         drawToolBar->addAction( line2PtAction );
00640         drawToolBar->addAction( circle2PtAction );
00641 }
00642 
00643 
00644 
00645 

Generated on Sat Feb 23 21:22:18 2008 for QtGEOM by  doxygen 1.4.7