/*************************************************************************** qgraphicaldata.h ------------------- version : 0.2 begin : 01-January-2001 copyright : (C) 2000 by Kamil Dobkowski email : kamildobk@poczta.onet.pl ***************************************************************************/ /*************************************************************************** * * * This program 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 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef QSGRAPHICALDATA_H #define QSGRAPHICALDATA_H #ifdef HAVE_CONFIG_H #include #endif #include"qsdata.h" #define SET_PROPERTY( property, new_value ) if ((property)!=(new_value)) { parametersChanging(); (property)=(new_value); parametersChanged(); } /** * \brief Data object which holds a set of graphics attributes such as fonts, fills, line styles etc. * * See new functions : setFill(), setFont(), setLine(), setPoint(). * Contains also implementation of the QSData interface. * @author Kamil Dobkowski */ class QSGraphicalData : public QSData { Q_OBJECT Q_PROPERTY( QString title READ title WRITE setTitle ) public: /** * Constructor */ QSGraphicalData( QObject *parent=0, QSGraphicalData *parentObject=0, const char *name=0 ); /** * Destructor. */ virtual ~QSGraphicalData(); /** * Sets a plot title. */ void setTitle( const QString& title ); /** * Returns title. */ QString title() const { return m_title_str; } /** * Sets a new matrix as the given channel in the plot. */ virtual bool setMatrix( int channel, QSMatrix *m ); /** * Returns matrix 'channel' if any, or NULL. * Notice that you should not operate on it during drawing ( see QSAxes::state ) * because this affects internal iterator positions in those matrices. */ virtual QSMatrix *matrix( int channel ) const; /** * Deletes the choosen matrix. */ virtual void deleteMatrix( int channel ); /** * Return matrix and sets data to NULL. */ virtual QSMatrix *takeMatrix( int channel, QSMatrix *newMatrix ); /** * Returns the total number of channels. */ int channelCount() const { return m_channels_count; } /** * Returns value at the position (x, y) from the channel 'channel'. * You have to pass correct arguments to this function because * it does not perform any channel or range checking. */ inline double value( int row, int col, int channel ) { return m_channels[channel]->value(row,col); } /** * Returs the height of the choosen matrix or 0 if it is not set. */ int matrixRows( int channel ) const { return channelrows():0):0; } /** * Returs the width of the choosen matrix or 0 if it is not set. */ int matrixCols( int channel ) const { return channelcols():0):0; } /** * Returns 'true' if matrix at the given channel exist. */ bool isChannel( int channel ) const; /** * Sets the font for the 'e' element. */ void setFont( int e, const QSGFont &font ); /** * Sets the fill for the 'e' element. */ void setFill( int e, const QSGFill &fill ); /** * Set a line style for the 'e' element. */ void setLine( int e, const QSGLine &line ); /** * Set a point style for the 'e' element. */ void setPoint( int e, const QSGPoint &point ); /** * Returns a font style of the given element */ QSGFont font( int e ) const { return eparemerersChanging() */ virtual void parametersChanging(); /** * This function is called after any parameter change. * This function can be reimplemented but unfortunately there is no * information, which parameter has changed. * It informs derived classes that they should repaint themselves. * Default implementation calls parent->parametersChanging(); */ virtual void parametersChanged(); /** * Calculates a logarithm of value 'value'. * Fix it to remember log10(logBase); */ double _log( double value, double logBase = 10.0 ) { return log10(value)/log10(logBase); } /** * fonts, fills and lines styles */ struct settings_t { QSGFont *fonts; QSGFill *fills; QSGLine *lines; QSGPoint *points; int fonts_count; int fills_count; int lines_count; int points_count; } m_settings; /** * list of matrices */ QSMatrix **m_channels; int m_channels_count; QString m_title_str; QSGraphicalData *m_parent_base_object; }; #endif