|
libkpl
4.1
A Library for Graphical Presentation of Data Sets and Functions
|
Kpl graphics scene class. More...
#include <kplscene.h>

Signals | |
| void | mouseMoved (const QPointF &pos, const FrameItem *frame) |
| Emitted when mouse has moved within the plot window. More... | |
| void | mousePressed (const QPointF &pos, Qt::MouseButtons buttons) |
| Emitted when mouse button has been pressed. More... | |
| void | positionChanged (QGraphicsItem *item) |
| Emitted when position of item has changed. More... | |
| void | previewCreated (const QString &filename) |
| Emitted after creation of a preview file to allow scheduling for cleanup. More... | |
Public Member Functions | |
| KplScene (const QSizeF &size=QSizeF(21, 14.8), QObject *parent=0) | |
| Constructor. More... | |
| ~KplScene () | |
| Destructor. More... | |
| void | insertItem (QGraphicsItem *item, int z=-1) |
| Inserts a plot item and makes it a child item of a framelike item, if a framelike item with lower z value exists and the inserted item is no framelike item itself. More... | |
| QList< QGraphicsItem * > | items (Qt::SortOrder order) const |
| Returns ordered list of items. More... | |
| QPointF | map (const QPointF &p) const |
| Maps from cm to pixel units. More... | |
| QPointF | mapInv (const QPointF &p) const |
| Maps from pixel to cm units. More... | |
| const QTransform & | matrix () const |
| Returns matrix for transformation from cm to pixel units. More... | |
| void | print (QPrinter *printer) |
| Prints plot. More... | |
| bool | readData (const KUrl &url, ArrayItem::DecimalCharacter decimalChar=ArrayItem::Point, bool autoPathHeader=false, bool autoNorm=true, bool logX=false, bool logY=false, double x0=4, double y0=3, double width=15, double height=10, unsigned colorFrame=0, unsigned colorGrid=0, unsigned colorData=0, FrameItem::GridMode gridMode=FrameItem::AxesWithLabels, const QString &xText="x", const QString &yText="y", const QString &header="", double relSize=1, int colX=0, int colY=1, int colErr=2, bool errorBars=false, KplItem::Symbol symbol=KplItem::SolidLine) |
| Opens a data file. More... | |
| bool | readPlo (const KUrl &url, QWidget *window=0) |
| Reads plot file, initializes items and adds them to the scene. More... | |
| bool | savePlo (const KUrl &url, bool absolute=true, char format= 'g', int precision=6) const |
| Saves all plot items at URL. More... | |
| bool | savePS (const KUrl &url=KUrl(), bool landscape=false, bool boundingBox=true, bool internalPS=true) |
| Generates PostScript file. More... | |
| const QSizeF | size () const |
| Returns scene size in cm units. More... | |
| void | setDashOffset () const |
| Sets offset for dashed lines. More... | |
| void | setProperties (QGraphicsItem *item) const |
| Sets item properties according to transformation matrix. More... | |
| void | setSize (const QSizeF &size) |
| Sets scene size and transformation matrix. More... | |
| QPointF | steps (int z=-1) const |
| Returns user unit steps for one pixel steps. More... | |
| void | updatePos (QGraphicsItem *item) |
| Emits signal positionChanged. More... | |
Public Member Functions inherited from QGraphicsScene | |
| QGraphicsScene (QObject *parent) | |
| QGraphicsScene (const QRectF &sceneRect, QObject *parent) | |
| QGraphicsScene (qreal x, qreal y, qreal width, qreal height, QObject *parent) | |
| QRectF | sceneRect () const |
| qreal | width () const |
| qreal | height () const |
| void | setSceneRect (const QRectF &rect) |
| void | setSceneRect (qreal x, qreal y, qreal w, qreal h) |
| void | render (QPainter *painter, const QRectF &target, const QRectF &source, Qt::AspectRatioMode aspectRatioMode) |
| ItemIndexMethod | itemIndexMethod () const |
| void | setItemIndexMethod (ItemIndexMethod method) |
| bool | isSortCacheEnabled () const |
| void | setSortCacheEnabled (bool enabled) |
| int | bspTreeDepth () const |
| void | setBspTreeDepth (int depth) |
| QRectF | itemsBoundingRect () const |
| QList< QGraphicsItem * > | items () const |
| QList< QGraphicsItem * > | items (Qt::SortOrder order) const |
| QList< QGraphicsItem * > | items (const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const |
| QList< QGraphicsItem * > | items (const QRectF &rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const |
| QList< QGraphicsItem * > | items (const QPolygonF &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const |
| QList< QGraphicsItem * > | items (const QPainterPath &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const |
| QList< QGraphicsItem * > | items (const QPointF &pos) const |
| QList< QGraphicsItem * > | items (const QRectF &rectangle, Qt::ItemSelectionMode mode) const |
| QList< QGraphicsItem * > | items (const QPolygonF &polygon, Qt::ItemSelectionMode mode) const |
| QList< QGraphicsItem * > | items (const QPainterPath &path, Qt::ItemSelectionMode mode) const |
| QList< QGraphicsItem * > | collidingItems (const QGraphicsItem *item, Qt::ItemSelectionMode mode) const |
| QGraphicsItem * | itemAt (const QPointF &position) const |
| QGraphicsItem * | itemAt (const QPointF &position, const QTransform &deviceTransform) const |
| QList< QGraphicsItem * > | items (qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode) const |
| QList< QGraphicsItem * > | items (qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const |
| QGraphicsItem * | itemAt (qreal x, qreal y) const |
| QGraphicsItem * | itemAt (qreal x, qreal y, const QTransform &deviceTransform) const |
| QList< QGraphicsItem * > | selectedItems () const |
| QPainterPath | selectionArea () const |
| void | setSelectionArea (const QPainterPath &path) |
| void | setSelectionArea (const QPainterPath &path, const QTransform &deviceTransform) |
| void | setSelectionArea (const QPainterPath &path, Qt::ItemSelectionMode mode) |
| void | setSelectionArea (const QPainterPath &path, Qt::ItemSelectionMode mode, const QTransform &deviceTransform) |
| QGraphicsItemGroup * | createItemGroup (const QList< QGraphicsItem * > &items) |
| void | destroyItemGroup (QGraphicsItemGroup *group) |
| void | addItem (QGraphicsItem *item) |
| QGraphicsEllipseItem * | addEllipse (const QRectF &rect, const QPen &pen, const QBrush &brush) |
| QGraphicsLineItem * | addLine (const QLineF &line, const QPen &pen) |
| QGraphicsPathItem * | addPath (const QPainterPath &path, const QPen &pen, const QBrush &brush) |
| QGraphicsPixmapItem * | addPixmap (const QPixmap &pixmap) |
| QGraphicsPolygonItem * | addPolygon (const QPolygonF &polygon, const QPen &pen, const QBrush &brush) |
| QGraphicsRectItem * | addRect (const QRectF &rect, const QPen &pen, const QBrush &brush) |
| QGraphicsTextItem * | addText (const QString &text, const QFont &font) |
| QGraphicsSimpleTextItem * | addSimpleText (const QString &text, const QFont &font) |
| QGraphicsProxyWidget * | addWidget (QWidget *widget, QFlags< Qt::WindowType > wFlags) |
| QGraphicsEllipseItem * | addEllipse (qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush) |
| QGraphicsLineItem * | addLine (qreal x1, qreal y1, qreal x2, qreal y2, const QPen &pen) |
| QGraphicsRectItem * | addRect (qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush) |
| void | removeItem (QGraphicsItem *item) |
| QGraphicsItem * | focusItem () const |
| void | setFocusItem (QGraphicsItem *item, Qt::FocusReason focusReason) |
| bool | hasFocus () const |
| void | setFocus (Qt::FocusReason focusReason) |
| void | clearFocus () |
| void | setStickyFocus (bool enabled) |
| bool | stickyFocus () const |
| QGraphicsItem * | mouseGrabberItem () const |
| QBrush | backgroundBrush () const |
| void | setBackgroundBrush (const QBrush &brush) |
| QBrush | foregroundBrush () const |
| void | setForegroundBrush (const QBrush &brush) |
| virtual QVariant | inputMethodQuery (Qt::InputMethodQuery query) const |
| QList< QGraphicsView * > | views () const |
| void | update (qreal x, qreal y, qreal w, qreal h) |
| void | invalidate (qreal x, qreal y, qreal w, qreal h, QFlags< QGraphicsScene::SceneLayer > layers) |
| QStyle * | style () const |
| void | setStyle (QStyle *style) |
| QFont | font () const |
| void | setFont (const QFont &font) |
| QPalette | palette () const |
| void | setPalette (const QPalette &palette) |
| bool | isActive () const |
| QGraphicsItem * | activePanel () const |
| void | setActivePanel (QGraphicsItem *item) |
| QGraphicsWidget * | activeWindow () const |
| void | setActiveWindow (QGraphicsWidget *widget) |
| bool | sendEvent (QGraphicsItem *item, QEvent *event) |
| void | update (const QRectF &rect) |
| void | invalidate (const QRectF &rect, QFlags< QGraphicsScene::SceneLayer > layers) |
| void | advance () |
| void | clearSelection () |
| void | clear () |
| void | changed (const QList< QRectF > ®ion) |
| void | sceneRectChanged (const QRectF &rect) |
| void | selectionChanged () |
Public Member Functions inherited from QObject | |
| QObject (QObject *parent) | |
| virtual const QMetaObject * | metaObject () const |
| QString | objectName () const |
| void | setObjectName (const QString &name) |
| bool | isWidgetType () const |
| bool | signalsBlocked () const |
| bool | blockSignals (bool block) |
| QThread * | thread () const |
| void | moveToThread (QThread *targetThread) |
| int | startTimer (int interval) |
| void | killTimer (int id) |
| T | findChild (const QString &name) const |
| QList< T > | findChildren (const QString &name) const |
| QList< T > | findChildren (const QRegExp ®Exp) const |
| QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
| const QObjectList & | children () const |
| void | setParent (QObject *parent) |
| void | installEventFilter (QObject *filterObj) |
| void | removeEventFilter (QObject *obj) |
| bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
| bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
| bool | disconnect (const QObject *receiver, const char *method) |
| void | dumpObjectTree () |
| void | dumpObjectInfo () |
| bool | setProperty (const char *name, const QVariant &value) |
| QVariant | property (const char *name) const |
| QList< QByteArray > | dynamicPropertyNames () const |
| void | destroyed (QObject *obj) |
| QObject * | parent () const |
| bool | inherits (const char *className) const |
| void | deleteLater () |
| QObject (QObject *parent, const char *name) | |
| void | insertChild (QObject *object) |
| void | removeChild (QObject *object) |
| bool | isA (const char *className) const |
| const char * | className () const |
| const char * | name () const |
| const char * | name (const char *defaultName) const |
| void | setName (const char *name) |
Static Public Member Functions | |
| static bool | framelike (int type) |
| Checks if type of an item is that of a FrameItem or an item inheriting from FrameItem. More... | |
| static bool | readPlo (const KUrl &url, QList< QGraphicsItem * > &list, QWidget *window=0, unsigned colorFrame=0, unsigned colorGrid=0, unsigned colorData=0, KplItem::Symbol symbol=KplItem::OpenCircle, double x0=4, double y0=3, double width=15, double height=10, FrameItem::GridMode gridMode=FrameItem::AxesWithLabels, int colX=0, int colY=0, int colErr=0, bool errorBars=false) |
| Reads plot file and initializes plot items. More... | |
| static bool | savePlo (const KUrl &url, const QList< QGraphicsItem * > &list, bool absolute=true, char format= 'g', int precision=6) |
| Saves plot items of a given list at URL. More... | |
Static Public Member Functions inherited from QObject | |
| QString | tr (const char *sourceText, const char *disambiguation, int n) |
| QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
| bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
| bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
| bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
| bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
Protected Member Functions | |
| FrameItem * | frame (int z=-1) const |
| Finds parent item corresponding to a z value of a plot item. More... | |
| virtual void | mouseMoveEvent (QGraphicsSceneMouseEvent *e) |
| Emits signal mouseMoved to indicate actual position and the frame item under the mouse cursor. More... | |
| virtual void | mousePressEvent (QGraphicsSceneMouseEvent *e) |
| Emits signal mousePressed to indicate actual position and pressed button. More... | |
Protected Member Functions inherited from QGraphicsScene | |
| virtual bool | event (QEvent *event) |
| virtual bool | eventFilter (QObject *watched, QEvent *event) |
| virtual void | contextMenuEvent (QGraphicsSceneContextMenuEvent *contextMenuEvent) |
| virtual void | dragEnterEvent (QGraphicsSceneDragDropEvent *event) |
| virtual void | dragMoveEvent (QGraphicsSceneDragDropEvent *event) |
| virtual void | dragLeaveEvent (QGraphicsSceneDragDropEvent *event) |
| virtual void | dropEvent (QGraphicsSceneDragDropEvent *event) |
| virtual void | focusInEvent (QFocusEvent *focusEvent) |
| virtual void | focusOutEvent (QFocusEvent *focusEvent) |
| virtual void | helpEvent (QGraphicsSceneHelpEvent *helpEvent) |
| virtual void | keyPressEvent (QKeyEvent *keyEvent) |
| virtual void | keyReleaseEvent (QKeyEvent *keyEvent) |
| virtual void | mouseReleaseEvent (QGraphicsSceneMouseEvent *mouseEvent) |
| virtual void | mouseDoubleClickEvent (QGraphicsSceneMouseEvent *mouseEvent) |
| virtual void | wheelEvent (QGraphicsSceneWheelEvent *wheelEvent) |
| virtual void | inputMethodEvent (QInputMethodEvent *event) |
| virtual void | drawBackground (QPainter *painter, const QRectF &rect) |
| virtual void | drawForeground (QPainter *painter, const QRectF &rect) |
| virtual void | drawItems (QPainter *painter, int numItems, QGraphicsItem *[] items, const QStyleOptionGraphicsItem[] options, QWidget *widget) |
| bool | focusNextPrevChild (bool next) |
Protected Member Functions inherited from QObject | |
| QObject * | sender () const |
| int | senderSignalIndex () const |
| int | receivers (const char *signal) const |
| virtual void | timerEvent (QTimerEvent *event) |
| virtual void | childEvent (QChildEvent *event) |
| virtual void | customEvent (QEvent *event) |
| virtual void | connectNotify (const char *signal) |
| virtual void | disconnectNotify (const char *signal) |
| bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
Protected Attributes | |
| double | m_sx |
| double | m_sy |
| QTransform | m_matrix |
| QTransform | m_inv |
| QSizeF | m_size |
Additional Inherited Members | |
Public Attributes inherited from QGraphicsScene | |
| typedef | SceneLayers |
Static Protected Member Functions inherited from QObject | |
| QByteArray | normalizeSignalSlot (const char *signalSlot) |
Properties inherited from QGraphicsScene | |
| backgroundBrush | |
| foregroundBrush | |
| itemIndexMethod | |
| sceneRect | |
| bspTreeDepth | |
| palette | |
| font | |
| sortCacheEnabled | |
| stickyFocus | |
Properties inherited from QObject | |
| objectName | |
Kpl graphics scene class.
The methods readData, readPlo and insertItem can be used to populate the scene with plot items. The methods print and savePS allow to print and to export as PostScript file, respectively.
Constructor.
| size | scene size in cm units. |
| parent | pointer to parent QObject. |
| KplScene::~KplScene | ( | ) |
Destructor.
|
protected |
Finds parent item corresponding to a z value of a plot item.
| z | z value of item, -1 for end of list. |
|
static |
Checks if type of an item is that of a FrameItem or an item inheriting from FrameItem.
| type | item type as returned by the item's function type() reimplemented from QGraphicsItem::type(). |
| void KplScene::insertItem | ( | QGraphicsItem * | item, |
| int | z = -1 |
||
| ) |
Inserts a plot item and makes it a child item of a framelike item, if a framelike item with lower z value exists and the inserted item is no framelike item itself.
| item | pointer to plot item. |
| z | z value of item, -1 for appending. |
| QList<QGraphicsItem*> KplScene::items | ( | Qt::SortOrder | order | ) | const |
Returns ordered list of items.
| order | sort order: Qt::AscendingOrder or Qt::DescendingOrder. |
Maps from cm to pixel units.
| p | position in cm. |
Maps from pixel to cm units.
| p | position in pixel units. |
|
inline |
Returns matrix for transformation from cm to pixel units.
Emitted when mouse has moved within the plot window.
| pos | mouse cursor position. |
| frame | pointer to frame containing pos item or 0 if pos not within a frame item. |
|
protectedvirtual |
Emits signal mouseMoved to indicate actual position and the frame item under the mouse cursor.
| e | mouse event. |
Reimplemented from QGraphicsScene.
|
signal |
Emitted when mouse button has been pressed.
| pos | mouse cursor position. |
| buttons | combination of pressed mouse buttons. |
|
protectedvirtual |
Emits signal mousePressed to indicate actual position and pressed button.
| e | mouse event. |
Reimplemented from QGraphicsScene.
|
signal |
Emitted when position of item has changed.
| item | pointer to plot item. |
|
signal |
Emitted after creation of a preview file to allow scheduling for cleanup.
| filename | full path of preview file. |
| void KplScene::print | ( | QPrinter * | printer | ) |
Prints plot.
| printer | pointer to printer object. |
| bool KplScene::readData | ( | const KUrl & | url, |
| ArrayItem::DecimalCharacter | decimalChar = ArrayItem::Point, |
||
| bool | autoPathHeader = false, |
||
| bool | autoNorm = true, |
||
| bool | logX = false, |
||
| bool | logY = false, |
||
| double | x0 = 4, |
||
| double | y0 = 3, |
||
| double | width = 15, |
||
| double | height = 10, |
||
| unsigned | colorFrame = 0, |
||
| unsigned | colorGrid = 0, |
||
| unsigned | colorData = 0, |
||
| FrameItem::GridMode | gridMode = FrameItem::AxesWithLabels, |
||
| const QString & | xText = "x", |
||
| const QString & | yText = "y", |
||
| const QString & | header = "", |
||
| double | relSize = 1, |
||
| int | colX = 0, |
||
| int | colY = 1, |
||
| int | colErr = 2, |
||
| bool | errorBars = false, |
||
| KplItem::Symbol | symbol = KplItem::SolidLine |
||
| ) |
Opens a data file.
In case of success, a FrameItem and a corresponding ArrayItem are constructed and added to the scene.
| url | URL of the file. |
| decimalChar | decimal symbol of floating point numbers used in file. |
| autoPathHeader | true for setting the heading to the path of the URL. |
| autoNorm | true for automatic normalization. |
| logX | true for logarithmic x axis. |
| logY | true for logarithmic y axis. |
| x0 | left page margin in cm. |
| y0 | bottom page margin in cm. |
| width | width in cm. |
| height | height in cm. |
| colorFrame | color for frame and labels. |
| colorGrid | color for grids and tics. |
| colorData | color for data plot. |
| gridMode | grid mode of frame item. |
| xText | x axis text. |
| yText | y axis text. |
| header | header text. |
| relSize | relative size of text, markers and lines. |
| colX | x column index. |
| colY | y column index. |
| colErr | y error column index. |
| errorBars | true to plot error bars. |
| symbol | symbol type. |
| bool KplScene::readPlo | ( | const KUrl & | url, |
| QWidget * | window = 0 |
||
| ) |
Reads plot file, initializes items and adds them to the scene.
| url | URL of the file. |
| window | pointer to main window. |
|
static |
Reads plot file and initializes plot items.
| url | URL of the file. |
| list | list for plot items. |
| window | pointer to main window. |
| colorFrame | default color for frame and labels. |
| colorGrid | default color for grids and tics. |
| colorData | default color for data plot. |
| symbol | default symbol type. |
| x0 | default left page margin in cm. |
| y0 | default bottom page margin in cm. |
| width | default width in cm. |
| height | default height in cm. |
| gridMode | default frame grid mode. |
| colX | default x column index. |
| colY | default y column index. |
| colErr | default y error column index. |
| errorBars | default, true to plot error bars. |
| bool KplScene::savePlo | ( | const KUrl & | url, |
| bool | absolute = true, |
||
| char | format = 'g', |
||
| int | precision = 6 |
||
| ) | const |
Saves all plot items at URL.
| url | URL of file. |
| absolute | save absolute URL when true. |
| format | format character for floating point number presentation. |
| precision | precision (number of digits) for floating point number presentation. |
|
static |
Saves plot items of a given list at URL.
| url | URL of file. |
| list | list of items to save. |
| absolute | save absolute URL when true. |
| format | format character for floating point number presentation. |
| precision | precision (number of digits) floating point number presentation. |
| bool KplScene::savePS | ( | const KUrl & | url = KUrl(), |
| bool | landscape = false, |
||
| bool | boundingBox = true, |
||
| bool | internalPS = true |
||
| ) |
Generates PostScript file.
| url | URL of the file. |
| landscape | true for landscape orientation. |
| boundingBox | true for calculation of PS bounding box. |
| internalPS | true for internal PS encoding. |
| void KplScene::setDashOffset | ( | ) | const |
Sets offset for dashed lines.
| void KplScene::setProperties | ( | QGraphicsItem * | item | ) | const |
Sets item properties according to transformation matrix.
| item | pointer to plot item. |
| void KplScene::setSize | ( | const QSizeF & | size | ) |
Sets scene size and transformation matrix.
| size | size in cm units. |
|
inline |
Returns scene size in cm units.
| QPointF KplScene::steps | ( | int | z = -1 | ) | const |
Returns user unit steps for one pixel steps.
| z | z value of item, -1 for end of list. |
| void KplScene::updatePos | ( | QGraphicsItem * | item | ) |
Emits signal positionChanged.
| item | pointer to plot item. |
1.8.8