/usr/include/KChart/KChartChart.h is in libkchart-dev 2.6.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | /**
* Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
*
* This file is part of the KD Chart library.
*
* 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KCHARTCHART_H
#define KCHARTCHART_H
#include <QWidget>
#include "kchart_export.h"
#include "KChartGlobal.h"
/*
Simplified(*) overview of object ownership in a chart:
Chart is-a QWidget
|
n CoordinatePlanes is-a AbstractArea is-a AbstractLayoutItem is-a QLayoutItem
|
n Diagrams is-a QAbstractItemView is-a QWidget
/ | \
AbstractGrid | Axes (can be shared between diagrams) is-a AbstractArea is-a... QLayoutItem
(no base class) |
Legends is-a AbstractAreaWidget is-a QWidget
(*) less important classes, including base classes, removed.
Layout rules:
In principle, every size or existence change in one of the objects listed above must be propagated
to all other objects. This could change their size.
There are also settings changes that invalidate the size of other components, where the size changes
are detected and propagated.
Painting call tree (simplified):
Chart::paint() (from users) / paintEvent() (from framework)
ChartPrivate::paintAll()-----------------------------------------------\
CoordinatePlane::paintAll() (from AbstractArea)--------\ Axis::paintAll()-\
CoordinatePlane::paint() (from AbstractLayoutItem) Grid::drawGrid() Axis::paint()
Diagram::paint( PaintContext* paintContext )
Note that grids are painted from the coordinate plane, not from the diagram as ownership would suggest.
*/
namespace KChart {
class BackgroundAttributes;
class FrameAttributes;
class AbstractDiagram;
class AbstractCoordinatePlane;
class HeaderFooter;
class Legend;
typedef QList<AbstractCoordinatePlane*> CoordinatePlaneList;
typedef QList<HeaderFooter*> HeaderFooterList;
typedef QList<Legend*> LegendList;
/**
* @class Chart KChartChart.h KChartChart
* @brief A chart with one or more diagrams.
*
* The Chart class represents a drawing consisting of one or more diagrams
* and various optional elements such as legends, axes, text boxes, headers
* or footers. It takes ownership of all these elements when they are assigned
* to it. Each diagram is associated with a coordinate plane, of which the chart
* can have more than one. The coordinate planes (and thus the associated diagrams)
* can be laid out in various ways.
*
* The Chart class makes heavy use of the Qt Interview framework for model/view
* programming, and thus requires data to be presented to it in a QAbstractItemModel
* compatible way. For many simple charts, especially if the visualized data is
* static, KChart::Widget provides an abstracted interface, that hides the complexity
* of Interview to a large extent.
*/
class KCHART_EXPORT Chart : public QWidget
{
Q_OBJECT
// KD Chart 3.0: leading is inter-line distance of text. this here is MARGIN or SPACING.
Q_PROPERTY( int globalLeadingTop READ globalLeadingTop WRITE setGlobalLeadingTop )
Q_PROPERTY( int globalLeadingBottom READ globalLeadingBottom WRITE setGlobalLeadingBottom )
Q_PROPERTY( int globalLeadingLeft READ globalLeadingLeft WRITE setGlobalLeadingLeft )
Q_PROPERTY( int globalLeadingRight READ globalLeadingRight WRITE setGlobalLeadingRight )
Q_PROPERTY( bool useNewLayoutSystem READ useNewLayoutSystem WRITE setUseNewLayoutSystem )
KCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC_QWIDGET( Chart )
public:
explicit Chart ( QWidget* parent = 0 );
~Chart();
/**
* @brief useNewLayoutSystem
* Be very careful activating the new layout system,
* its still experimental and works only if the user knows
* what he is doing. The reason is that the system does not prevent
* the user from creating sharing graphs that are not layoutable in a
* plane and still needs assistance from the user.
*/
bool useNewLayoutSystem() const;
void setUseNewLayoutSystem( bool value );
/**
\brief Specify the frame attributes to be used, by default is it a thin black line.
To hide the frame line, you could do something like this:
\verbatim
KChart::FrameAttributes frameAttrs( my_chart->frameAttributes() );
frameAttrs.setVisible( false );
my_chart->setFrameAttributes( frameAttrs );
\endverbatim
\sa setBackgroundAttributes
*/
void setFrameAttributes( const FrameAttributes &a );
FrameAttributes frameAttributes() const;
/**
\brief Specify the background attributes to be used, by default there is no background.
To set a light blue background, you could do something like this:
\verbatim
KChart::BackgroundAttributes backgroundAttrs( my_chart->backgroundAttributes() );
backgroundAttrs.setVisible( true );
backgroundAttrs.setBrush( QColor(0xd0,0xd0,0xff) );
my_chart->setBackgroundAttributes( backgroundAttrs );
\endverbatim
\sa setFrameAttributes
*/
void setBackgroundAttributes( const BackgroundAttributes &a );
BackgroundAttributes backgroundAttributes() const;
/**
* Each chart must have at least one coordinate plane.
* Initially a default CartesianCoordinatePlane is created.
* Use replaceCoordinatePlane() to replace it with a different
* one, such as a PolarCoordinatePlane.
* @return The first coordinate plane of the chart.
*/
AbstractCoordinatePlane* coordinatePlane();
/**
* The list of coordinate planes.
* @return The list of coordinate planes.
*/
CoordinatePlaneList coordinatePlanes();
/**
* Adds a coordinate plane to the chart. The chart takes ownership.
* @param plane The coordinate plane to add.
*
* \sa replaceCoordinatePlane, takeCoordinatePlane
*/
void addCoordinatePlane( AbstractCoordinatePlane* plane );
/**
* Inserts a coordinate plane to the chart at index @p index.
* The chart takes ownership.
*
* @param index The index where to add the plane
* @param plane The coordinate plane to add.
*
* \sa replaceCoordinatePlane, takeCoordinatePlane
*/
void insertCoordinatePlane( int index, AbstractCoordinatePlane* plane );
/**
* Replaces the old coordinate plane, or appends the
* plane, it there is none yet.
*
* @param plane The coordinate plane to be used instead of the old plane.
* This parameter must not be zero, or the method will do nothing.
*
* @param oldPlane The coordinate plane to be removed by the new plane. This
* plane will be deleted automatically. If the parameter is omitted,
* the very first coordinate plane will be replaced. In case, there was no
* plane yet, the new plane will just be added.
*
* \note If you want to re-use the old coordinate plane, call takeCoordinatePlane and
* addCoordinatePlane, instead of using replaceCoordinatePlane.
*
* \sa addCoordinatePlane, takeCoordinatePlane
*/
void replaceCoordinatePlane( AbstractCoordinatePlane* plane,
AbstractCoordinatePlane* oldPlane = 0 );
/**
* Removes the coordinate plane from the chart, without deleting it.
*
* The chart no longer owns the plane, so it is
* the caller's responsibility to delete the plane.
*
* \sa addCoordinatePlane, takeCoordinatePlane
*/
void takeCoordinatePlane( AbstractCoordinatePlane* plane );
/**
* Set the coordinate plane layout that should be used as model for
* the internal used layout. The layout needs to be an instance of
* QHBoxLayout or QVBoxLayout.
*/
void setCoordinatePlaneLayout( QLayout * layout );
QLayout* coordinatePlaneLayout();
/**
* The first header or footer of the chart. By default there is none.
* @return The first header or footer of the chart or 0 if there was none
* added to the chart.
*/
HeaderFooter* headerFooter();
/**
* The list of headers and footers associated with the chart.
* @return The list of headers and footers associated with the chart.
*/
HeaderFooterList headerFooters();
/**
* Adds a header or a footer to the chart. The chart takes ownership.
* @param headerFooter The header (or footer, resp.) to add.
*
* \sa replaceHeaderFooter, takeHeaderFooter
*/
void addHeaderFooter( HeaderFooter* headerFooter );
/**
* Replaces the old header (or footer, resp.), or appends the
* new header or footer, it there is none yet.
*
* @param headerFooter The header or footer to be used instead of the old one.
* This parameter must not be zero, or the method will do nothing.
*
* @param oldHeaderFooter The header or footer to be removed by the new one. This
* header or footer will be deleted automatically. If the parameter is omitted,
* the very first header or footer will be replaced. In case, there was no
* header and no footer yet, the new header or footer will just be added.
*
* \note If you want to re-use the old header or footer, call takeHeaderFooter and
* addHeaderFooter, instead of using replaceHeaderFooter.
*
* \sa addHeaderFooter, takeHeaderFooter
*/
void replaceHeaderFooter ( HeaderFooter* headerFooter,
HeaderFooter* oldHeaderFooter = 0 );
/**
* Removes the header (or footer, resp.) from the chart, without deleting it.
*
* The chart no longer owns the header or footer, so it is
* the caller's responsibility to delete the header or footer.
*
* \sa addHeaderFooter, replaceHeaderFooter
*/
void takeHeaderFooter( HeaderFooter* headerFooter );
/**
* The first legend of the chart or 0 if there was none added to the chart.
* @return The first legend of the chart or 0 if none exists.
*/
Legend* legend();
/**
* The list of all legends associated with the chart.
* @return The list of all legends associated with the chart.
*/
LegendList legends();
/**
* Add the given legend to the chart. The chart takes ownership.
* @param legend The legend to add.
*
* \sa replaceLegend, takeLegend
*/
void addLegend( Legend* legend );
/**
* Replaces the old legend, or appends the
* new legend, it there is none yet.
*
* @param legend The legend to be used instead of the old one.
* This parameter must not be zero, or the method will do nothing.
*
* @param oldLegend The legend to be removed by the new one. This
* legend will be deleted automatically. If the parameter is omitted,
* the very first legend will be replaced. In case, there was no
* legend yet, the new legend will just be added.
*
* If you want to re-use the old legend, call takeLegend and
* addLegend, instead of using replaceLegend.
*
* \note Whenever addLegend is called the font sizes used by the
* Legend are set to relative and they get coupled to the Chart's size,
* with their relative values being 20 for the item texts and 24 to the
* title text. So if you want to use custom font sizes for the Legend
* make sure to set them after calling addLegend.
*
* \sa addLegend, takeLegend
*/
void replaceLegend ( Legend* legend, Legend* oldLegend = 0 );
/**
* Removes the legend from the chart, without deleting it.
*
* The chart no longer owns the legend, so it is
* the caller's responsibility to delete the legend.
*
* \sa addLegend, takeLegend
*/
void takeLegend( Legend* legend );
/**
* Set the padding between the margin of the widget and the area that
* the contents are drawn into.
* @param left The padding on the left side.
* @param top The padding at the top.
* @param right The padding on the left hand side.
* @param bottom The padding on the bottom.
*
* \note Using previous versions of KD Chart you might have called
* setGlobalLeading() to make room for long Abscissa labels (or for an
* overlapping top label of an Ordinate axis, resp.) that would not fit
* into the normal axis area. This is \em no \em longer \em needed
* because KD Chart now is using hidden auto-spacer items reserving
* as much free space as is needed for axes with overlaping content
* at the respective sides.
*
* \sa setGlobalLeadingTop, setGlobalLeadingBottom, setGlobalLeadingLeft, setGlobalLeadingRight
* \sa globalLeadingTop, globalLeadingBottom, globalLeadingLeft, globalLeadingRight
*/
void setGlobalLeading( int left, int top, int right, int bottom );
/**
* Set the padding between the start of the widget and the start
* of the area that is used for drawing on the left.
* @param leading The padding value.
*
* \sa setGlobalLeading
*/
void setGlobalLeadingLeft( int leading );
/**
* The padding between the start of the widget and the start
* of the area that is used for drawing on the left.
* @return The padding between the start of the widget and the start
* of the area that is used for drawing on the left.
*
* \sa setGlobalLeading
*/
int globalLeadingLeft() const;
/**
* Set the padding between the start of the widget and the start
* of the area that is used for drawing at the top.
* @param leading The padding value.
*
* \sa setGlobalLeading
*/
void setGlobalLeadingTop( int leading );
/**
* The padding between the start of the widget and the start
* of the area that is used for drawing at the top.
* @return The padding between the start of the widget and the start
* of the area that is used for drawing at the top.
*
* \sa setGlobalLeading
*/
int globalLeadingTop() const;
/**
* Set the padding between the start of the widget and the start
* of the area that is used for drawing on the right.
* @param leading The padding value.
*
* \sa setGlobalLeading
*/
void setGlobalLeadingRight( int leading );
/**
* The padding between the start of the widget and the start
* of the area that is used for drawing on the right.
* @return The padding between the start of the widget and the start
* of the area that is used for drawing on the right.
*
* \sa setGlobalLeading
*/
int globalLeadingRight() const;
/**
* Set the padding between the start of the widget and the start
* of the area that is used for drawing on the bottom.
* @param leading The padding value.
*
* \sa setGlobalLeading
*/
void setGlobalLeadingBottom( int leading );
/**
* The padding between the start of the widget and the start
* of the area that is used for drawing at the bottom.
* @return The padding between the start of the widget and the start
* of the area that is used for drawing at the bottom.
*
* \sa setGlobalLeading
*/
int globalLeadingBottom() const;
/**
* Paints all the contents of the chart. Use this method to make KChart
* draw into your QPainter.
*
* \note Any global leading settings will be used by the paint method too,
* so make sure to set them to zero, if you want the drawing to have the exact
* size of the target rectangle.
*
* \param painter The painter to be drawn into.
* \param target The rectangle to be filled by the Chart's drawing.
*
* \sa setGlobalLeading
*/
void paint( QPainter* painter, const QRect& target );
void reLayoutFloatingLegends();
Q_SIGNALS:
/** Emitted upon change of a property of the Chart or any of its components. */
void propertiesChanged();
void finishedDrawing();
protected:
/**
* Adjusts the internal layout when the chart is resized.
*/
/* reimp */ void resizeEvent ( QResizeEvent * event );
/**
* @brief Draws the background and frame, then calls paint().
*
* In most cases there is no need to override this method in a derived
* class, but if you do, do not forget to call paint().
* @sa paint
*/
/* reimp */ void paintEvent( QPaintEvent* event );
/** reimp */
void mousePressEvent( QMouseEvent* event );
/** reimp */
void mouseDoubleClickEvent( QMouseEvent* event );
/** reimp */
void mouseMoveEvent( QMouseEvent* event );
/** reimp */
void mouseReleaseEvent( QMouseEvent* event );
/** reimp */
bool event( QEvent* event );
private:
// TODO move this to the private class
void addLegendInternal( Legend *legend, bool setMeasures );
};
// Here we have a few docu block to be included into the API documentation:
/**
* \dir src
* \brief Implementation directory of KChart.
*
* This directory contains the header files and the source files of both,
* the private and the public classes.
*
* \note Only classes that have an include wrapper in the \c $KCHARTDIR/include
* directory are part of the supported API.
* All other classes are to be considered as implemntation details, they
* could be changed in future versions of KChart without notice.
*
* In other words: No class that is not mentioned in the \c $KCHARTDIR/include
* directory may be directly used by your application.
*
* The recommended way to include classes of the KChart API is including
* them by class name, so instead of including KChartChart.h you would say:
*
\verbatim
#include <KChartChart>
\endverbatim
*
* When following this there is no reason to include the \c $KCHARTDIR/src
* directory, it is sufficient to include \c $KCHARTDIR/include
*/
}
/**
* @class QAbstractItemView "(do not include)"
* @brief Class only listed here to document inheritance of some KChart classes.
*
* Please consult the respective Qt documentation for details:
* <A HREF="http://doc.trolltech.com/">http://doc.trolltech.com/</A>
*/
/**
* @class QAbstractProxyModel "(do not include)"
* @brief Class only listed here to document inheritance of some KChart classes.
*
* Please consult the respective Qt documentation for details:
* <A HREF="http://doc.trolltech.com/">http://doc.trolltech.com/</A>
*/
/**
* @class QFrame "(do not include)"
* @brief Class only listed here to document inheritance of some KChart classes.
*
* Please consult the respective Qt documentation for details:
* <A HREF="http://doc.trolltech.com/">http://doc.trolltech.com/</A>
*/
/**
* @class QObject "(do not include)"
* @brief Class only listed here to document inheritance of some KChart classes.
*
* Please consult the respective Qt documentation for details:
* <A HREF="http://doc.trolltech.com/">http://doc.trolltech.com/</A>
*/
/**
* @class QSortFilterProxyModel "(do not include)"
* @brief Class only listed here to document inheritance of some KChart classes.
*
* Please consult the respective Qt documentation for details:
* <A HREF="http://doc.trolltech.com/">http://doc.trolltech.com/</A>
*/
/**
* @class QWidget "(do not include)"
* @brief Class only listed here to document inheritance of some KChart classes.
*
* Please consult the respective Qt documentation for details:
* <A HREF="http://doc.trolltech.com/">http://doc.trolltech.com/</A>
*/
/**
* @class QTextDocument "(do not include)"
* @brief Class only listed here to document inheritance of some KChart classes.
*
* Please consult the respective Qt documentation for details:
* <A HREF="http://doc.trolltech.com/">http://doc.trolltech.com/</A>
*/
/**
* @class QLayoutItem "(do not include)"
* @brief Class only listed here to document inheritance of some KChart classes.
*
* Please consult the respective Qt documentation for details:
* <A HREF="http://doc.trolltech.com/">http://doc.trolltech.com/</A>
*/
/**
* @class QGraphicsPolygonItem "(do not include)"
* @brief Class only listed here to document inheritance of some KChart classes.
*
* Please consult the respective Qt documentation for details:
* <A HREF="http://doc.trolltech.com/">http://doc.trolltech.com/</A>
*/
#endif
|