diff --git a/glabels/CMakeLists.txt b/glabels/CMakeLists.txt index 5c9eb59..929902c 100644 --- a/glabels/CMakeLists.txt +++ b/glabels/CMakeLists.txt @@ -24,6 +24,7 @@ set (glabels_sources LabelModel.cpp LabelModelObject.cpp LabelModelBoxObject.cpp + LabelModelShapeObject.cpp LabelRegion.cpp MainWindow.cpp MergeField.cpp @@ -53,6 +54,7 @@ set (glabels_qobject_headers LabelModel.h LabelModelObject.h LabelModelBoxObject.h + LabelModelShapeObject.h NewLabelDialog.h MainWindow.h SimplePreview.h diff --git a/glabels/LabelModelBoxObject.cpp b/glabels/LabelModelBoxObject.cpp index 36a120d..de709e2 100644 --- a/glabels/LabelModelBoxObject.cpp +++ b/glabels/LabelModelBoxObject.cpp @@ -30,18 +30,8 @@ namespace glabels /// /// Constructor /// - LabelModelBoxObject::LabelModelBoxObject( QObject* parent ) : LabelModelObject(parent) + LabelModelBoxObject::LabelModelBoxObject( QObject* parent ) : LabelModelShapeObject(parent) { - mHandles << new HandleNorthWest( this ); - mHandles << new HandleNorth( this ); - mHandles << new HandleNorthEast( this ); - mHandles << new HandleEast( this ); - mHandles << new HandleSouthEast( this ); - mHandles << new HandleSouth( this ); - mHandles << new HandleSouthWest( this ); - mHandles << new HandleWest( this ); - - /* TODO: initialize default line and fill poperties. */ } @@ -50,104 +40,6 @@ namespace glabels /// LabelModelBoxObject::~LabelModelBoxObject() { - foreach( Handle* handle, mHandles ) - { - delete handle; - } - mHandles.clear(); - } - - - /// - /// Line Width Property Getter - /// - double LabelModelBoxObject::lineWidth( void ) const - { - return mLineWidth; - } - - - /// - /// Line Width Property Setter - /// - void LabelModelBoxObject::setLineWidth( double value ) - { - if ( mLineWidth != value ) - { - mLineWidth = value; - emit changed(); - } - } - - - /// - /// Line Color Node Property Getter - /// - ColorNode LabelModelBoxObject::lineColorNode( void ) const - { - return mLineColorNode; - } - - - /// - /// Line Color Node Property Setter - /// - void LabelModelBoxObject::setLineColorNode( const ColorNode& value ) - { - if ( mLineColorNode != value ) - { - mLineColorNode = value; - emit changed(); - } - } - - - /// - /// Fill Color Node Property Getter - /// - ColorNode LabelModelBoxObject::fillColorNode( void ) const - { - return mFillColorNode; - } - - - /// - /// Fill Color Node Property Setter - /// - void LabelModelBoxObject::setFillColorNode( const ColorNode& value ) - { - if ( mFillColorNode != value ) - { - mFillColorNode = value; - emit changed(); - } - } - - - /// - /// Can Fill Capability Implementation - /// - bool LabelModelBoxObject::canFill() - { - return true; - } - - - /// - /// Can Line Color Capability Implementation - /// - bool LabelModelBoxObject::canLineColor() - { - return true; - } - - - /// - /// Can Line Width Capability Implementation - /// - bool LabelModelBoxObject::canLineWidth() - { - return true; } diff --git a/glabels/LabelModelBoxObject.h b/glabels/LabelModelBoxObject.h index e4117f8..c96fceb 100644 --- a/glabels/LabelModelBoxObject.h +++ b/glabels/LabelModelBoxObject.h @@ -21,7 +21,8 @@ #ifndef glabels_LabelModelBoxObject_h #define glabels_LabelModelBoxObject_h -#include "LabelModelObject.h" + +#include "LabelModelShapeObject.h" namespace glabels @@ -30,7 +31,7 @@ namespace glabels /// /// Label Model Box Object /// - class LabelModelBoxObject : public LabelModelObject + class LabelModelBoxObject : public LabelModelShapeObject { Q_OBJECT @@ -42,40 +43,6 @@ namespace glabels virtual ~LabelModelBoxObject(); - /////////////////////////////////////////////////////////////// - // Property Implementations - /////////////////////////////////////////////////////////////// - public: - // - // Shape Property: lineWidth - // - virtual double lineWidth( void ) const; - virtual void setLineWidth( double value ); - - - // - // Shape Property: lineColorNode - // - virtual ColorNode lineColorNode( void ) const; - virtual void setLineColorNode( const ColorNode& value ); - - - // - // Shape Property: fillColorNode - // - virtual ColorNode fillColorNode( void ) const; - virtual void setFillColorNode( const ColorNode& value ); - - - /////////////////////////////////////////////////////////////// - // Capability Implementations - /////////////////////////////////////////////////////////////// - public: - virtual bool canFill(); - virtual bool canLineColor(); - virtual bool canLineWidth(); - - /////////////////////////////////////////////////////////////// // Drawing operations /////////////////////////////////////////////////////////////// @@ -83,15 +50,6 @@ namespace glabels virtual void drawShadow( QPainter* painter, bool inEditor, MergeRecord* record ) const; virtual void drawObject( QPainter* painter, bool inEditor, MergeRecord* record ) const; - - /////////////////////////////////////////////////////////////// - // Private Members - /////////////////////////////////////////////////////////////// - private: - double mLineWidth; - ColorNode mLineColorNode; - ColorNode mFillColorNode; - }; } diff --git a/glabels/LabelModelShapeObject.cpp b/glabels/LabelModelShapeObject.cpp new file mode 100644 index 0000000..b8c21a6 --- /dev/null +++ b/glabels/LabelModelShapeObject.cpp @@ -0,0 +1,154 @@ +/* LabelModelShapeObject.cpp + * + * Copyright (C) 2013 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels-qt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + +#include "LabelModelShapeObject.h" + +#include +#include + + +namespace glabels +{ + + /// + /// Constructor + /// + LabelModelShapeObject::LabelModelShapeObject( QObject* parent ) : LabelModelObject(parent) + { + mHandles << new HandleNorthWest( this ); + mHandles << new HandleNorth( this ); + mHandles << new HandleNorthEast( this ); + mHandles << new HandleEast( this ); + mHandles << new HandleSouthEast( this ); + mHandles << new HandleSouth( this ); + mHandles << new HandleSouthWest( this ); + mHandles << new HandleWest( this ); + + /* TODO: initialize default line and fill poperties. */ + } + + + /// + /// Destructor + /// + LabelModelShapeObject::~LabelModelShapeObject() + { + foreach( Handle* handle, mHandles ) + { + delete handle; + } + mHandles.clear(); + } + + + /// + /// Line Width Property Getter + /// + double LabelModelShapeObject::lineWidth( void ) const + { + return mLineWidth; + } + + + /// + /// Line Width Property Setter + /// + void LabelModelShapeObject::setLineWidth( double value ) + { + if ( mLineWidth != value ) + { + mLineWidth = value; + emit changed(); + } + } + + + /// + /// Line Color Node Property Getter + /// + ColorNode LabelModelShapeObject::lineColorNode( void ) const + { + return mLineColorNode; + } + + + /// + /// Line Color Node Property Setter + /// + void LabelModelShapeObject::setLineColorNode( const ColorNode& value ) + { + if ( mLineColorNode != value ) + { + mLineColorNode = value; + emit changed(); + } + } + + + /// + /// Fill Color Node Property Getter + /// + ColorNode LabelModelShapeObject::fillColorNode( void ) const + { + return mFillColorNode; + } + + + /// + /// Fill Color Node Property Setter + /// + void LabelModelShapeObject::setFillColorNode( const ColorNode& value ) + { + if ( mFillColorNode != value ) + { + mFillColorNode = value; + emit changed(); + } + } + + + /// + /// Can Fill Capability Implementation + /// + bool LabelModelShapeObject::canFill() + { + return true; + } + + + /// + /// Can Line Color Capability Implementation + /// + bool LabelModelShapeObject::canLineColor() + { + return true; + } + + + /// + /// Can Line Width Capability Implementation + /// + bool LabelModelShapeObject::canLineWidth() + { + return true; + } + + +} diff --git a/glabels/LabelModelShapeObject.h b/glabels/LabelModelShapeObject.h new file mode 100644 index 0000000..4b119e9 --- /dev/null +++ b/glabels/LabelModelShapeObject.h @@ -0,0 +1,92 @@ +/* LabelModelShapeObject.h + * + * Copyright (C) 2013 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels-qt is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels-qt. If not, see . + */ + +#ifndef glabels_LabelModelShapeObject_h +#define glabels_LabelModelShapeObject_h + +#include "LabelModelObject.h" + + +namespace glabels +{ + + /// + /// Label Model Shape Object (Box or Ellipse) + /// + class LabelModelShapeObject : public LabelModelObject + { + Q_OBJECT + + /////////////////////////////////////////////////////////////// + // Lifecycle Methods + /////////////////////////////////////////////////////////////// + protected: + LabelModelShapeObject( QObject* parent = 0 ); + public: + virtual ~LabelModelShapeObject(); + + + /////////////////////////////////////////////////////////////// + // Property Implementations + /////////////////////////////////////////////////////////////// + public: + // + // Shape Property: lineWidth + // + virtual double lineWidth( void ) const; + virtual void setLineWidth( double value ); + + + // + // Shape Property: lineColorNode + // + virtual ColorNode lineColorNode( void ) const; + virtual void setLineColorNode( const ColorNode& value ); + + + // + // Shape Property: fillColorNode + // + virtual ColorNode fillColorNode( void ) const; + virtual void setFillColorNode( const ColorNode& value ); + + + /////////////////////////////////////////////////////////////// + // Capability Implementations + /////////////////////////////////////////////////////////////// + public: + virtual bool canFill(); + virtual bool canLineColor(); + virtual bool canLineWidth(); + + + /////////////////////////////////////////////////////////////// + // Private Members + /////////////////////////////////////////////////////////////// + protected: + double mLineWidth; + ColorNode mLineColorNode; + ColorNode mFillColorNode; + + }; + +} + +#endif // glabels_LabelModelShapeObject_h