SketchOrientationDialog.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2011 Jürgen Riegel <juergen.riegel@web.de>              *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 #include "PreCompiled.h"
00024 
00025 #ifndef _PreComp_
00026 # include <QDialog>
00027 #endif
00028 
00029 #include <Gui/MainWindow.h>
00030 #include <Base/Tools.h>
00031 
00032 #include "ui_SketchOrientationDialog.h"
00033 #include "SketchOrientationDialog.h"
00034 
00035 using namespace SketcherGui;
00036 
00037 SketchOrientationDialog::SketchOrientationDialog(void) 
00038 {
00039 
00040 }
00041 
00042 SketchOrientationDialog::~SketchOrientationDialog()
00043 {
00044 
00045 }
00046 
00047 int SketchOrientationDialog::exec()
00048 {
00049     //Gui::MDIView *mdi = Gui::Application::Instance->activeDocument()->getActiveView();
00050     //Gui::View3DInventorViewer *viewer = static_cast<Gui::View3DInventor *>(mdi)->getViewer();
00051 
00052     QDialog dlg(Gui::getMainWindow());
00053 
00054     Ui::SketchOrientationDialog ui_SketchOrientationDialog;
00055     ui_SketchOrientationDialog.setupUi(&dlg);
00056 
00057     int res;
00058     if (res=dlg.exec()) {
00059         double offset = ui_SketchOrientationDialog.Offset_doubleSpinBox->value();
00060         bool reverse = ui_SketchOrientationDialog.Reverse_checkBox->isChecked();
00061         if (ui_SketchOrientationDialog.XY_radioButton->isChecked()) {
00062             if (reverse) {
00063                 Pos = Base::Placement(Base::Vector3d(0,0,offset),Base::Rotation(-1.0,0.0,0.0,0.0));
00064                 DirType = 1;
00065             }
00066             else {
00067                 Pos = Base::Placement(Base::Vector3d(0,0,offset),Base::Rotation());
00068                 DirType = 0;
00069             }
00070         }
00071         else if (ui_SketchOrientationDialog.XZ_radioButton->isChecked()) {
00072             if (reverse) {
00073                 Pos = Base::Placement(Base::Vector3d(0,offset,0),Base::Rotation(Base::Vector3d(0,sqrt(2.0)/2.0,sqrt(2.0)/2.0),M_PI));
00074                 DirType = 3;
00075             }
00076             else {
00077                 Pos = Base::Placement(Base::Vector3d(0,offset,0),Base::Rotation(Base::Vector3d(-1,0,0),1.5*M_PI));
00078                 DirType = 2;
00079             }
00080         }
00081         else if (ui_SketchOrientationDialog.YZ_radioButton->isChecked()) {
00082             if (reverse) {
00083                 Pos = Base::Placement(Base::Vector3d(offset,0,0),Base::Rotation(-0.5,0.5,0.5,-0.5));
00084                 DirType = 5;
00085             }
00086             else {
00087                 Pos = Base::Placement(Base::Vector3d(offset,0,0),Base::Rotation(0.5,0.5,0.5,0.5));
00088                 DirType = 4;
00089             }
00090         }
00091     }
00092 
00093     return res;
00094 }

Generated on Wed Nov 23 19:00:38 2011 for FreeCAD by  doxygen 1.6.1