Transform.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2009 Werner Mayer <wmayer[at]users.sourceforge.net>     *
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 #ifndef GUI_TRANSFORM_H
00024 #define GUI_TRANSFORM_H
00025 
00026 #include <Gui/InputVector.h>
00027 #include <Gui/Selection.h>
00028 #include <Gui/TaskView/TaskDialog.h>
00029 #include <Gui/TaskView/TaskView.h>
00030 #include <Base/Placement.h>
00031 #include <set>
00032 
00033 namespace Gui {
00034 namespace Dialog {
00035 
00036 class GuiExport TransformStrategy
00037 {
00038 public:
00039     TransformStrategy();
00040     virtual ~TransformStrategy();
00041 
00042     Base::Vector3d getRotationCenter() const;
00043     void acceptDataTransform(const Base::Matrix4D& mat, App::DocumentObject* obj);
00044     void commitTransform(const Base::Matrix4D& plm);
00045     void applyTransform(const Base::Placement& plm);
00046     void resetTransform();
00047     void applyViewTransform(const Base::Placement& plm, App::DocumentObject* obj);
00048     void resetViewTransform(App::DocumentObject* obj);
00049     virtual std::set<App::DocumentObject*> transformObjects() const = 0;
00050 };
00051 
00052 class GuiExport DefaultTransformStrategy : public TransformStrategy,
00053                                            public Gui::SelectionObserver
00054 {
00055 public:
00056     DefaultTransformStrategy(QWidget* widget);
00057     virtual ~DefaultTransformStrategy();
00058     std::set<App::DocumentObject*> transformObjects() const;
00059 
00060 private:
00061     void onSelectionChanged(const Gui::SelectionChanges& msg);
00062 
00063 private:
00064     std::set<App::DocumentObject*> selection;
00065     QWidget* widget;
00066 };
00067 
00068 class Ui_Placement;
00069 class GuiExport Transform : public Gui::LocationDialog
00070 {
00071     Q_OBJECT
00072 
00073 public:
00074     Transform(QWidget* parent = 0, Qt::WFlags fl = 0);
00075     ~Transform();
00076     void accept();
00077     void reject();
00078     void showStandardButtons(bool);
00079     void setTransformStrategy(TransformStrategy* ts);
00080 
00081 protected:
00082     Base::Vector3f getDirection() const;
00083     void changeEvent(QEvent *e);
00084 
00085 public Q_SLOTS:
00086     void on_applyButton_clicked();
00087 
00088 private Q_SLOTS:
00089     void onTransformChanged(int);
00090 
00091 private:
00092     Base::Placement getPlacementData() const;
00093     void directionActivated(int);
00094 
00095 Q_SIGNALS:
00096     void directionChanged();
00097 
00098 private:
00099     typedef Gui::LocationInterfaceComp<Ui_Placement> Ui_TransformComp;
00100     Ui_TransformComp* ui;
00101     Base::Placement pm;
00102     std::set<App::DocumentObject*> selection;
00103     TransformStrategy* strategy;
00104 };
00105 
00106 class GuiExport TaskTransform : public Gui::TaskView::TaskDialog
00107 {
00108     Q_OBJECT
00109 
00110 public:
00111     TaskTransform();
00112     ~TaskTransform();
00113 
00114 public:
00115     bool accept();
00116     bool reject();
00117     void clicked(int);
00118 
00119     void setTransformStrategy(TransformStrategy* ts);
00120     virtual QDialogButtonBox::StandardButtons getStandardButtons() const
00121     { return QDialogButtonBox::Ok |
00122              QDialogButtonBox::Apply |
00123              QDialogButtonBox::Cancel; }
00124 
00125 private:
00126     Transform* dialog;
00127     Gui::TaskView::TaskBox* taskbox;
00128 };
00129 
00130 } // namespace Dialog
00131 } // namespace Gui
00132 
00133 #endif // GUI_TRANSFORM_H

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