| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2008 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 |
|
| 24 |
#ifndef GUI_VIEWPROVIDERANNOTATION_H |
| 25 |
#define GUI_VIEWPROVIDERANNOTATION_H |
| 26 |
|
| 27 |
#include "ViewProviderDocumentObject.h" |
| 28 |
#include <App/PropertyUnits.h> |
| 29 |
#include "SoTextLabel.h" |
| 30 |
|
| 31 |
class SoFont; |
| 32 |
class SoText2; |
| 33 |
class SoAsciiText; |
| 34 |
class SoBaseColor; |
| 35 |
class SoTranslation; |
| 36 |
class SoTransform; |
| 37 |
class SoRotationXYZ; |
| 38 |
class SoImage; |
| 39 |
class SoCoordinate3; |
| 40 |
|
| 41 |
namespace Gui |
| 42 |
{ |
| 43 |
|
| 44 |
class GuiExport ViewProviderAnnotation: public ViewProviderDocumentObject |
| 45 |
{ |
| 46 |
PROPERTY_HEADER_WITH_OVERRIDE(Gui::ViewProviderAnnotation); |
| 47 |
|
| 48 |
public: |
| 49 |
/// Constructor |
| 50 |
ViewProviderAnnotation(); |
| 51 |
~ViewProviderAnnotation() override; |
| 52 |
|
| 53 |
// Display properties |
| 54 |
App::PropertyColor TextColor; |
| 55 |
App::PropertyEnumeration Justification; |
| 56 |
App::PropertyFloat FontSize; |
| 57 |
App::PropertyFont FontName; |
| 58 |
App::PropertyFloat LineSpacing; |
| 59 |
App::PropertyAngle Rotation; |
| 60 |
App::PropertyEnumeration RotationAxis; |
| 61 |
|
| 62 |
void attach(App::DocumentObject*) override; |
| 63 |
void updateData(const App::Property*) override; |
| 64 |
std::vector<std::string> getDisplayModes() const override; |
| 65 |
void setDisplayMode(const char* ModeName) override; |
| 66 |
|
| 67 |
protected: |
| 68 |
void onChanged(const App::Property* prop) override; |
| 69 |
|
| 70 |
private: |
| 71 |
SoFont* pFont; |
| 72 |
SoText2* pLabel; |
| 73 |
SoAsciiText* pLabel3d; |
| 74 |
SoBaseColor* pColor; |
| 75 |
SoTranslation* pTranslation; |
| 76 |
SoRotationXYZ* pRotationXYZ; |
| 77 |
|
| 78 |
static const char* JustificationEnums[]; |
| 79 |
static const char* RotationAxisEnums[]; |
| 80 |
}; |
| 81 |
|
| 82 |
/** |
| 83 |
* This is a different implementation of an annotation object which uses an |
| 84 |
* SoImage node instead of an SoText2 or SoAsciiText node. |
| 85 |
* This approach gives a bit more flexibility since it can render arbitrary |
| 86 |
* annotations. |
| 87 |
*/ |
| 88 |
class GuiExport ViewProviderAnnotationLabel: public ViewProviderDocumentObject |
| 89 |
{ |
| 90 |
PROPERTY_HEADER_WITH_OVERRIDE(Gui::ViewProviderAnnotationLabel); |
| 91 |
|
| 92 |
public: |
| 93 |
/// Constructor |
| 94 |
ViewProviderAnnotationLabel(); |
| 95 |
~ViewProviderAnnotationLabel() override; |
| 96 |
|
| 97 |
// Display properties |
| 98 |
App::PropertyColor TextColor; |
| 99 |
App::PropertyColor BackgroundColor; |
| 100 |
App::PropertyEnumeration Justification; |
| 101 |
App::PropertyFloat FontSize; |
| 102 |
App::PropertyFont FontName; |
| 103 |
App::PropertyBool Frame; |
| 104 |
|
| 105 |
void attach(App::DocumentObject*) override; |
| 106 |
void updateData(const App::Property*) override; |
| 107 |
std::vector<std::string> getDisplayModes() const override; |
| 108 |
void setDisplayMode(const char* ModeName) override; |
| 109 |
|
| 110 |
protected: |
| 111 |
void onChanged(const App::Property* prop) override; |
| 112 |
void drawImage(const std::vector<std::string>&); |
| 113 |
|
| 114 |
private: |
| 115 |
static void dragStartCallback(void* data, SoDragger* d); |
| 116 |
static void dragFinishCallback(void* data, SoDragger* d); |
| 117 |
static void dragMotionCallback(void* data, SoDragger* d); |
| 118 |
|
| 119 |
private: |
| 120 |
SoCoordinate3* pCoords; |
| 121 |
SoImage* pImage; |
| 122 |
SoBaseColor* pColor; |
| 123 |
SoTranslation* pBaseTranslation; |
| 124 |
TranslateManip* pTextTranslation; |
| 125 |
|
| 126 |
static const char* JustificationEnums[]; |
| 127 |
}; |
| 128 |
|
| 129 |
} // namespace Gui |
| 130 |
|
| 131 |
|
| 132 |
#endif // GUI_VIEWPROVIDERANNOTATION_H |