| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2015 Stefan Tröger <[email protected]> * |
| 3 |
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <[email protected]> * |
| 4 |
* * |
| 5 |
* This file is part of the FreeCAD CAx development system. * |
| 6 |
* * |
| 7 |
* This library is free software; you can redistribute it and/or * |
| 8 |
* modify it under the terms of the GNU Library General Public * |
| 9 |
* License as published by the Free Software Foundation; either * |
| 10 |
* version 2 of the License, or (at your option) any later version. * |
| 11 |
* * |
| 12 |
* This library is distributed in the hope that it will be useful, * |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 15 |
* GNU Library General Public License for more details. * |
| 16 |
* * |
| 17 |
* You should have received a copy of the GNU Library General Public * |
| 18 |
* License along with this library; see the file COPYING.LIB. If not, * |
| 19 |
* write to the Free Software Foundation, Inc., 59 Temple Place, * |
| 20 |
* Suite 330, Boston, MA 02111-1307, USA * |
| 21 |
* * |
| 22 |
***************************************************************************/ |
| 23 |
|
| 24 |
#ifndef GUI_VIEWPROVIDER_ViewProviderOrigin_H |
| 25 |
#define GUI_VIEWPROVIDER_ViewProviderOrigin_H |
| 26 |
|
| 27 |
#include <functional> |
| 28 |
#include <Base/Bitmask.h> |
| 29 |
#include <App/PropertyGeo.h> |
| 30 |
|
| 31 |
#include "ViewProviderGeoFeatureGroup.h" |
| 32 |
|
| 33 |
|
| 34 |
namespace Gui |
| 35 |
{ |
| 36 |
|
| 37 |
class Document; |
| 38 |
class ViewProviderDatum; |
| 39 |
|
| 40 |
enum class DatumElement |
| 41 |
{ |
| 42 |
// clang-format off |
| 43 |
Origin = 1 << 0, |
| 44 |
Axes = 1 << 1, |
| 45 |
Planes = 1 << 2 |
| 46 |
// clang-format on |
| 47 |
}; |
| 48 |
|
| 49 |
using DatumElements = Base::Flags<DatumElement>; |
| 50 |
|
| 51 |
class GuiExport ViewProviderCoordinateSystem: public ViewProviderGeoFeatureGroup |
| 52 |
{ |
| 53 |
PROPERTY_HEADER_WITH_OVERRIDE(Gui::ViewProviderCoordinateSystem); |
| 54 |
|
| 55 |
public: |
| 56 |
/// constructor. |
| 57 |
ViewProviderCoordinateSystem(); |
| 58 |
/// destructor. |
| 59 |
~ViewProviderCoordinateSystem() override; |
| 60 |
|
| 61 |
/// @name Override methods |
| 62 |
///@{ |
| 63 |
std::vector<App::DocumentObject*> claimChildren() const override; |
| 64 |
std::vector<App::DocumentObject*> claimChildren3D() const override; |
| 65 |
|
| 66 |
SoGroup* getChildRoot() const override |
| 67 |
{ |
| 68 |
return pcGroupChildren; |
| 69 |
} |
| 70 |
|
| 71 |
void attach(App::DocumentObject* pcObject) override; |
| 72 |
std::vector<std::string> getDisplayModes() const override; |
| 73 |
void setDisplayMode(const char* ModeName) override; |
| 74 |
///@} |
| 75 |
|
| 76 |
/** @name Temporary visibility mode |
| 77 |
* Control the visibility of origin and associated objects when needed |
| 78 |
*/ |
| 79 |
///@{ |
| 80 |
/// Set temporary visibility of some of origin's objects e.g. while rotating or mirroring |
| 81 |
void setTemporaryVisibility(DatumElements elements); |
| 82 |
/// Returns true if the origin in temporary visibility mode |
| 83 |
bool isTemporaryVisibility(); |
| 84 |
/// Reset the visibility |
| 85 |
void resetTemporaryVisibility(); |
| 86 |
///@} |
| 87 |
|
| 88 |
void setTemporaryScale(double factor); |
| 89 |
void resetTemporarySize(); |
| 90 |
|
| 91 |
void setPlaneLabelVisibility(bool val); |
| 92 |
|
| 93 |
bool canDragObjects() const override |
| 94 |
{ |
| 95 |
return false; |
| 96 |
} |
| 97 |
|
| 98 |
bool canDropObjects() const override |
| 99 |
{ |
| 100 |
return false; |
| 101 |
} |
| 102 |
|
| 103 |
/// Returns default size. Use this if it is not possible to determine appropriate size by other means |
| 104 |
static double defaultSize(); |
| 105 |
|
| 106 |
// the factor by which the axes are longer than the planes |
| 107 |
static constexpr float axesScaling = 1.5f; |
| 108 |
|
| 109 |
// default color for origini: light-blue (50, 150, 250, 255 stored as 0xRRGGBBAA) |
| 110 |
static const uint32_t defaultColor = 0x3296faff; |
| 111 |
|
| 112 |
protected: |
| 113 |
bool onDelete(const std::vector<std::string>&) override; |
| 114 |
|
| 115 |
private: |
| 116 |
using DatumObjectFunc = std::function<void(ViewProviderDatum*)>; |
| 117 |
void applyDatumObjects(const DatumObjectFunc& func); |
| 118 |
|
| 119 |
private: |
| 120 |
SoGroup* pcGroupChildren; |
| 121 |
|
| 122 |
std::map<Gui::ViewProvider*, bool> tempVisMap; |
| 123 |
}; |
| 124 |
|
| 125 |
} // namespace Gui |
| 126 |
|
| 127 |
ENABLE_BITMASK_OPERATORS(Gui::DatumElement) |
| 128 |
|
| 129 |
#endif // GUI_VIEWPROVIDER_ViewProviderOrigin_H |