| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2004 Jürgen Riegel <[email protected]> * |
| 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_VIEW3DINVENTOR_H |
| 24 |
#define GUI_VIEW3DINVENTOR_H |
| 25 |
|
| 26 |
#include <memory> |
| 27 |
#include <optional> |
| 28 |
#include <QImage> |
| 29 |
|
| 30 |
#include <Base/Parameter.h> |
| 31 |
|
| 32 |
#include "MDIView.h" |
| 33 |
|
| 34 |
#include "Base/Vector3D.h" |
| 35 |
|
| 36 |
class QPrinter; |
| 37 |
class QOpenGLWidget; |
| 38 |
class QStackedWidget; |
| 39 |
|
| 40 |
namespace Gui |
| 41 |
{ |
| 42 |
|
| 43 |
class Document; |
| 44 |
class View3DInventorViewer; |
| 45 |
class View3DPy; |
| 46 |
class View3DSettings; |
| 47 |
class NaviCubeSettings; |
| 48 |
|
| 49 |
struct RayPickInfo |
| 50 |
{ |
| 51 |
bool isValid; |
| 52 |
Base::Vector3d point; |
| 53 |
std::string document; |
| 54 |
std::string object; |
| 55 |
std::optional<std::string> parentObject; |
| 56 |
std::optional<std::string> component; |
| 57 |
std::optional<std::string> subName; |
| 58 |
}; |
| 59 |
class GuiExport GLOverlayWidget: public QWidget |
| 60 |
{ |
| 61 |
Q_OBJECT |
| 62 |
|
| 63 |
public: |
| 64 |
explicit GLOverlayWidget(QWidget* parent = nullptr) |
| 65 |
: QWidget(parent) |
| 66 |
{} |
| 67 |
~GLOverlayWidget() override = default; |
| 68 |
virtual void setImage(const QImage& img) |
| 69 |
{ |
| 70 |
image = img; |
| 71 |
} |
| 72 |
void paintEvent(QPaintEvent*) override; |
| 73 |
|
| 74 |
protected: |
| 75 |
QImage image; |
| 76 |
}; |
| 77 |
|
| 78 |
/** The 3D view window |
| 79 |
* It consists out of the 3D view |
| 80 |
* \author Juergen Riegel |
| 81 |
*/ |
| 82 |
class GuiExport View3DInventor: public MDIView |
| 83 |
{ |
| 84 |
Q_OBJECT |
| 85 |
|
| 86 |
TYPESYSTEM_HEADER_WITH_OVERRIDE(); |
| 87 |
|
| 88 |
public: |
| 89 |
View3DInventor( |
| 90 |
Gui::Document* pcDocument, |
| 91 |
QWidget* parent, |
| 92 |
const QOpenGLWidget* sharewidget = nullptr, |
| 93 |
Qt::WindowFlags wflags = Qt::WindowFlags() |
| 94 |
); |
| 95 |
~View3DInventor() override; |
| 96 |
|
| 97 |
View3DInventor* clone() override; |
| 98 |
|
| 99 |
/// Message handler |
| 100 |
bool onMsg(const char* pMsg, const char** ppReturn) override; |
| 101 |
bool onHasMsg(const char* pMsg) const override; |
| 102 |
void deleteSelf() override; |
| 103 |
/// get called when the document is updated |
| 104 |
void onRename(Gui::Document* pDoc) override; |
| 105 |
void onUpdate() override; |
| 106 |
void viewAll() override; |
| 107 |
const char* getName() const override; |
| 108 |
|
| 109 |
/// print function of the view |
| 110 |
void print() override; |
| 111 |
void printPdf() override; |
| 112 |
void printPreview() override; |
| 113 |
void print(QPrinter*) override; |
| 114 |
|
| 115 |
PyObject* getPyObject() override; |
| 116 |
/** |
| 117 |
* If \a b is set to \a FullScreen the MDI view is displayed in full screen mode, if \a b |
| 118 |
* is set to \a TopLevel then it is displayed as an own top-level window, otherwise (\a Normal) |
| 119 |
* as tabbed window. |
| 120 |
* This method is reimplemented from MDIView to set the this widget as the proxy of the embedded |
| 121 |
* GL widget to get all key events in \a TopLevel or \a Fullscreen mode. |
| 122 |
*/ |
| 123 |
void setCurrentViewMode(ViewMode b) override; |
| 124 |
RayPickInfo getObjInfoRay(Base::Vector3d* startvec, Base::Vector3d* dirvec); |
| 125 |
bool setCamera(const char* pCamera); |
| 126 |
void toggleClippingPlane(); |
| 127 |
bool hasClippingPlane() const; |
| 128 |
|
| 129 |
void setOverlayWidget(QWidget*); |
| 130 |
void removeOverlayWidget(); |
| 131 |
|
| 132 |
View3DInventorViewer* getViewer() const |
| 133 |
{ |
| 134 |
return _viewer; |
| 135 |
} |
| 136 |
bool containsViewProvider(const ViewProvider*) const override; |
| 137 |
|
| 138 |
public Q_SLOTS: |
| 139 |
/// override the cursor in this view |
| 140 |
void setOverrideCursor(const QCursor&) override; |
| 141 |
void restoreOverrideCursor() override; |
| 142 |
|
| 143 |
void dump(const char* filename, bool onlyVisible = false); |
| 144 |
|
| 145 |
protected Q_SLOTS: |
| 146 |
void stopAnimating(); |
| 147 |
|
| 148 |
private: |
| 149 |
void applySettings(); |
| 150 |
|
| 151 |
protected: |
| 152 |
void windowStateChanged(QWidget* view) override; |
| 153 |
void dropEvent(QDropEvent* e) override; |
| 154 |
void dragEnterEvent(QDragEnterEvent* e) override; |
| 155 |
void keyPressEvent(QKeyEvent* e) override; |
| 156 |
void keyReleaseEvent(QKeyEvent* e) override; |
| 157 |
void focusInEvent(QFocusEvent* e) override; |
| 158 |
void customEvent(QEvent* e) override; |
| 159 |
void contextMenuEvent(QContextMenuEvent* e) override; |
| 160 |
|
| 161 |
private: |
| 162 |
View3DInventorViewer* _viewer; |
| 163 |
PyObject* _viewerPy; |
| 164 |
QTimer* stopSpinTimer; |
| 165 |
QStackedWidget* stack; |
| 166 |
std::unique_ptr<View3DSettings> viewSettings; |
| 167 |
std::unique_ptr<NaviCubeSettings> naviSettings; |
| 168 |
|
| 169 |
// friends |
| 170 |
friend class View3DPy; |
| 171 |
}; |
| 172 |
|
| 173 |
} // namespace Gui |
| 174 |
|
| 175 |
#endif // GUI_VIEW3DINVENTOR_H |