QCAD
Open Source 2D CAD
RView.h
Go to the documentation of this file.
1 
20 #ifndef RVIEW_H
21 #define RVIEW_H
22 
23 #include "core_global.h"
24 
25 #include <QString>
26 #include <QColor>
27 #include <QDebug>
28 
29 #include "RGlobal.h"
30 #include "RObject.h"
31 #include "RBox.h"
32 
33 class RDocument;
34 
42 class QCADCORE_EXPORT RView: public RObject {
43 public:
48 
49 public:
50  RView();
51 
52  RView(RDocument* document, const QString& name, RVector centerPoint,
53  double width, double height);
54 
55  virtual ~RView();
56 
57  static void init();
58 
59  virtual RS::EntityType getType() const {
60  return RS::ObjectView;
61  }
62 
63  virtual RView* clone() const;
64 
65  QString getName() const {
66  return name;
67  }
68 
69  void setName(const QString& n) {
70  name = n;
71  }
72 
74  return centerPoint;
75  }
76 
77  void setCenterPoint(const RVector& cPoint) {
78  centerPoint = cPoint;
79  }
80 
81  double getWidth() const {
82  return width;
83  }
84 
85  void setWidth(double w) {
86  width = w;
87  }
88 
89  double getHeight() const {
90  return height;
91  }
92 
93  void setHeight(double h) {
94  height = h;
95  }
96 
98  return RBox(centerPoint - RVector(width, height) / 2, centerPoint
99  + RVector(width, height) / 2);
100  }
101 
102  void scale(double factor) {
103  centerPoint.scale(factor);
104  width*=factor;
105  height*=factor;
106  }
107 
108  virtual QPair<QVariant, RPropertyAttributes> getProperty(
109  RPropertyTypeId& propertyTypeId,
110  bool humanReadable = false, bool noAttributes = false, bool showOnRequest = false);
111  virtual bool setProperty(RPropertyTypeId propertyTypeId,
112  const QVariant& value, RTransaction* transaction=NULL);
113 
114 private:
115  QString name;
117  double width;
118  double height;
119 };
120 
121 QCADCORE_EXPORT QDebug operator<<(QDebug dbg, const RView& v);
122 
123 Q_DECLARE_METATYPE(QSharedPointer<RView>)
124 Q_DECLARE_METATYPE(QSharedPointer<RView>*)
127 
128 #endif
RObject::clone
virtual RObject * clone() const =0
RView::getCenterPoint
RVector getCenterPoint() const
Definition: RView.h:73
RBox.h
RS::ObjectView
@ ObjectView
Definition: RS.h:134
RView::getWidth
double getWidth() const
Definition: RView.h:81
RObject
Abstract base class for all objects.
Definition: RObject.h:61
RVector
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
RView::getName
QString getName() const
Definition: RView.h:65
RView::height
double height
Definition: RView.h:118
RS::EntityType
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:125
RObject::getProperty
virtual QPair< QVariant, RPropertyAttributes > getProperty(RPropertyTypeId &propertyTypeId, bool humanReadable=false, bool noAttributes=false, bool showOnRequest=false)
Definition: RObject.cpp:106
RView::setWidth
void setWidth(double w)
Definition: RView.h:85
RView::setName
void setName(const QString &n)
Definition: RView.h:69
RView::PropertyCenterPoint
static RPropertyTypeId PropertyCenterPoint
Definition: RView.h:45
RView::PropertyHeight
static RPropertyTypeId PropertyHeight
Definition: RView.h:47
RView::name
QString name
Definition: RView.h:115
RView::PropertyName
static RPropertyTypeId PropertyName
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RView.h:44
RObject::setProperty
virtual bool setProperty(RPropertyTypeId propertyTypeId, const QVariant &value, RTransaction *transaction=NULL)
Sets the given property to the given value.
Definition: RObject.cpp:151
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(RMath *)
RView::getBox
RBox getBox()
Definition: RView.h:97
RView::setHeight
void setHeight(double h)
Definition: RView.h:93
RView::getHeight
double getHeight() const
Definition: RView.h:89
RView
Represents a view in a drawing.
Definition: RView.h:42
RObject::init
static void init()
Definition: RObject.cpp:67
RPropertyTypeId
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RPropertyTypeId.h:59
core_global.h
RGlobal.h
RDocument
A graphics document contains and owns entities, layers, user coordinate systems, variables,...
Definition: RDocument.h:72
RView::setCenterPoint
void setCenterPoint(const RVector &cPoint)
Definition: RView.h:77
RView::getType
virtual RS::EntityType getType() const
Definition: RView.h:59
RObject.h
RView::PropertyWidth
static RPropertyTypeId PropertyWidth
Definition: RView.h:46
RTransaction
Transaction implementation.
Definition: RTransaction.h:74
RBox
Represents a box e.g.
Definition: RBox.h:43
RView::width
double width
Definition: RView.h:117
RView::centerPoint
RVector centerPoint
Definition: RView.h:116
operator<<
QCADCORE_EXPORT QDebug operator<<(QDebug dbg, const RView &v)
Stream operator for QDebug.
Definition: RView.cpp:84
RView::scale
void scale(double factor)
Definition: RView.h:102
QCADCORE_EXPORT
#define QCADCORE_EXPORT
Definition: core_global.h:10