16#include <QGraphicsScene>
34class Q_DECL_EXPORT
KplScene :
public QGraphicsScene
43 KplScene(
const QSizeF& size = QSizeF(21, 14.8), QObject* parent =
nullptr);
75 QList<QGraphicsItem*>
items(Qt::SortOrder order)
const;
81 QPointF
map(
const QPointF& p)
const;
87 QPointF
mapInv(
const QPointF& p)
const;
89 inline const QTransform&
matrix()
const {
return m_matrix; };
125 bool autoPathHeader =
false,
bool autoNorm =
true,
126 bool logX =
false,
bool logY =
false,
double x0 = 4,
127 double y0 = 3,
double width = 15,
double height = 10,
128 unsigned colorFrame = 0,
unsigned colorGrid = 0,
129 unsigned colorData = 0,
131 const QString& xText =
"x"_L1,
const QString& yText =
"y"_L1,
132 const QString& header =
""_L1,
double relSize = 1,
133 int colX = 0,
int colY = 1,
int colErr = 2,
134 bool errorBars =
false,
142 bool readPlo(
const QUrl& url, QWidget* window =
nullptr);
163 static bool readPlo(
const QUrl& url, QList<QGraphicsItem*>& list,
164 QWidget* window =
nullptr,
unsigned colorFrame = 0,
165 unsigned colorGrid = 0,
unsigned colorData = 0,
167 double x0 = 4,
double y0 = 3,
double width = 15,
170 int colX = 0,
int colY = 0,
int colErr = 0,
171 bool errorBars =
false);
181 bool savePlo(
const QUrl& url,
bool absolute =
true,
char format =
'g',
182 int precision = 6)
const;
193 static bool savePlo(
const QUrl& url,
const QList<QGraphicsItem*>& list,
194 bool absolute =
true,
char format =
'g',
203 bool savePS(
const QUrl& url = QUrl(),
bool landscape =
false,
204 bool boundingBox =
true);
206 inline const QSizeF
size()
const {
return m_size; };
275 QTransform m_matrix, m_inv;
DecimalCharacter
Decimal character.
Definition arrayitem.h:43
@ Point
Decimal point.
Definition arrayitem.h:44
Frame item class.
Definition frameitem.h:34
GridMode
Grid mode.
Definition frameitem.h:37
@ AxesWithLabels
Axes with tics and labels.
Definition frameitem.h:40
Symbol
Symbol types.
Definition kplitem.h:83
@ SolidLine
Solid line.
Definition kplitem.h:102
@ OpenCircle
Open circle.
Definition kplitem.h:101
Kpl graphics scene class.
Definition kplscene.h:35
void setSize(const QSizeF &size)
Sets scene size and transformation matrix.
bool savePlo(const QUrl &url, bool absolute=true, char format='g', int precision=6) const
Saves all plot items at URL.
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *e) override
Emits signal mouseMoved to indicate actual position and the frame item under the mouse cursor.
void mouseMoved(const QPointF &pos, const FrameItem *frame)
Emitted when mouse has moved within the plot window.
QPointF steps(int z=-1) const
Returns user unit steps for one pixel steps.
void mousePressed(const QPointF &pos, Qt::MouseButtons buttons)
Emitted when mouse button has been pressed.
void positionChanged(QGraphicsItem *item)
Emitted when position of item has changed.
void setDashOffsets() const
Sets offsets for dashed lines.
const QTransform & matrix() const
Returns matrix for transformation from cm to pixel units.
Definition kplscene.h:89
static bool framelike(int type)
Checks if type of an item is that of a FrameItem or an item inheriting from FrameItem.
bool exportImage(const QUrl &url, bool boundingBox=true)
Exports as image file.
void setProperties(QGraphicsItem *item) const
Sets item properties according to transformation matrix.
static bool savePlo(const QUrl &url, const QList< QGraphicsItem * > &list, bool absolute=true, char format='g', int precision=6)
Saves plot items of a given list at URL.
void previewCreated(const QString &filename)
Emitted after creation of a preview file to allow scheduling for cleanup.
bool readData(const QUrl &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"_L1, const QString &yText="y"_L1, const QString &header=""_L1, double relSize=1, int colX=0, int colY=1, int colErr=2, bool errorBars=false, KplItem::Symbol symbol=KplItem::SolidLine)
Opens a data file.
void print(QPrinter *printer)
Prints plot.
QList< QGraphicsItem * > items(Qt::SortOrder order) const
Returns ordered list of items.
virtual void mousePressEvent(QGraphicsSceneMouseEvent *e) override
Emits signal mousePressed to indicate actual position and pressed button.
QPointF mapInv(const QPointF &p) const
Maps from pixel to cm units.
const QSizeF size() const
Returns scene size in cm units.
Definition kplscene.h:206
static bool readPlo(const QUrl &url, QList< QGraphicsItem * > &list, QWidget *window=nullptr, 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.
FrameItem * frame(int z=-1) const
Finds parent item corresponding to a z value of a plot item.
bool readPlo(const QUrl &url, QWidget *window=nullptr)
Reads plot file, initializes items and adds them to the scene.
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 v...
QPointF map(const QPointF &p) const
Maps from cm to pixel units.
bool savePS(const QUrl &url=QUrl(), bool landscape=false, bool boundingBox=true)
Generates PostScript file.
void updatePos(QGraphicsItem *item)
Emits signal positionChanged.
KplScene(const QSizeF &size=QSizeF(21, 14.8), QObject *parent=nullptr)
Constructor.