MarkupPartLabels.h
1 //##################################################################################################
2 //
3 // Ceetron Desktop Components
4 // Component: Visualization
5 //
6 // --------------------------------------------------------------------------------------------
7 // Copyright (C) 2014, Ceetron AS
8 // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Ceetron AS. The contents of this file may
9 // not be disclosed to third parties, copied or duplicated in any form, in whole or in part,
10 // without the prior written permission of Ceetron AS.
11 //##################################################################################################
12 
13 #pragma once
14 
15 #include "CeeVisualization/Base.h"
16 #include "CeeCore/RefCountedObject.h"
17 #include "CeeVisualization/MarkupPart.h"
18 #include "CeeCore/Color3f.h"
19 #include "CeeCore/Str.h"
20 #include "CeeCore/Vec3d.h"
21 #include "CeeCore/PtrRef.h"
22 
23 namespace cee {
24 class BoundingBox;
25 
26 namespace vis {
27 class Font;
28 
29 //==================================================================================================
30 //
31 //
32 //
33 //==================================================================================================
34 class CEE_VIS_EXPORT MarkupPartLabels : public MarkupPart
35 {
36 public:
39  {
42  DRAW_WITHOUT_ZBUFFER_TEST
43  };
44 
47  {
50  VERTICAL_DOWN
51  };
52 
55  {
56  LEFT,
58  RIGHT
59  };
60 
61 
62 public:
64  MarkupPartLabels(LabelDrawMode labelDrawMode, const Color3f& textColor, const Color3f& borderColor, const Color3f& backgroundColor);
65  MarkupPartLabels(LabelDrawMode labelDrawMode, const Color3f& textColor, const Color3f& borderColor, const Color3f& backgroundColor, const Color3f& markerColor);
66  virtual ~MarkupPartLabels();
67 
68  virtual PartType type() const;
69  virtual BoundingBox boundingBox() const;
70 
71  virtual void setPriority(int priority);
72  virtual int priority() const;
73 
74  virtual const Mat4d& transformation() const;
75  virtual void setTransformation(const Mat4d& matrix);
76 
77  void setAbsoluteOffset(int x, int y);
78  int absoluteOffsetX() const;
79  int absoluteOffsetY() const;
80 
81  void setRelativeOffset(double x, double y);
82  double relativeOffsetX() const;
83  double relativeOffsetY() const;
84 
85  LabelDrawMode drawMode() const;
86  void setDrawMode(LabelDrawMode mode);
87 
88  Orientation orientation() const;
89  void setOrientation(Orientation direction);
90 
91  HorizontalTextAlignment horizontalTextAlignment() const;
92  void setHorizontalTextAlignment(HorizontalTextAlignment alignment);
93 
94  unsigned int maximumNumberOfLabelsToDraw() const;
95  void setMaximumNumberOfLabelsToDraw(unsigned int maximumNumberToDraw);
96 
97  float eyeLiftFactor() const;
98  void setEyeLiftFactor(float factor);
99 
100  const Font* font() const;
101  void setFont(Font* labelFont);
102 
103  const Color3f& textColor() const;
104  void setTextColor(const Color3f& color);
105 
106  const Color3f& backgroundColor() const;
107  void setBackgroundColor(const Color3f& color);
108 
109  const Color3f& borderColor() const;
110  void setBorderColor(const Color3f& color);
111 
112  const Color3f& markerColor() const;
113  void setMarkerColor(const Color3f& color);
114 
115  float borderWidth() const;
116  void setBorderWidth(float width);
117 
118  float markerPointSize() const;
119  void setMarkerPointSize(float pointSize);
120 
121  bool drawBackground() const;
122  void setDrawBackground(bool drawBackground);
123 
124  bool drawBorder() const;
125  void setDrawBorder(bool drawBorder);
126 
127  bool drawMarker() const;
128  void setDrawMarker(bool drawMarker);
129 
130  bool offsetLabelToFitInView() const;
131  void setOffsetLabelToFitInView(bool offsetLabel);
132 
133  size_t count() const;
134  const cee::Str& text(size_t index) const;
135  const cee::Vec3d& position(size_t index) const;
136  unsigned int width(size_t index);
137  unsigned int height(size_t index);
138  size_t add(const Vec3d& position, const Str& text);
139  void set(size_t index, const Vec3d& position, const Str& text);
140  void remove(size_t index);
141  void removeAll();
142 
143  static PtrRef<MarkupPartLabels> create(const Vec3d& position, const Str& text, LabelDrawMode drawMode = DRAW_WITHOUT_ZBUFFER_TEST);
144  static PtrRef<MarkupPartLabels> createWithMarker(const Vec3d& position, const Str& text, const Color3f& markerColor, LabelDrawMode drawMode = DRAW_WITHOUT_ZBUFFER_TEST);
145 
146 protected:
147  virtual bool internal_preRenderUpdatePart(bool forceUpdate, cvf::OpenGLContext* cvfContext, MarkupClippingData* clippingData);
148  virtual cvf::Part* internal_cvfPart();
149  virtual cvf::Part* internal_cvfOverlayPart();
150  virtual cvf::Part* internal_cvfOverlayDetectVisiblePart();
151 
152 private:
153  CEE_PRIVATE_F(MarkupModel);
154  CEE_PRIVATE_IMPL(MarkupPartLabels);
155  CEE_DISALLOW_COPY_AND_ASSIGN(MarkupPartLabels);
156 };
157 
158 } // namespace vis
159 } // namespace cee
Namespace cee contains all functionality and structures under the Core component. ...
Definition: AppComponent.cpp:26
A general unicode based string class.
Definition: Str.h:28
Model used for drawing labels, arrows, lines, points, triangles and glyphs.
Definition: MarkupModel.h:31
Smart pointer class used for handling reference counted objects (that derive from Object)...
Definition: PtrRef.h:26
PartType
Enum specifying the type of MarkupPart.
Definition: MarkupPart.h:39
Vertical direction, upward text.
Definition: MarkupPartLabels.h:49
Base class for MarkupModel Parts.
Definition: MarkupPart.h:35
Axis-aligned bounding box.
Definition: BoundingBox.h:27
LabelDrawMode
Enum specifying the way to draw the labels. Controls the visibility of the label. ...
Definition: MarkupPartLabels.h:38
Class for storing an RGB color triplet.
Definition: Color3f.h:25
Align center.
Definition: MarkupPartLabels.h:57
Horizontal text direction.
Definition: MarkupPartLabels.h:48
Draw the label as geometry with z buffer test.
Definition: MarkupPartLabels.h:41
Orientation
Enum specifying the direction to draw the labels.
Definition: MarkupPartLabels.h:46
HorizontalTextAlignment
Horizontal alignment of the text when drawing multiple lines.
Definition: MarkupPartLabels.h:54
Vector class for a 3D double vector.
Definition: Vec3d.h:26
Label is visible if the position of the label (position provided in the add()) is visible...
Definition: MarkupPartLabels.h:40
A font used for text drawing.
Definition: Font.h:30
Align left.
Definition: MarkupPartLabels.h:56
4 dimensional matrix.
Definition: Mat4d.h:26
A MarkupModel part for drawing labels.
Definition: MarkupPartLabels.h:34