[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Thu Feb 21 18:46:45 CET 2008
SVN commit 777820 by fenton:
Add Circle Item as options for Layout.
Fix locked Aspect Ratio in ViewItem.
M +1 -1 arrowitem.cpp
A circleitem.cpp [License: GPL (v2+)]
A circleitem.h [License: GPL (v2+)]
M +2 -0 libkstapp.pro
M +16 -0 mainwindow.cpp
M +2 -0 mainwindow.h
M +7 -2 viewitem.cpp
M +2 -0 viewitemzorder.h
--- branches/work/kst/portto4/kst/src/libkstapp/arrowitem.cpp #777819:777820
@@ -25,7 +25,7 @@
ArrowItem::ArrowItem(View *parent)
: ViewItem(parent) {
setName("Arrow");
- setZValue(LINE_ZVALUE);
+ setZValue(ARROW_ZVALUE);
setAllowedGrips(RightMidGrip | LeftMidGrip);
QBrush b = brush();
b.setStyle(Qt::SolidPattern);
--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #777819:777820
@@ -33,6 +33,7 @@
changedatasampledialog.cpp \
changefiledialog.cpp \
choosecolordialog.cpp \
+ circleitem.cpp \
commandlineparser.cpp \
contenttab.cpp \
csddialog.cpp \
@@ -117,6 +118,7 @@
changedatasampledialog.h \
changefiledialog.h \
choosecolordialog.h \
+ circleitem.h \
commandlineparser.h\
contenttab.h \
csddialog.h \
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #777819:777820
@@ -21,6 +21,7 @@
#include "debug.h"
#include "labelitem.h"
#include "lineitem.h"
+#include "circleitem.h"
#include "arrowitem.h"
#include "memorywidget.h"
#include "objectstore.h"
@@ -119,6 +120,7 @@
//disable all layout actions
_createLabelAct->setEnabled(layoutMode);
_createBoxAct->setEnabled(layoutMode);
+ _createCircleAct->setEnabled(layoutMode);
_createEllipseAct->setEnabled(layoutMode);
_createLineAct->setEnabled(layoutMode);
_createArrowAct->setEnabled(layoutMode);
@@ -355,6 +357,12 @@
}
+void MainWindow::createCircle() {
+ CreateCircleCommand *cmd = new CreateCircleCommand;
+ cmd->createItem();
+}
+
+
void MainWindow::createEllipse() {
CreateEllipseCommand *cmd = new CreateEllipseCommand;
cmd->createItem();
@@ -472,6 +480,12 @@
_createBoxAct->setEnabled(false);
connect(_createBoxAct, SIGNAL(triggered()), this, SLOT(createBox()));
+ _createCircleAct = new QAction(tr("&Create circle"), this);
+ _createCircleAct->setStatusTip(tr("Create a circle for the current view"));
+ _createCircleAct->setIcon(QPixmap(":kst_gfx_ellipse.png"));
+ _createCircleAct->setEnabled(false);
+ connect(_createCircleAct, SIGNAL(triggered()), this, SLOT(createCircle()));
+
_createEllipseAct = new QAction(tr("&Create ellipse"), this);
_createEllipseAct->setStatusTip(tr("Create an ellipse for the current view"));
_createEllipseAct->setIcon(QPixmap(":kst_gfx_ellipse.png"));
@@ -668,6 +682,7 @@
_layoutMenu->addSeparator();
_layoutMenu->addAction(_createLabelAct);
_layoutMenu->addAction(_createBoxAct);
+ _layoutMenu->addAction(_createCircleAct);
_layoutMenu->addAction(_createEllipseAct);
_layoutMenu->addAction(_createLineAct);
_layoutMenu->addAction(_createArrowAct);
@@ -717,6 +732,7 @@
_layoutToolBar = new QToolBar(tr("Layout"), this);
// _layoutToolBar->addAction(_createLabelAct); //no icon
_layoutToolBar->addAction(_createBoxAct);
+ _layoutToolBar->addAction(_createCircleAct);
_layoutToolBar->addAction(_createEllipseAct);
_layoutToolBar->addAction(_createLineAct);
_layoutToolBar->addAction(_createArrowAct);
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.h #777819:777820
@@ -78,6 +78,7 @@
void createBox();
void createEllipse();
void createLabel();
+ void createCircle();
void createLine();
void createArrow();
void createPicture();
@@ -143,6 +144,7 @@
// FIXME: move these into each object, along with the creation slot?
QAction *_createLabelAct;
QAction *_createBoxAct;
+ QAction *_createCircleAct;
QAction *_createEllipseAct;
QAction *_createLineAct;
QAction *_createArrowAct;
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #777819:777820
@@ -1209,25 +1209,30 @@
QPointF ViewItem::lockOffset(const QPointF &offset, qreal ratio, bool oddCorner) const {
qreal x;
qreal y;
+ bool xKey;
if (offset.x() < 0 && offset.y() > 0) {
+ xKey = true;
x = offset.x();
y = x == 0 ? 0 : (1 / ratio) * x;
} else if (offset.y() < 0 && offset.x() > 0) {
+ xKey = false;
y = offset.y();
x = y == 0 ? 0 : ratio * y;
} else if (qAbs(offset.x()) < qAbs(offset.y())) {
+ xKey = true;
x = offset.x();
y = x == 0 ? 0 : (1 / ratio) * x;
} else {
+ xKey = false;
y = offset.y();
x = y == 0 ? 0 : ratio * y;
}
QPointF o = offset;
if (oddCorner) {
- o = QPointF(y == offset.y() ? -x : x,
- x == offset.x() ? -y : y);
+ o = QPointF(!xKey ? -x : x,
+ xKey ? -y : y);
} else {
o = QPointF(x, y);
}
--- branches/work/kst/portto4/kst/src/libkstapp/viewitemzorder.h #777819:777820
@@ -14,10 +14,12 @@
#define PLOTRENDER_ZVALUE 3
#define PLOTAXIS_ZVALUE 4
#define BOX_ZVALUE 5
+#define CIRCLE_ZVALUE 7
#define ELLIPSE_ZVALUE 7
#define PICTURE_ZVALUE 7
#define SVG_ZVALUE 7
#define LABEL_ZVALUE 8
#define LINE_ZVALUE 9
+#define ARROW_ZVALUE 9
// vim: ts=2 sw=2 et
More information about the Kst
mailing list