00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "KDChartRingPainter.h"
00030 #include "KDChartParams.h"
00031
00032 #include <qpainter.h>
00033 #include <qvaluestack.h>
00034
00035 #include <stdlib.h>
00036
00043 void KDChartPropertySet::deepCopy( const KDChartPropertySet* source )
00044 {
00045 if( !source || this == source )
00046 return;
00047 mOwnID = source->mOwnID;
00048 mName = source->mName;
00049 mIdShowBar = source->mIdShowBar; mShowBar = source->mShowBar;
00050 mIdBarColor = source->mIdBarColor; mBarColor = source->mBarColor;
00051 mIdAreaBrush = source->mIdAreaBrush; mAreaBrush = source->mAreaBrush;
00052 mIdLineWidth = source->mIdLineWidth; mLineWidth = source->mLineWidth;
00053 mIdLineColor = source->mIdLineColor; mLineColor = source->mLineColor;
00054 mIdLineStyle = source->mIdLineStyle; mLineStyle = source->mLineStyle;
00055 mIdShowMarker = source->mIdShowMarker; mShowMarker = source->mShowMarker;
00056 mIdMarkerSize = source->mIdMarkerSize; mMarkerSize = source->mMarkerSize;
00057 mIdMarkerColor = source->mIdMarkerColor; mMarkerColor = source->mMarkerColor;
00058 mIdMarkerStyle = source->mIdMarkerStyle; mMarkerStyle = source->mMarkerStyle;
00059 mIdMarkerAlign = source->mIdMarkerAlign; mMarkerAlign = source->mMarkerAlign;
00060 mIdExtraLinesAlign = source->mIdExtraLinesAlign; mExtraLinesAlign = source->mExtraLinesAlign;
00061 mIdExtraLinesInFront = source->mIdExtraLinesInFront; mExtraLinesInFront = source->mExtraLinesInFront;
00062 mIdExtraLinesLength = source->mIdExtraLinesLength; mExtraLinesLength = source->mExtraLinesLength;
00063 mIdExtraLinesWidth = source->mIdExtraLinesWidth; mExtraLinesWidth = source->mExtraLinesWidth;
00064 mIdExtraLinesColor = source->mIdExtraLinesColor; mExtraLinesColor = source->mExtraLinesColor;
00065 mIdExtraLinesStyle = source->mIdExtraLinesStyle; mExtraLinesStyle = source->mExtraLinesStyle;
00066 mIdExtraMarkersAlign = source->mIdExtraMarkersAlign; mExtraMarkersAlign = source->mExtraMarkersAlign;
00067 mIdExtraMarkersSize = source->mIdExtraMarkersSize; mExtraMarkersSize = source->mExtraMarkersSize;
00068 mIdExtraMarkersColor = source->mIdExtraMarkersColor; mExtraMarkersColor = source->mExtraMarkersColor;
00069 mIdExtraMarkersStyle = source->mIdExtraMarkersStyle; mExtraMarkersStyle = source->mExtraMarkersStyle;
00070 }
00071
00072 const KDChartPropertySet* KDChartPropertySet::clone() const
00073 {
00074 KDChartPropertySet* newSet = new KDChartPropertySet();
00075 newSet->deepCopy( this );
00076 return newSet;
00077 }
00078
00079 void KDChartPropertySet::quickReset( const QString& name, int idParent )
00080 {
00081
00082 mName = name;
00083
00084 mOwnID = idParent;
00085 mIdLineWidth = idParent;
00086 mIdLineColor = idParent;
00087 mIdLineStyle = idParent;
00088 mIdShowMarker = idParent;
00089 mIdMarkerSize = idParent;
00090 mIdMarkerColor = idParent;
00091 mIdMarkerStyle = idParent;
00092 mIdMarkerAlign = idParent;
00093 mIdExtraLinesAlign = idParent;
00094 mIdExtraLinesInFront = idParent;
00095 mIdExtraLinesLength = idParent;
00096 mIdExtraLinesWidth = idParent;
00097 mIdExtraLinesColor = idParent;
00098 mIdExtraLinesStyle = idParent;
00099 mIdExtraMarkersAlign = idParent;
00100 mIdExtraMarkersSize = idParent;
00101 mIdExtraMarkersColor = idParent;
00102 mIdExtraMarkersStyle = idParent;
00103 mIdShowBar = idParent;
00104 mIdBarColor = idParent;
00105 mIdAreaBrush = idParent;
00106 }
00107
00108 void KDChartPropertySet::fullReset( const QString& name, int idParent )
00109 {
00110 quickReset( name, idParent );
00111 fillValueMembersWithDummyValues();
00112 }
00113
00114 void KDChartPropertySet::fillValueMembersWithDummyValues()
00115 {
00116
00117 mLineWidth = 1;
00118 mLineColor = Qt::black;
00119 mLineStyle = Qt::SolidLine;
00120 mShowMarker = true;
00121 mMarkerAlign = Qt::AlignCenter;
00122 mMarkerSize = QSize(6,6);
00123 mMarkerColor = Qt::black;
00124 mMarkerStyle = 0;
00125 mExtraLinesAlign = Qt::AlignLeft|Qt::AlignTop;
00126 mExtraLinesInFront = false;
00127 mExtraLinesLength = -20;
00128 mExtraLinesWidth = 1;
00129 mExtraLinesColor = Qt::black;
00130 mExtraLinesStyle = Qt::SolidLine;
00131 mExtraMarkersAlign = Qt::AlignLeft|Qt::AlignTop;
00132 mExtraMarkersSize = QSize(6,6);
00133 mExtraMarkersColor = Qt::black;
00134 mExtraMarkersStyle = 0;
00135 mShowBar = true;
00136 mBarColor = Qt::black;
00137 mAreaBrush = QBrush( Qt::blue );
00138 }
00139
00140
00141 QDomElement KDChartPropertySet::saveXML(QDomDocument& doc) const
00142 {
00143 QDomElement propertySetElement = doc.createElement( "PropertySet" );
00144 propertySetElement.setAttribute( "OwnID", mOwnID );
00145 KDXML::createStringNode( doc, propertySetElement, "Name", mName );
00146
00147 KDXML::createIntNode( doc, propertySetElement, "IDShowBar", mIdShowBar );
00148 KDXML::createBoolNode( doc, propertySetElement, "ShowBar", mShowBar );
00149 KDXML::createIntNode( doc, propertySetElement, "IDBarColor", mIdBarColor );
00150 KDXML::createColorNode( doc, propertySetElement, "BarColor", mBarColor );
00151
00152 KDXML::createIntNode( doc, propertySetElement, "IDAreaBrush", mIdAreaBrush );
00153 KDXML::createBrushNode( doc, propertySetElement, "AreaBrush", mAreaBrush );
00154
00155 KDXML::createIntNode( doc, propertySetElement, "IDLineWidth", mIdLineWidth );
00156 KDXML::createIntNode( doc, propertySetElement, "LineWidth", mLineWidth );
00157 KDXML::createIntNode( doc, propertySetElement, "IDLineColor", mIdLineColor );
00158 KDXML::createColorNode( doc, propertySetElement, "LineColor", mLineColor );
00159 KDXML::createIntNode( doc, propertySetElement, "IDLineStyle", mIdLineStyle );
00160 QDomElement lineStyleElement = doc.createElement( "LineStyle" );
00161 propertySetElement.appendChild( lineStyleElement );
00162 lineStyleElement.setAttribute( "Style", KDXML::penStyleToString( mLineStyle));
00163
00164 KDXML::createIntNode( doc, propertySetElement, "IDShowMarker", mIdShowMarker);
00165 KDXML::createBoolNode( doc, propertySetElement, "ShowMarker", mShowMarker);
00166 KDXML::createIntNode( doc, propertySetElement, "IDMarkerAlign", mIdMarkerAlign );
00167 KDXML::createIntNode( doc, propertySetElement, "MarkerAlign", mMarkerAlign );
00168 KDXML::createIntNode( doc, propertySetElement, "IDMarkerSize", mIdMarkerSize );
00169 KDXML::createSizeNode( doc, propertySetElement, "MarkerSize", mMarkerSize );
00170 KDXML::createIntNode( doc, propertySetElement, "IDMarkerColor", mIdMarkerColor );
00171 KDXML::createColorNode( doc, propertySetElement, "MarkerColor", mMarkerColor );
00172 KDXML::createIntNode( doc, propertySetElement, "IDMarkerStyle", mIdMarkerStyle );
00173 QDomElement markerStElem = doc.createElement( "MarkerStyle" );
00174 propertySetElement.appendChild( markerStElem );
00175 markerStElem.setAttribute("Style",
00176 KDChartParams::lineMarkerStyleToString( (KDChartParams::LineMarkerStyle)mMarkerStyle));
00177
00178 KDXML::createIntNode( doc, propertySetElement, "IDExtraLinesAlign", mIdExtraLinesAlign );
00179 KDXML::createIntNode( doc, propertySetElement, "ExtraLinesAlign", mExtraLinesAlign );
00180 KDXML::createIntNode( doc, propertySetElement, "IDExtraLinesInFront",mIdExtraLinesInFront );
00181 KDXML::createBoolNode( doc, propertySetElement, "ExtraLinesInFront", mExtraLinesInFront );
00182 KDXML::createIntNode( doc, propertySetElement, "IDExtraLinesLength", mIdExtraLinesLength );
00183 KDXML::createIntNode( doc, propertySetElement, "ExtraLinesLength", mExtraLinesLength );
00184 KDXML::createIntNode( doc, propertySetElement, "IDExtraLinesWidth", mIdExtraLinesWidth );
00185 KDXML::createIntNode( doc, propertySetElement, "ExtraLinesWidth", mExtraLinesWidth );
00186 KDXML::createIntNode( doc, propertySetElement, "IDExtraLinesColor", mIdExtraLinesColor );
00187 KDXML::createColorNode( doc, propertySetElement, "ExtraLinesColor", mExtraLinesColor );
00188 KDXML::createIntNode( doc, propertySetElement, "IDExtraLinesStyle", mIdExtraLinesStyle );
00189 QDomElement specLineStElem = doc.createElement( "ExtraLinesStyle" );
00190 propertySetElement.appendChild( specLineStElem );
00191 specLineStElem.setAttribute( "Style", KDXML::penStyleToString( mExtraLinesStyle));
00192
00193 KDXML::createIntNode( doc, propertySetElement, "IDExtraMarkersAlign", mIdExtraMarkersAlign );
00194 KDXML::createIntNode( doc, propertySetElement, "ExtraMarkersAlign", mExtraMarkersAlign );
00195 KDXML::createIntNode( doc, propertySetElement, "IDExtraMarkersSize", mIdExtraMarkersSize );
00196 KDXML::createSizeNode( doc, propertySetElement, "ExtraMarkersSize", mExtraMarkersSize );
00197 KDXML::createIntNode( doc, propertySetElement, "IDExtraMarkersColor", mIdExtraMarkersColor );
00198 KDXML::createColorNode( doc, propertySetElement, "ExtraMarkersColor", mExtraMarkersColor );
00199 KDXML::createIntNode( doc, propertySetElement, "IDExtraMarkersStyle", mIdExtraMarkersStyle );
00200 QDomElement specMarkerStElem = doc.createElement( "ExtraMarkersStyle" );
00201 propertySetElement.appendChild( specMarkerStElem );
00202 specMarkerStElem.setAttribute("Style",
00203 KDChartParams::lineMarkerStyleToString( (KDChartParams::LineMarkerStyle)mExtraMarkersStyle));
00204 return propertySetElement;
00205 }
00206
00207 bool KDChartPropertySet::loadXML( const QDomElement& element, KDChartPropertySet& set )
00208 {
00209 bool bOwnIDFound = false;
00210 QString s;
00211 QColor color;
00212 QBrush brush;
00213 QSize size;
00214 bool bValue;
00215 int i;
00216
00217 set.fillValueMembersWithDummyValues();
00218
00219 if( element.hasAttribute("OwnID") ){
00220 i = element.attribute( "OwnID" ).toInt( &bOwnIDFound );
00221 if( bOwnIDFound ){
00222 set.mOwnID = i;
00223 QDomNode node = element.firstChild();
00224 while( !node.isNull() ) {
00225 QDomElement element = node.toElement();
00226 if( !element.isNull() ) {
00227 QString tagName = element.tagName();
00228 if( tagName == "Name" ) {
00229 if( KDXML::readStringNode( element, s ) )
00230 set.mName = s;
00231 } else
00232
00233 if( tagName == "IDShowBar" ) {
00234 if( KDXML::readIntNode( element, i ) )
00235 set.mIdShowBar = i;
00236 } else if( tagName == "ShowBar" ) {
00237 if( KDXML::readBoolNode( element, bValue ) )
00238 set.mShowBar = bValue;
00239 } else if( tagName == "IDBarColor" ) {
00240 if( KDXML::readIntNode( element, i ) )
00241 set.mIdBarColor = i;
00242 } else if( tagName == "BarColor" ) {
00243 if( KDXML::readColorNode( element, color ) )
00244 set.mBarColor = color;
00245 } else
00246
00247 if( tagName == "IDAreaBrush" ) {
00248 if( KDXML::readIntNode( element, i ) )
00249 set.mIdAreaBrush = i;
00250 } else if( tagName == "AreaBrush" ) {
00251 if( KDXML::readBrushNode( element, brush ) )
00252 set.mAreaBrush = color;
00253 } else
00254
00255 if( tagName == "IDLineWidth" ) {
00256 if( KDXML::readIntNode( element, i ) )
00257 set.mIdLineWidth = i;
00258 } else if( tagName == "LineWidth" ) {
00259 if( KDXML::readIntNode( element, i ) )
00260 set.mLineWidth = i;
00261 } else if( tagName == "IDLineColor" ) {
00262 if( KDXML::readIntNode( element, i ) )
00263 set.mIdLineColor = i;
00264 } else if( tagName == "LineColor" ) {
00265 if( KDXML::readColorNode( element, color ) )
00266 set.mLineColor = color;
00267 } else if( tagName == "IDLineStyle" ) {
00268 if( KDXML::readIntNode( element, i ) )
00269 set.mIdLineStyle = i;
00270 } else if( tagName == "LineStyle" ) {
00271 if( element.hasAttribute( "Style" ) )
00272 set.mLineStyle = KDXML::stringToPenStyle( element.attribute( "Style" ) );
00273 } else
00274
00275 if( tagName == "IDShowMarker" ) {
00276 if( KDXML::readIntNode( element, i ) )
00277 set.mIdShowMarker = i;
00278 } else if( tagName == "ShowMarker" ) {
00279 if( KDXML::readBoolNode( element, bValue ) )
00280 set.mShowMarker = bValue;
00281 } else if( tagName == "IDMarkerAlign" ) {
00282 if( KDXML::readIntNode( element, i ) )
00283 set.mIdMarkerAlign = i;
00284 } else if( tagName == "MarkerAlign" ) {
00285 if( KDXML::readIntNode( element, i ) )
00286 set.mMarkerAlign = i;
00287 } else if( tagName == "IDMarkerSize" ) {
00288 if( KDXML::readIntNode( element, i ) )
00289 set.mIdMarkerSize = i;
00290 } else if( tagName == "MarkerSize" ) {
00291 if( KDXML::readSizeNode( element, size ) )
00292 set.mMarkerSize = size;
00293 } else if( tagName == "IDMarkerColor" ) {
00294 if( KDXML::readIntNode( element, i ) )
00295 set.mIdMarkerColor = i;
00296 } else if( tagName == "MarkerColor" ) {
00297 if( KDXML::readColorNode( element, color ) )
00298 set.mMarkerColor = color;
00299 } else if( tagName == "IDMarkerStyle" ) {
00300 if( KDXML::readIntNode( element, i ) )
00301 set.mIdMarkerStyle = i;
00302 } else if( tagName == "MarkerStyle" ) {
00303 if( element.hasAttribute( "Style" ) )
00304 set.mMarkerStyle
00305 = KDChartParams::stringToLineMarkerStyle( element.attribute( "Style" ) );
00306 } else
00307
00308 if( tagName == "IDExtraLinesAlign" ) {
00309 if( KDXML::readIntNode( element, i ) )
00310 set.mIdExtraLinesAlign = i;
00311 } else if( tagName == "ExtraLinesAlign" ) {
00312 if( KDXML::readIntNode( element, i ) )
00313 set.mExtraLinesAlign = i;
00314 } else if( tagName == "IDExtraLinesInFront" ) {
00315 if( KDXML::readIntNode( element, i ) )
00316 set.mIdExtraLinesInFront = i;
00317 } else if( tagName == "ExtraLinesInFront" ) {
00318 if( KDXML::readBoolNode( element, bValue ) )
00319 set.mExtraLinesInFront = bValue;
00320 } else if( tagName == "IDExtraLinesLength" ) {
00321 if( KDXML::readIntNode( element, i ) )
00322 set.mIdExtraLinesLength = i;
00323 } else if( tagName == "ExtraLinesLength" ) {
00324 if( KDXML::readIntNode( element, i ) )
00325 set.mExtraLinesLength = i;
00326 } else if( tagName == "IDExtraLinesWidth" ) {
00327 if( KDXML::readIntNode( element, i ) )
00328 set.mIdExtraLinesWidth = i;
00329 } else if( tagName == "ExtraLinesWidth" ) {
00330 if( KDXML::readIntNode( element, i ) )
00331 set.mExtraLinesWidth = i;
00332 } else if( tagName == "IDExtraLinesColor" ) {
00333 if( KDXML::readIntNode( element, i ) )
00334 set.mIdExtraLinesColor = i;
00335 } else if( tagName == "ExtraLinesColor" ) {
00336 if( KDXML::readColorNode( element, color ) )
00337 set.mExtraLinesColor = color;
00338 } else if( tagName == "IDExtraLinesStyle" ) {
00339 if( KDXML::readIntNode( element, i ) )
00340 set.mIdExtraLinesStyle = i;
00341 } else if( tagName == "ExtraLinesStyle" ) {
00342 if( element.hasAttribute( "Style" ) )
00343 set.mExtraLinesStyle = KDXML::stringToPenStyle( element.attribute( "Style" ) );
00344 } else
00345
00346 if( tagName == "IDExtraMarkersAlign" ) {
00347 if( KDXML::readIntNode( element, i ) )
00348 set.mIdExtraMarkersAlign = i;
00349 } else if( tagName == "ExtraMarkersAlign" ) {
00350 if( KDXML::readIntNode( element, i ) )
00351 set.mExtraMarkersAlign = i;
00352 } else if( tagName == "IDExtraMarkersSize" ) {
00353 if( KDXML::readIntNode( element, i ) )
00354 set.mIdExtraMarkersSize = i;
00355 } else if( tagName == "ExtraMarkersSize" ) {
00356 if( KDXML::readSizeNode( element, size ) )
00357 set.mExtraMarkersSize = size;
00358 } else if( tagName == "IDExtraMarkersColor" ) {
00359 if( KDXML::readIntNode( element, i ) )
00360 set.mIdExtraMarkersColor = i;
00361 } else if( tagName == "ExtraMarkersColor" ) {
00362 if( KDXML::readColorNode( element, color ) )
00363 set.mExtraMarkersColor = color;
00364 } else if( tagName == "IDExtraMarkersStyle" ) {
00365 if( KDXML::readIntNode( element, i ) )
00366 set.mIdExtraMarkersStyle = i;
00367 } else if( tagName == "ExtraMarkersStyle" ) {
00368 if( element.hasAttribute( "Style" ) )
00369 set.mExtraMarkersStyle
00370 = KDChartParams::stringToLineMarkerStyle( element.attribute( "Style" ) );
00371 } else {
00372 qDebug( "Unknown subelement of KDChartPropertySet found: %s", tagName.latin1() );
00373 }
00374 }
00375 node = node.nextSibling();
00376 }
00377 }
00378 }
00379 return bOwnIDFound;
00380 }
00381
00382 #include "KDChartPropertySet.moc"