00001 /* -*- c++ -*- (for Emacs) 00002 * 00003 * abstractdiagramelement.h 00004 * Digest 00005 * 00006 * Created by Aidan Lane on Thu Jun 13 2005. 00007 * Copyright (c) 2005 Optimisation and Constraint Solving Group, 00008 * Monash University. All rights reserved. 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 */ 00024 00025 #ifndef ABSTRACTDIAGRAMELEMENT_H 00026 #define ABSTRACTDIAGRAMELEMENT_H 00027 00028 00029 #include "MvcCore/abstractelement.h" 00030 00031 #include <QPointF> 00032 #include <QSet> 00033 #include <QStringList> 00034 00035 #include "diagramelementevents.h" 00036 #include "mvcdiagram.h" // used by sub-classes to fetch element types 00037 00038 00044 class AbstractDiagramElement : public AbstractElement { 00045 00046 public: 00047 enum ControlPointEditFlag { 00048 NoEditingAllowed = 0x0, 00049 InsertionIsAllowed = 0x1, 00050 RemovalIsAllowed = 0x2, 00051 MovementIsAllowed = 0x4, 00052 }; 00053 Q_DECLARE_FLAGS( ControlPointEditFlags, ControlPointEditFlag ); // typesafe flags 00054 00055 static ControlPointEditFlags classControlPointEditFlags() { 00056 return NoEditingAllowed; 00057 } 00058 virtual ControlPointEditFlags controlPointEditFlags() const = 0; 00059 00065 const QList<QPointF>& controlPoints() const { return m_controlPoints; } 00066 00067 virtual const QSet<int>& requiredAttributes() const = 0; 00068 virtual const QSet<int>& additionalAttributes() const = 0; 00069 00070 00071 protected: 00072 AbstractDiagramElement( qint32 instanceId, ElementDoc* doc, 00073 const QList<QPointF>& controlPoints = QList<QPointF>() ); 00074 AbstractDiagramElement( ElementDoc* doc, 00075 const QList<QPointF>& controlPoints = QList<QPointF>() ); 00076 00077 void addRequiredAttributes(); 00078 00079 virtual void dispatchEvent( MEvent* ); 00080 00081 virtual void controlPointInsertEvent( MEControlPointInsertEvent* ); 00082 virtual void controlPointRemoveEvent( MEControlPointRemoveEvent* ); 00083 virtual void controlPointMoveEvent( MEControlPointMoveEvent* ); 00084 00085 virtual AbstractElementAttribute* createAttribute( int type ); 00086 virtual AbstractElementAttribute* createAttribute( const QByteArray& key ); 00087 virtual int attributeKeyToType( const QByteArray& key ); 00088 00089 // The following is intentionally NOT private in the name of efficiency and 00090 // simplification of implementation of sub-classes. 00091 QList<QPointF> m_controlPoints; 00092 }; 00093 00094 Q_DECLARE_OPERATORS_FOR_FLAGS( AbstractDiagramElement::ControlPointEditFlags ); 00095 00096 00097 #endif // ! ABSTRACTDIAGRAMELEMENT_H
1.5.2