Changeset 13537 for branches/OMEdit/OMEditGUI/ShapeAnnotation.h
- Timestamp:
- 2012-10-20T20:27:24+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OMEdit/OMEditGUI/ShapeAnnotation.h
r13405 r13537 83 83 }; 84 84 85 class ShapeAnnotation _OMC: public QObject, public QGraphicsItem, public GraphicItem, public FilledShape85 class ShapeAnnotation : public QObject, public QGraphicsItem, public GraphicItem, public FilledShape 86 86 { 87 87 Q_OBJECT 88 88 Q_INTERFACES(QGraphicsItem) 89 89 public: 90 ShapeAnnotation _OMC(QGraphicsItem *pParent);90 ShapeAnnotation(QGraphicsItem *pParent); 91 91 QPainterPath addPathStroker(QPainterPath &path) const; 92 92 QRectF getBoundingRect() const; … … 100 100 }; 101 101 102 // Base class for all shapes annotations103 class ShapeAnnotation : public QObject, public QGraphicsItem104 {105 Q_OBJECT106 Q_INTERFACES(QGraphicsItem)107 private:108 QAction *mpShapePropertiesAction;109 QAction *mpTextPropertiesAction;110 QAction *mpShapePenStyleAction;111 QAction *mpShapeBrushStyleAction;112 113 QAction *mpNoArrowAction;114 QAction *mpHalfArrowAction;115 QAction *mpOpenArrowAction;116 QAction *mpFilledArrowAction;117 QAction *mpNoEndArrowAction;118 QAction *mpHalfEndArrowAction;119 QAction *mpOpenEndArrowAction;120 QAction *mpFilledEndArrowAction;121 122 QSettings mSettings;123 public:124 ShapeAnnotation(QGraphicsItem *parent = 0);125 ShapeAnnotation(GraphicsView *pGraphicsView, QGraphicsItem *parent = 0);126 ~ShapeAnnotation();127 void initializeFields();128 void readSettings();129 void readPenStyleSettings();130 void readBrushStyleSettings();131 void createActions();132 void setSelectionBoxActive();133 void setSelectionBoxPassive();134 void setSelectionBoxHover();135 void changePenProperty();136 void changeBrushProperty();137 Transformation* getTransformation();138 void createResizerItems();139 void showResizerItems();140 void hideResizerItems();141 void setResizerItemsHover();142 void getResizerItemsPositions(qreal *x1, qreal *y1, qreal *x2, qreal *y2);143 void applyRotation(qreal angle);144 //void changeColour();145 virtual QString getShapeAnnotation();146 QRectF getBoundingRect() const;147 QPainterPath addPathStroker(QPainterPath &path) const;148 ShapeProperties *mpShapeProperties;149 GraphicsView *mpGraphicsView;150 signals:151 void updateShapeAnnotation();152 public slots:153 void deleteMe();154 void doSelect();155 void doUnSelect();156 void moveUp();157 void moveDown();158 void moveLeft();159 void moveRight();160 void rotateClockwise();161 void rotateAntiClockwise();162 void resetRotation();163 void flipHorizontal();164 void flipVertical();165 //void copyComponent();166 //void pasteComponent();167 QColor getLineColor();168 Qt::PenStyle getLinePattern();169 double getLineThickness();170 double getRectCornerRadius();171 bool getLineSmooth();172 QColor getFillColor();173 Qt::BrushStyle getFillPattern();174 void noArrowLine();175 void halfArrowLine();176 void openArrowLine();177 void filledArrowLine();178 void noEndArrowLine();179 void halfEndArrowLine();180 void openEndArrowLine();181 void filledEndArrowLine();182 183 void openShapeProperties();184 void openTextProperties();185 //void openPenStyleProperties();186 //void openBrushStyleProperties();187 void prepareResizeShape(ResizerItem *pResizerItem);188 void resizeShape(int index, QPointF newPosition);189 void finishResizeShape();190 void updateShapePosition();191 protected:192 bool mVisible;193 QPointF mOrigin;194 qreal mRotation;195 QColor mLineColor;196 QColor mFillColor;197 QMap<QString, Qt::PenStyle> mLinePatternsMap;198 Qt::PenStyle mLinePattern;199 QMap<QString, Qt::BrushStyle> mFillPatternsMap;200 Qt::BrushStyle mFillPattern;201 qreal mThickness;202 QMap<QString, Qt::BrushStyle> mBorderPatternsMap;203 Qt::BrushStyle mBorderPattern;204 QVector<QPointF> mPoints;205 QList<QPointF> mExtent;206 qreal mCornerRadius;207 bool mSmooth;208 enum ArrowType {None, Open, Filled, Half};209 QMap<QString, ArrowType> mArrowsMap;210 int mStartArrow;211 int mEndArrow;212 qreal mArrowSize;213 Transformation *mpTransformation;214 QGraphicsRectItem *mpResizerRectangle;215 ResizerItem *mpBottomLeftResizerItem;216 ResizerItem *mpTopLeftResizerItem;217 ResizerItem *mpTopRightResizerItem;218 ResizerItem *mpBottomRightResizerItem;219 ResizerItem *mpSelectedResizerItem;220 QPointF mTransformationStartPosition;221 QPointF mPivotPoint;222 qreal mXFactor;223 qreal mYFactor;224 225 QList<RectangleCornerItem*> mRectangleCornerItemsList;226 bool mIsCustomShape;227 bool mIsFinishedCreatingShape;228 bool mIsRectangleCorneItemClicked;229 bool mIsItemClicked;230 QPointF mClickPos;231 232 virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);233 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);234 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);235 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);236 virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);237 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);238 };239 240 class ShapeProperties : public QDialog241 {242 Q_OBJECT243 private:244 // Heading controls245 Label *mpHeadingLabel;246 QFrame *mpHorizontalLine;247 // Pen style controls248 QGroupBox *mpPenStyleGroup;249 Label *mpPenColorLabel;250 Label *mpPenColorViewerLabel;251 QPushButton *mpPenColorPickButton;252 QColor mPenColor;253 Qt::PenStyle mPenPattern;254 double mPenThickness;255 double mRectCornerRadius;256 bool mPenSmooth;257 Label *mpSmoothLabel;258 QCheckBox *mpPenNoColorCheckBox;259 Label *mpPenPatternLabel;260 QComboBox *mpPenPatternsComboBox;261 Label *mpPenThicknessLabel;262 QDoubleSpinBox *mpPenThicknessSpinBox;263 Label *mpCornerRadiusLabel;264 QDoubleSpinBox *mpCornerRadiusSpinBox;265 QCheckBox *mpSmoothCheckBox;266 // Brush style controls267 QGroupBox *mpBrushStyleGroup;268 Label *mpBrushColorLabel;269 Label *mpBrushColorViewerLabel;270 QPushButton *mpBrushColorPickButton;271 QColor mBrushColor;272 Qt::BrushStyle mBrushPattern;273 QCheckBox *mpBrushNoColorCheckBox;274 Label *mpBrushPatternLabel;275 QComboBox *mpBrushPatternsComboBox;276 QPushButton *mpCancelButton;277 QPushButton *mpOkButton;278 QDialogButtonBox *mpButtonBox;279 signals:280 void colourChanged();281 public:282 ShapeProperties(ShapeAnnotation *pShape, MainWindow *pParent);283 void setShapeType();284 void setUpDialog();285 void setUpLineDialog();286 void setInitPenColor(QColor color);287 void setInitPenPattern(Qt::PenStyle pattern);288 void setInitPenThickness(double thickness);289 void setInitCornerRadius(double radius);290 void setInitPenSmooth(bool smooth);291 QColor getPenColor();292 void setPenPattern();293 QString getPenPatternString();294 Qt::PenStyle getPenPattern();295 void setPenThickness();296 double getPenThickness();297 void setCornerRadius();298 double getCornerRadius();299 void setPenSmooth();300 bool getPenSmooth();301 void setInitBrushColor(QColor color);302 void setInitBrushPattern(Qt::BrushStyle pattern);303 QColor getBrushColor();304 void setBrushPattern();305 QString getBrushPatternString();306 Qt::BrushStyle getBrushPattern();307 QVBoxLayout* createHorizontalLine();308 QVBoxLayout* createPenControls();309 QVBoxLayout* createBrushControls();310 311 MainWindow *mpMainWindow;312 ShapeAnnotation *mpShape;313 enum ShapeType {Line, Polygon, Rectangle, Ellipse, Text, Bitmap};314 int mShapeType;315 public slots:316 void pickPenColor();317 void penNoColorChecked(int state);318 void pickBrushColor();319 320 void brushNoColorChecked(int state);321 void applyChanges();322 323 };324 325 102 #endif // SHAPEANNOTATION_H
Note: See TracChangeset
for help on using the changeset viewer.