| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2009 Werner Mayer <wmayer[at]users.sourceforge.net> * |
| 3 |
* * |
| 4 |
* This file is part of the FreeCAD CAx development system. * |
| 5 |
* * |
| 6 |
* This library is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Library General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 |
* GNU Library General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Library General Public * |
| 17 |
* License along with this library; see the file COPYING.LIB. If not, * |
| 18 |
* write to the Free Software Foundation, Inc., 59 Temple Place, * |
| 19 |
* Suite 330, Boston, MA 02111-1307, USA * |
| 20 |
* * |
| 21 |
***************************************************************************/ |
| 22 |
|
| 23 |
#ifndef GUI_TRANSFORM_H |
| 24 |
#define GUI_TRANSFORM_H |
| 25 |
|
| 26 |
#include <QDialog> |
| 27 |
#include <set> |
| 28 |
#include <Base/Placement.h> |
| 29 |
|
| 30 |
#include "Selection.h" |
| 31 |
#include "TaskView/TaskDialog.h" |
| 32 |
#include "TaskView/TaskView.h" |
| 33 |
|
| 34 |
|
| 35 |
namespace Gui |
| 36 |
{ |
| 37 |
namespace Dialog |
| 38 |
{ |
| 39 |
|
| 40 |
class GuiExport TransformStrategy |
| 41 |
{ |
| 42 |
public: |
| 43 |
TransformStrategy(); |
| 44 |
virtual ~TransformStrategy(); |
| 45 |
|
| 46 |
Base::Vector3d getRotationCenter() const; |
| 47 |
void acceptDataTransform(const Base::Matrix4D& mat, App::DocumentObject* obj); |
| 48 |
void commitTransform(const Base::Matrix4D& plm); |
| 49 |
void applyTransform(const Base::Placement& plm); |
| 50 |
void resetTransform(); |
| 51 |
void applyViewTransform(const Base::Placement& plm, App::DocumentObject* obj); |
| 52 |
void resetViewTransform(App::DocumentObject* obj); |
| 53 |
virtual std::set<App::DocumentObject*> transformObjects() const = 0; |
| 54 |
}; |
| 55 |
|
| 56 |
class GuiExport DefaultTransformStrategy: public TransformStrategy, public Gui::SelectionObserver |
| 57 |
{ |
| 58 |
public: |
| 59 |
DefaultTransformStrategy(QWidget* widget); |
| 60 |
~DefaultTransformStrategy() override; |
| 61 |
std::set<App::DocumentObject*> transformObjects() const override; |
| 62 |
|
| 63 |
private: |
| 64 |
void onSelectionChanged(const Gui::SelectionChanges& msg) override; |
| 65 |
|
| 66 |
private: |
| 67 |
std::set<App::DocumentObject*> selection; |
| 68 |
QWidget* widget; |
| 69 |
}; |
| 70 |
|
| 71 |
class Ui_Placement; |
| 72 |
class GuiExport Transform: public QDialog |
| 73 |
{ |
| 74 |
Q_OBJECT |
| 75 |
|
| 76 |
public: |
| 77 |
Transform(QWidget* parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags()); |
| 78 |
~Transform() override; |
| 79 |
void accept() override; |
| 80 |
void reject() override; |
| 81 |
void showStandardButtons(bool); |
| 82 |
void setTransformStrategy(TransformStrategy* ts); |
| 83 |
|
| 84 |
protected: |
| 85 |
Base::Vector3d getDirection() const; |
| 86 |
void changeEvent(QEvent* e) override; |
| 87 |
|
| 88 |
public: |
| 89 |
void onApplyButtonClicked(); |
| 90 |
|
| 91 |
private: |
| 92 |
void onTransformChanged(int); |
| 93 |
Base::Placement getPlacementData() const; |
| 94 |
|
| 95 |
private: |
| 96 |
Ui_Placement* ui; |
| 97 |
Base::Placement pm; |
| 98 |
std::set<App::DocumentObject*> selection; |
| 99 |
TransformStrategy* strategy; |
| 100 |
}; |
| 101 |
|
| 102 |
class GuiExport TaskTransform: public Gui::TaskView::TaskDialog |
| 103 |
{ |
| 104 |
Q_OBJECT |
| 105 |
|
| 106 |
public: |
| 107 |
TaskTransform(); |
| 108 |
~TaskTransform() override; |
| 109 |
|
| 110 |
public: |
| 111 |
bool accept() override; |
| 112 |
bool reject() override; |
| 113 |
void clicked(int) override; |
| 114 |
|
| 115 |
void setTransformStrategy(TransformStrategy* ts); |
| 116 |
QDialogButtonBox::StandardButtons getStandardButtons() const override |
| 117 |
{ |
| 118 |
return QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel; |
| 119 |
} |
| 120 |
|
| 121 |
private: |
| 122 |
Transform* dialog; |
| 123 |
}; |
| 124 |
|
| 125 |
} // namespace Dialog |
| 126 |
} // namespace Gui |
| 127 |
|
| 128 |
#endif // GUI_TRANSFORM_H |