1 /***************************************************************************
2 geomeytrval.cpp - description
5 copyright : (C) 2008 by Marco Gittler
6 email : g.marco@freenet.de
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
19 #include "geometryval.h"
20 #include <QGraphicsView>
21 #include <QVBoxLayout>
22 #include <QGraphicsScene>
23 #include "graphicsscenerectmove.h"
24 #include <QGraphicsRectItem>
25 #include <QMouseEvent>
28 Geometryval::Geometryval(QWidget* parent): QWidget(parent) {
30 QVBoxLayout* vbox = new QVBoxLayout(this);
31 ui.widget->setLayout(vbox);
32 QGraphicsView *view = new QGraphicsView(this);
33 view->setBackgroundBrush(QBrush(QColor(0, 0, 0)));
34 vbox->addWidget(view);
36 ui.frame->setTickPosition(QSlider::TicksBelow);
38 scene = new GraphicsSceneRectMove(this);
39 scene->setTool(TITLE_SELECT);
40 view->setScene(scene);
41 double aspect = 4.0 / 3.0; //change to project val
42 QGraphicsRectItem *m_frameBorder = new QGraphicsRectItem(QRectF(0, 0, 100.0*aspect, 100));
43 m_frameBorder->setZValue(-1100);
44 //m_frameBorder->setBrush(QColor(255, 255, 0, 255));
45 m_frameBorder->setPen(QPen(QBrush(QColor(255, 255, 255, 255)), 1.0, Qt::DashLine));
46 scene->addItem(m_frameBorder);
48 paramRect = new QGraphicsRectItem(QRectF(20.0*aspect, 20, 80*aspect, 80));
50 paramRect->setZValue(0);
51 //m_frameBorder1->setBrush(QColor(255, 0, 0, 0));
52 paramRect->setPen(QPen(QBrush(QColor(255, 0, 0, 255)), 1.0));
54 scene->addItem(paramRect);
56 scene->setSceneRect(-100.0*aspect, -100, 300.0*aspect, 300);
57 connect(scene , SIGNAL(itemMoved()) , this , SLOT(moveEvent()));
60 void Geometryval::moveEvent() {
61 //if (event->button())
63 QDomNodeList namenode = param.elementsByTagName("parameter");
64 QDomNode pa = namenode.item(0);
65 QRectF rec = paramRect->rect().translated(paramRect->pos());
66 pa.attributes().namedItem("value").setNodeValue(
67 QString("%1;%2;%3;%4;%5").arg(
70 (int)(rec.x() + rec.width())).arg(
71 (int)(rec.y() + rec.height())).arg(
75 //pa.attributes().namedItem("start").setNodeValue("50");
77 QTextStream stre(&dat);
80 emit parameterChanged();
83 QDomElement Geometryval::getParamDesc() {
87 void Geometryval::setupParam(const QDomElement& par, const QString& paramName, int minFrame, int maxFrame) {
89 //read param her and set rect
90 ui.frame->setRange(minFrame, maxFrame);