00001 /*************************************************************************** 00002 * Copyright (c) 2008 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 00024 #ifndef GUI_VIEWPROVIDERANNOTATION_H 00025 #define GUI_VIEWPROVIDERANNOTATION_H 00026 00027 #include "ViewProviderDocumentObject.h" 00028 #include <App/PropertyUnits.h> 00029 00030 class SoFont; 00031 class SoText2; 00032 class SoAsciiText; 00033 class SoBaseColor; 00034 class SoTranslation; 00035 class SoTransform; 00036 class SoRotationXYZ; 00037 class SoImage; 00038 class SoCoordinate3; 00039 00040 namespace Gui 00041 { 00042 00043 class GuiExport ViewProviderAnnotation : public ViewProviderDocumentObject 00044 { 00045 PROPERTY_HEADER(Gui::ViewProviderAnnotation); 00046 00047 public: 00049 ViewProviderAnnotation(void); 00050 virtual ~ViewProviderAnnotation(); 00051 00052 // Display properties 00053 App::PropertyColor TextColor; 00054 App::PropertyEnumeration Justification; 00055 App::PropertyFloat FontSize; 00056 App::PropertyString FontName; 00057 App::PropertyFloat LineSpacing; 00058 App::PropertyAngle Rotation; 00059 App::PropertyEnumeration RotationAxis; 00060 00061 void attach(App::DocumentObject *); 00062 void updateData(const App::Property*); 00063 std::vector<std::string> getDisplayModes(void) const; 00064 void setDisplayMode(const char* ModeName); 00065 00066 protected: 00067 void onChanged(const App::Property* prop); 00068 00069 private: 00070 SoFont * pFont; 00071 SoText2 * pLabel; 00072 SoAsciiText * pLabel3d; 00073 SoBaseColor * pColor; 00074 SoTranslation * pTranslation; 00075 SoRotationXYZ * pRotationXYZ; 00076 00077 static const char* JustificationEnums[]; 00078 static const char* RotationAxisEnums[]; 00079 }; 00080 00087 class GuiExport ViewProviderAnnotationLabel : public ViewProviderDocumentObject 00088 { 00089 PROPERTY_HEADER(Gui::ViewProviderAnnotationLabel); 00090 00091 public: 00093 ViewProviderAnnotationLabel(void); 00094 virtual ~ViewProviderAnnotationLabel(); 00095 00096 // Display properties 00097 App::PropertyColor TextColor; 00098 App::PropertyColor BackgroundColor; 00099 App::PropertyEnumeration Justification; 00100 App::PropertyFloat FontSize; 00101 App::PropertyFont FontName; 00102 App::PropertyBool Frame; 00103 00104 void attach(App::DocumentObject *); 00105 void updateData(const App::Property*); 00106 std::vector<std::string> getDisplayModes(void) const; 00107 void setDisplayMode(const char* ModeName); 00108 00111 bool doubleClicked(void); 00112 void setupContextMenu(QMenu*, QObject*, const char*); 00113 protected: 00114 bool setEdit(int ModNum); 00115 void unsetEdit(int ModNum); 00117 00118 protected: 00119 void onChanged(const App::Property* prop); 00120 void drawImage(const std::vector<std::string>&); 00121 00122 private: 00123 static void dragStartCallback(void * data, SoDragger * d); 00124 static void dragFinishCallback(void * data, SoDragger * d); 00125 static void dragMotionCallback(void * data, SoDragger * d); 00126 00127 private: 00128 SoCoordinate3 * pCoords; 00129 SoImage * pImage; 00130 SoBaseColor * pColor; 00131 SoTranslation * pBaseTranslation; 00132 SoTransform * pTextTranslation; 00133 00134 static const char* JustificationEnums[]; 00135 }; 00136 00137 } //namespace Gui 00138 00139 00140 #endif // GUI_VIEWPROVIDERANNOTATION_H