---
XmlParser/XmlParser.pro | 4 +-
XmlParser/XmlParser.pro.user | 135 +++++++++++++++++++++++++++++++++++-------
XmlParser/demodir.h | 7 --
XmlParser/main.cpp | 1 +
XmlParser/mainwindow.cpp | 24 ++++----
XmlParser/mainwindow.h | 4 +-
XmlParser/polygonitem.cpp | 23 ++++----
XmlParser/polygonitem.h | 1 +
XmlParser/region.h | 16 +++---
XmlParser/runner.cpp | 8 ++-
XmlParser/runner.h | 4 +-
XmlParser/scene.cpp | 21 ++++++-
XmlParser/scene.h | 2 +
XmlParser/toolbar.cpp | 7 ++
XmlParser/toolbar.h | 2 +-
XmlParser/xml.cpp | 72 +++++-----------------
16 files changed, 204 insertions(+), 127 deletions(-)
delete mode 100644 XmlParser/demodir.h
diff --git a/XmlParser/XmlParser.pro b/XmlParser/XmlParser.pro
index e65b72a..597fc47 100644
--- a/XmlParser/XmlParser.pro
+++ b/XmlParser/XmlParser.pro
@@ -5,7 +5,8 @@ QT += xml
TARGET = XmlParser
TEMPLATE = app
INCLUDEPATH += /lrde/home/stage/froger_a/olena/milena/ \
- /lrde/home/stage/froger_a/olena/scribo/
+ /lrde/home/stage/froger_a/olena/scribo/ \
+ /lrde/home/stage/froger_a/olena/_build/scribo/demo/
QMAKE_CXXFLAGS += -DNDEBUG \
-DMLN_WO_GLOBAL_VARS
LIBS += -I/usr/include/graphicsImage \
@@ -31,7 +32,6 @@ HEADERS += mainwindow.h \
polygonitem.h \
runner.h \
toolbar.h \
- demodir.h \
process.h \
preprocess.h \
configs.h \
diff --git a/XmlParser/XmlParser.pro.user b/XmlParser/XmlParser.pro.user
index 0b03fae..9eea455 100644
--- a/XmlParser/XmlParser.pro.user
+++ b/XmlParser/XmlParser.pro.user
@@ -50,7 +50,7 @@
</data>
<data>
<variable>activebuildconfiguration</variable>
- <value type="QString">Debug</value>
+ <value type="QString">Release</value>
</data>
<data>
<variable>buildConfiguration-Debug</variable>
@@ -67,6 +67,7 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName"
type="QString">Release</value>
<value key="QtVersionId" type="int">0</value>
+ <value key="ToolChain" type="int">0</value>
<value key="addQDumper" type=""></value>
<value key="buildConfiguration" type="int">0</value>
</valuemap>
@@ -76,35 +77,35 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName"
type="QString">Debug</value>
<valuelist key="abstractProcess.Environment"
type="QVariantList">
- <value
type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-jXUCLOmOZn,guid=4585eaa0c02f09d20a77bf8f006153a8</value>
+ <value
type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-TRVg8AHdB1,guid=cba5ba91aecc3f6dfc36295700626000</value>
<value type="QString">DESKTOP_SESSION=fluxbox</value>
<value type="QString">DISPLAY=:0.0</value>
<value type="QString">GDMSESSION=fluxbox</value>
<value type="QString">GDM_LANG=fr_FR.UTF-8</value>
<value type="QString">GDM_XSERVER_LOCATION=local</value>
- <value
type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-aTERin</value>
- <value type="QString">GNOME_KEYRING_PID=8076</value>
+ <value
type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-nw18hR</value>
+ <value type="QString">GNOME_KEYRING_PID=3747</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/lrde/home/stage/froger_a</value>
<value type="QString">LANG=fr_FR.UTF-8</value>
<value
type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
<value type="QString">LOGNAME=froger_a</value>
- <value
type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value>
+ <value type="QString">OLDPWD=/lrde/home/stage/froger_a</value>
<value
type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value>
<value
type="QString">PWD=/lrde/home/stage/froger_a/qt/XmlParser</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SHLVL=2</value>
- <value type="QString">SSH_AGENT_PID=8151</value>
- <value
type="QString">SSH_AUTH_SOCK=/tmp/ssh-wrZmtE8085/agent.8085</value>
+ <value type="QString">SSH_AGENT_PID=3822</value>
+ <value
type="QString">SSH_AUTH_SOCK=/tmp/ssh-SkEKXK3756/agent.3756</value>
<value type="QString">TERM=xterm</value>
<value type="QString">USER=froger_a</value>
<value type="QString">USERNAME=froger_a</value>
- <value type="QString">WINDOWID=10485796</value>
- <value
type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value>
- <value type="QString">XAUTHORITY=/tmp/.gdm4ATXQW</value>
+ <value type="QString">WINDOWID=12582948</value>
+ <value
type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value>
+ <value type="QString">XAUTHORITY=/tmp/.gdmQ2DSQW</value>
<value
type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value>
- <value
type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358426220.205793-1492047644</value>
+ <value
type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358494916.667367-1101742900</value>
<value type="QString">XPSERVERLIST=:64 </value>
<value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value>
<value type="QString">XTERM_SHELL=/bin/bash</value>
@@ -128,35 +129,35 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName"
type="QString">Debug</value>
<valuelist key="abstractProcess.Environment"
type="QVariantList">
- <value
type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-jXUCLOmOZn,guid=4585eaa0c02f09d20a77bf8f006153a8</value>
+ <value
type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-TRVg8AHdB1,guid=cba5ba91aecc3f6dfc36295700626000</value>
<value type="QString">DESKTOP_SESSION=fluxbox</value>
<value type="QString">DISPLAY=:0.0</value>
<value type="QString">GDMSESSION=fluxbox</value>
<value type="QString">GDM_LANG=fr_FR.UTF-8</value>
<value type="QString">GDM_XSERVER_LOCATION=local</value>
- <value
type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-aTERin</value>
- <value type="QString">GNOME_KEYRING_PID=8076</value>
+ <value
type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-nw18hR</value>
+ <value type="QString">GNOME_KEYRING_PID=3747</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/lrde/home/stage/froger_a</value>
<value type="QString">LANG=fr_FR.UTF-8</value>
<value
type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
<value type="QString">LOGNAME=froger_a</value>
- <value
type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value>
+ <value type="QString">OLDPWD=/lrde/home/stage/froger_a</value>
<value
type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value>
<value
type="QString">PWD=/lrde/home/stage/froger_a/qt/XmlParser</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SHLVL=2</value>
- <value type="QString">SSH_AGENT_PID=8151</value>
- <value
type="QString">SSH_AUTH_SOCK=/tmp/ssh-wrZmtE8085/agent.8085</value>
+ <value type="QString">SSH_AGENT_PID=3822</value>
+ <value
type="QString">SSH_AUTH_SOCK=/tmp/ssh-SkEKXK3756/agent.3756</value>
<value type="QString">TERM=xterm</value>
<value type="QString">USER=froger_a</value>
<value type="QString">USERNAME=froger_a</value>
- <value type="QString">WINDOWID=10485796</value>
- <value
type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value>
- <value type="QString">XAUTHORITY=/tmp/.gdm4ATXQW</value>
+ <value type="QString">WINDOWID=12582948</value>
+ <value
type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value>
+ <value type="QString">XAUTHORITY=/tmp/.gdmQ2DSQW</value>
<value
type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value>
- <value
type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358426220.205793-1492047644</value>
+ <value
type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358494916.667367-1101742900</value>
<value type="QString">XPSERVERLIST=:64 </value>
<value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value>
<value type="QString">XTERM_SHELL=/bin/bash</value>
@@ -186,18 +187,110 @@
<variable>buildconfiguration-Release-buildstep0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName"
type="QString">Release</value>
+ <valuelist key="abstractProcess.Environment"
type="QVariantList">
+ <value
type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-E5D7SPzCvM,guid=d599357c9b4b11459397a7040062a9e9</value>
+ <value type="QString">DESKTOP_SESSION=fluxbox</value>
+ <value type="QString">DISPLAY=:0.0</value>
+ <value type="QString">GDMSESSION=fluxbox</value>
+ <value type="QString">GDM_LANG=fr_FR.UTF-8</value>
+ <value type="QString">GDM_XSERVER_LOCATION=local</value>
+ <value
type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-IhfkdE</value>
+ <value type="QString">GNOME_KEYRING_PID=8615</value>
+ <value type="QString">GTK_MODULES=canberra-gtk-module</value>
+ <value type="QString">HOME=/lrde/home/stage/froger_a</value>
+ <value type="QString">LANG=fr_FR.UTF-8</value>
+ <value
type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
+ <value type="QString">LOGNAME=froger_a</value>
+ <value
type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value>
+ <value
type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value>
+ <value
type="QString">PWD=/lrde/home/stage/froger_a/qt/XmlParser</value>
+ <value type="QString">QTDIR=/usr/share/qt4</value>
+ <value type="QString">SHELL=/bin/bash</value>
+ <value type="QString">SHLVL=2</value>
+ <value type="QString">SSH_AGENT_PID=8690</value>
+ <value
type="QString">SSH_AUTH_SOCK=/tmp/ssh-znXRds8624/agent.8624</value>
+ <value type="QString">TERM=xterm</value>
+ <value type="QString">USER=froger_a</value>
+ <value type="QString">USERNAME=froger_a</value>
+ <value type="QString">WINDOWID=16777252</value>
+ <value
type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value>
+ <value type="QString">XAUTHORITY=/tmp/.gdmLS4BRW</value>
+ <value
type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value>
+ <value
type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358513837.420735-2094239602</value>
+ <value type="QString">XPSERVERLIST=:64 </value>
+ <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value>
+ <value type="QString">XTERM_SHELL=/bin/bash</value>
+ <value type="QString">XTERM_VERSION=XTerm(261)</value>
+ <value type="QString">_=/usr/bin/qtcreator</value>
+ </valuelist>
+ <valuelist key="abstractProcess.arguments"
type="QVariantList">
+ <value
type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/XmlParser/XmlParser.pro</value>
+ <value type="QString">-spec</value>
+ <value type="QString">linux-g++</value>
+ <value type="QString">-r</value>
+ </valuelist>
+ <value key="abstractProcess.command"
type="QString">/usr/bin/qmake-qt4</value>
+ <value key="abstractProcess.enabled"
type="bool">false</value>
+ <value key="abstractProcess.workingDirectory"
type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/XmlParser</value>
</valuemap>
</data>
<data>
<variable>buildconfiguration-Release-buildstep1</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName"
type="QString">Release</value>
+ <valuelist key="abstractProcess.Environment"
type="QVariantList">
+ <value
type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-E5D7SPzCvM,guid=d599357c9b4b11459397a7040062a9e9</value>
+ <value type="QString">DESKTOP_SESSION=fluxbox</value>
+ <value type="QString">DISPLAY=:0.0</value>
+ <value type="QString">GDMSESSION=fluxbox</value>
+ <value type="QString">GDM_LANG=fr_FR.UTF-8</value>
+ <value type="QString">GDM_XSERVER_LOCATION=local</value>
+ <value
type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-IhfkdE</value>
+ <value type="QString">GNOME_KEYRING_PID=8615</value>
+ <value type="QString">GTK_MODULES=canberra-gtk-module</value>
+ <value type="QString">HOME=/lrde/home/stage/froger_a</value>
+ <value type="QString">LANG=fr_FR.UTF-8</value>
+ <value
type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value>
+ <value type="QString">LOGNAME=froger_a</value>
+ <value
type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value>
+ <value
type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value>
+ <value
type="QString">PWD=/lrde/home/stage/froger_a/qt/XmlParser</value>
+ <value type="QString">QTDIR=/usr/share/qt4</value>
+ <value type="QString">SHELL=/bin/bash</value>
+ <value type="QString">SHLVL=2</value>
+ <value type="QString">SSH_AGENT_PID=8690</value>
+ <value
type="QString">SSH_AUTH_SOCK=/tmp/ssh-znXRds8624/agent.8624</value>
+ <value type="QString">TERM=xterm</value>
+ <value type="QString">USER=froger_a</value>
+ <value type="QString">USERNAME=froger_a</value>
+ <value type="QString">WINDOWID=16777252</value>
+ <value
type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value>
+ <value type="QString">XAUTHORITY=/tmp/.gdmLS4BRW</value>
+ <value
type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value>
+ <value
type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358513837.420735-2094239602</value>
+ <value type="QString">XPSERVERLIST=:64 </value>
+ <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value>
+ <value type="QString">XTERM_SHELL=/bin/bash</value>
+ <value type="QString">XTERM_VERSION=XTerm(261)</value>
+ <value type="QString">_=/usr/bin/qtcreator</value>
+ </valuelist>
+ <value key="abstractProcess.IgnoreReturnValue"
type="bool">false</value>
+ <valuelist key="abstractProcess.arguments"
type="QVariantList">
+ <value type="QString">-w</value>
+ </valuelist>
+ <value key="abstractProcess.command"
type="QString">/usr/bin/make</value>
+ <value key="abstractProcess.enabled"
type="bool">true</value>
+ <value key="abstractProcess.workingDirectory"
type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/XmlParser</value>
</valuemap>
</data>
<data>
<variable>buildconfiguration-Release-cleanstep0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName"
type="QString">Release</value>
+ <value key="cleanConfig" type="bool">true</value>
+ <valuelist key="makeargs" type="QVariantList">
+ <value type="QString">clean</value>
+ </valuelist>
</valuemap>
</data>
<data>
diff --git a/XmlParser/demodir.h b/XmlParser/demodir.h
deleted file mode 100644
index 4182ace..0000000
--- a/XmlParser/demodir.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef DEMODIR_H
-#define DEMODIR_H
-
-# define SCRIBO_PREFIX_BINDIR "/usr/local/bin"
-# define SCRIBO_LOCAL_DEMODIR
"/lrde/home/stage/froger_a/olena/_build/scribo/demo"
-
-#endif // DEMODIR_H
diff --git a/XmlParser/main.cpp b/XmlParser/main.cpp
index 53ec79f..aecf5cd 100644
--- a/XmlParser/main.cpp
+++ b/XmlParser/main.cpp
@@ -12,6 +12,7 @@
int main(int argc, char **argv)
{
Magick::InitializeMagick(*argv);
+ QApplication::setGraphicsSystem("raster");
QApplication a(argc, argv);
MainWindow w;
w.show();
diff --git a/XmlParser/mainwindow.cpp b/XmlParser/mainwindow.cpp
index eb461fc..a9415cf 100644
--- a/XmlParser/mainwindow.cpp
+++ b/XmlParser/mainwindow.cpp
@@ -10,6 +10,7 @@ MainWindow::MainWindow(QWidget *parent):
QVBoxLayout *gBLayout = new QVBoxLayout;
gBLayout->addWidget(ui->graphicsView);
ui->groupBox->setLayout(gBLayout);
+ ui->graphicsView->setCacheMode(QGraphicsView::CacheBackground);
scene = new Scene(ui->graphicsView);
scene->setSceneRect(ui->graphicsView->geometry());
ui->graphicsView->setScene(scene);
@@ -18,16 +19,19 @@ MainWindow::MainWindow(QWidget *parent):
toolBar->setGeometry(0, ui->menuBar->height(), ui->menuBar->width(),
30);
connect(toolBar->openAction(), SIGNAL(triggered()), this,
SLOT(on_actionOpen_triggered()));
connect(toolBar->quitAction(), SIGNAL(triggered()), this, SLOT(close()));
- connect(toolBar->segmentAction(), SIGNAL(triggered()), this,
SLOT(onSegmentation()));
+ connect(toolBar->segmentAction(), SIGNAL(triggered()), this,
SLOT(onBeginSegmentation()));
progressDialog = new ProgressDialog(this);
- connect(&runner, SIGNAL(finished(QString*)), this,
SLOT(onEndSegmentation(QString*)));
+ connect(&runner, SIGNAL(finished()), progressDialog, SLOT(close()));
connect(&runner, SIGNAL(new_progress_max_value(int)), progressDialog,
SLOT(setMaximum(int)));
connect(&runner, SIGNAL(new_progress_label(QString)), progressDialog,
SLOT(setLabelText(QString)));
+ connect(&runner, SIGNAL(xml_saved(QString)), this, SLOT(onXmlSaved(QString)));
connect(&runner, SIGNAL(progress()), progressDialog, SLOT(run()));
}
MainWindow::~MainWindow()
{
+ delete scene;
+ delete progressDialog;
delete ui;
}
@@ -49,17 +53,14 @@ void MainWindow::on_actionOpen_triggered()
imagePath = QFileDialog::getOpenFileName(this);
if(imagePath != "")
{
+ scene->removeItems();
QPixmap pixmap(imagePath);
- QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(pixmap);
- pixmapItem->setFlag(QGraphicsItem::ItemNegativeZStacksBehindParent, true);
- pixmapItem->setZValue(-1);
- pixmapItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- ui->graphicsView->scene()->setSceneRect(pixmap.rect());
- ui->graphicsView->scene()->addItem(pixmapItem);
+ scene->setSceneRect(pixmap.rect());
+ scene->setBackgroundBrush(QBrush(pixmap));
}
}
-void MainWindow::onSegmentation()
+void MainWindow::onBeginSegmentation()
{
if(imagePath != "")
{
@@ -68,10 +69,9 @@ void MainWindow::onSegmentation()
}
}
-void MainWindow::onEndSegmentation(QString *filename)
+void MainWindow::onXmlSaved(const QString& filename)
{
- progressDialog->close();
- Xml::parseItems(*filename, scene);
+ Xml::parseItems(filename, scene);
}
/*void MainWindow::on_action(QString& string)
diff --git a/XmlParser/mainwindow.h b/XmlParser/mainwindow.h
index 6deccc7..e8e899a 100644
--- a/XmlParser/mainwindow.h
+++ b/XmlParser/mainwindow.h
@@ -39,8 +39,8 @@ class MainWindow :
private slots:
void on_actionOpen_triggered();
- void onSegmentation();
- void onEndSegmentation(QString *filename);
+ void onBeginSegmentation();
+ void onXmlSaved(const QString& filename);
//void on_action(QString& string);
};
diff --git a/XmlParser/polygonitem.cpp b/XmlParser/polygonitem.cpp
index 5ab3e7e..2c20dbf 100644
--- a/XmlParser/polygonitem.cpp
+++ b/XmlParser/polygonitem.cpp
@@ -1,7 +1,7 @@
#include "polygonitem.h"
-PolygonItem::PolygonItem(QGraphicsItem *parent, QGraphicsScene *scene):
- QGraphicsPolygonItem(parent, scene)
+PolygonItem::PolygonItem(QGraphicsItem *parent, QGraphicsScene *scene)
+ : QGraphicsPolygonItem(parent, scene)
{
init();
}
@@ -12,23 +12,24 @@ PolygonItem::PolygonItem(const QPolygonF &polygon, QGraphicsItem
*parent, QGraph
init();
}
+PolygonItem::~PolygonItem()
+{
+ delete selectedPen;
+ delete unselectedPen;
+ delete selectedBrush;
+ delete unselectedBrush;
+}
+
void PolygonItem::init()
{
- setCacheMode(QGraphicsItem::ItemCoordinateCache);
- setFlags(QGraphicsItem::ItemClipsToShape);
selectedPen = new QPen(Qt::SolidLine);
unselectedPen = new QPen(Qt::SolidLine);
- selectedPen->setWidthF(3);
+ selectedPen->setWidthF(2);
unselectedPen->setWidth(0);
selectedPen->setCapStyle(Qt::SquareCap);
unselectedPen->setCapStyle(Qt::SquareCap);
selectedBrush = new QBrush(Qt::SolidPattern);
unselectedBrush = new QBrush(Qt::SolidPattern);
- QRectF bRect(boundingRect());
- if(bRect.width() < 1)
- bRect.setWidth(1);
- if(bRect.height() < 1)
- bRect.setHeight(1);
}
void PolygonItem::setColor(const QColor &color)
@@ -46,7 +47,7 @@ QColor PolygonItem::color() const
return selectedBrush->color();
}
-void PolygonItem::repaint(const QRectF &rect, bool clic)
+void PolygonItem::repaint(const QRectF& rect, bool clic)
{
bool sel;
if(clic)
diff --git a/XmlParser/polygonitem.h b/XmlParser/polygonitem.h
index c46fcb4..50abf61 100644
--- a/XmlParser/polygonitem.h
+++ b/XmlParser/polygonitem.h
@@ -13,6 +13,7 @@ class PolygonItem :
public:
explicit PolygonItem(QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);
explicit PolygonItem(const QPolygonF& path, QGraphicsItem *parent = 0,
QGraphicsScene *scene = 0);
+ ~PolygonItem();
void setColor(const QColor& color);
QColor color() const;
diff --git a/XmlParser/region.h b/XmlParser/region.h
index 0741177..e0c456e 100644
--- a/XmlParser/region.h
+++ b/XmlParser/region.h
@@ -5,14 +5,6 @@
namespace GraphicRegion
{
- struct Data
- {
- QColor color;
- QString name;
- int region;
- int zValue;
- };
-
enum Id
{
Text,
@@ -30,6 +22,14 @@ namespace GraphicRegion
Chart,
Maths
};
+
+ struct Data
+ {
+ QColor color;
+ QString name;
+ int region;
+ int zValue;
+ };
}
namespace Separator
diff --git a/XmlParser/runner.cpp b/XmlParser/runner.cpp
index 7ad62fa2..8dfd8b0 100644
--- a/XmlParser/runner.cpp
+++ b/XmlParser/runner.cpp
@@ -33,7 +33,8 @@ void Runner::run()
image2d<value::rgb8> ima;
io::magick::load(ima, args_.at(0).toUtf8().constData());
image2d<bool> bin_ima = preprocess(ima);
- emit finished(&process(ima, bin_ima));
+ process(ima, bin_ima);
+ emit finished();
}
break;
@@ -130,12 +131,13 @@ void Runner::process(const image2d<value::rgb8>&
original_ima,
if (!dir.exists() && !dir.mkpath(output_dir))
output_dir = QDir::tempPath();
}
- f.output_file = (output_dir + "/" + file.baseName() +
"_gui.xml").toUtf8().constData();
+ QString filename = (output_dir + "/" + file.baseName() +
"_gui.xml");
+ f.output_file = filename.toUtf8().constData();
emit new_progress_max_value(f.nsteps());
// Perform text detection.
f(original_ima, processed_ima);
- return f.output_file;
+ emit xml_saved(filename);
//qDebug() << "Process Done.";
}
diff --git a/XmlParser/runner.h b/XmlParser/runner.h
index 0e506b7..56a07df 100644
--- a/XmlParser/runner.h
+++ b/XmlParser/runner.h
@@ -34,7 +34,7 @@ class Runner :
private:
image2d<bool> preprocess(const image2d<value::rgb8>& ima);
- QString process(const image2d<value::rgb8>& original_ima, const
image2d<bool>& processed_ima);
+ void process(const image2d<value::rgb8>& original_ima, const
image2d<bool>& processed_ima);
void export_as();
virtual void run();
template <typename V> unsigned find_best_scale(const
mln::image2d<V>& ima);
@@ -51,7 +51,7 @@ class Runner :
void new_progress_label(const QString& msg);
void xml_saved(const QString& filename);
void progress();
- void finished(QString *filename = 0);
+ void finished();
};
#endif // RUNNER_H
diff --git a/XmlParser/scene.cpp b/XmlParser/scene.cpp
index 79cc213..612d2bd 100644
--- a/XmlParser/scene.cpp
+++ b/XmlParser/scene.cpp
@@ -18,6 +18,11 @@ Scene::Scene(qreal x, qreal y, qreal width, qreal height, QObject
*parent):
init();
}
+Scene::~Scene()
+{
+ delete selection;
+}
+
void Scene::init()
{
isPressing = false;
@@ -25,6 +30,17 @@ void Scene::init()
selection = new Selection(this);
}
+void Scene::removeItems()
+{
+ QList<QGraphicsItem *> itemsList = items();
+ QGraphicsItem *i;
+ foreach(i, itemsList)
+ {
+ if(i != selection)
+ delete i;
+ }
+}
+
void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if(event->button() == Qt::LeftButton && !isPressing)
@@ -57,9 +73,8 @@ void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
isPressing = false;
if(clic)
- emit repaintItems(QRectF(QPointF(0, 0), event->scenePos()), true);
- else
- emit repaintItems(selection->rect(), false);
+ selection->setRect(QRectF(QPointF(0, 0), event->scenePos()));
+ emit repaintItems(selection->rect(), clic);
selection->setRect(0, 0, 0, 0);
}
}
diff --git a/XmlParser/scene.h b/XmlParser/scene.h
index 47e0cf2..b7294c6 100644
--- a/XmlParser/scene.h
+++ b/XmlParser/scene.h
@@ -15,6 +15,8 @@ class Scene :
explicit Scene(QObject *parent = 0);
explicit Scene(const QRectF &sceneRect, QObject *parent = 0);
explicit Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent =
0);
+ ~Scene();
+ void removeItems();
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
diff --git a/XmlParser/toolbar.cpp b/XmlParser/toolbar.cpp
index 746f5ee..7742310 100644
--- a/XmlParser/toolbar.cpp
+++ b/XmlParser/toolbar.cpp
@@ -12,6 +12,13 @@ ToolBar::ToolBar(QWidget *parent):
quit = addAction(tr("Quit"));
}
+ToolBar::~ToolBar()
+{
+ delete open;
+ delete segment;
+ delete quit;
+}
+
QAction * ToolBar::openAction() const
{
return open;
diff --git a/XmlParser/toolbar.h b/XmlParser/toolbar.h
index 25609af..e7a3b77 100644
--- a/XmlParser/toolbar.h
+++ b/XmlParser/toolbar.h
@@ -3,13 +3,13 @@
#include <QToolBar>
#include <QAction>
-#include "mainwindow.h"
class ToolBar :
public QToolBar
{
public:
explicit ToolBar(QWidget *parent);
+ ~ToolBar();
QAction * openAction() const;
QAction * segmentAction() const;
QAction * quitAction() const;
diff --git a/XmlParser/xml.cpp b/XmlParser/xml.cpp
index 4b20005..67c5451 100644
--- a/XmlParser/xml.cpp
+++ b/XmlParser/xml.cpp
@@ -1,6 +1,19 @@
#include "xml.h"
#include "region.h"
+static const GraphicRegion::Data itemsData[] =
+{
+ {QColor::fromRgb(0, 0, 255, 60), "VerticalSeparatorRegion",
(int)GraphicRegion::VerticalSeparator, 2},
+ {QColor::fromRgb(0, 0, 255, 60), "HorizontalSeparatorRegion",
(int)GraphicRegion::HorizontalSeparator, 2},
+ {QColor::fromRgb(0, 0, 128, 60), "WhitespaceSeparatorRegion",
(int)GraphicRegion::WhiteSpaceSeparator, 2},
+ {QColor::fromRgb(255, 120, 0, 60), "ImageRegion",
(int)GraphicRegion::Image, 1},
+ {QColor::fromRgb(43, 39, 128, 60), "NoiseRegion",
(int)GraphicRegion::Noise, 2},
+ {QColor::fromRgb(220, 246, 0, 60), "TableRegion",
(int)GraphicRegion::Table, 2},
+ {QColor::fromRgb(170, 0, 255, 60), "MathsRegion",
(int)GraphicRegion::Maths, 3},
+ {QColor::fromRgb(255, 0, 144, 60), "GraphicRegion",
(int)GraphicRegion::Graphic, 2},
+ {QColor::fromRgb(0, 204, 255, 60), "ChartRegion",
(int)GraphicRegion::Chart, 2}
+};
+
Xml::Xml()
{
}
@@ -29,10 +42,12 @@ void Xml::graphicsTypoRegion(const QDomElement& element, const
QPoint& xPos, Sce
{
int yPos = element.attribute("baseline", "null").toInt();
QGraphicsLineItem *baselineRegion = new QGraphicsLineItem(QLine(QPoint(xPos.x(),
yPos), QPoint(xPos.y(), yPos)), 0, scene);
+ baselineRegion->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
baselineRegion->setData(0, QVariant::fromValue((int)GraphicRegion::Baseline));
baselineRegion->setZValue(3);
yPos = element.attribute("meanline", "null").toInt();
QGraphicsLineItem *meanlineRegion = new QGraphicsLineItem(QLine(QPoint(xPos.x(),
yPos), QPoint(xPos.y(), yPos)), 0, scene);
+ meanlineRegion->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
meanlineRegion->setData(0, QVariant::fromValue((int)GraphicRegion::Meanline));
meanlineRegion->setZValue(3);
}
@@ -95,61 +110,8 @@ void Xml::parseItems(const QString &filename, Scene *scene)
QDomDocument xml;
xml.setContent(&xmlFile);
xmlFile.close();
- QVector<QGraphicsItem *> items;
QDomElement element =
xml.documentElement().firstChild().nextSiblingElement("Page").firstChild().toElement();
graphicsTextRegion(element, scene);
- GraphicRegion::Data verticalData;
- verticalData.color = QColor::fromRgb(0, 0, 255, 80);
- verticalData.name = "VerticalSeparatorRegion";
- verticalData.region = (int)GraphicRegion::VerticalSeparator;
- verticalData.zValue = 2;
- graphicsRegion(element.nextSiblingElement(verticalData.name), verticalData, scene);
- GraphicRegion::Data horizontalData;
- horizontalData.color = QColor::fromRgb(0, 0, 255, 80);
- horizontalData.name = "HorizontalSeparatorRegion";
- horizontalData.region = (int)GraphicRegion::HorizontalSeparator;
- horizontalData.zValue = 2;
- graphicsRegion(element.nextSiblingElement(horizontalData.name), horizontalData,
scene);
- GraphicRegion::Data spaceData;
- spaceData.color = QColor::fromRgb(0, 0, 128, 80);
- spaceData.name = "WhitespaceSeparatorRegion";
- spaceData.region = (int)GraphicRegion::WhiteSpaceSeparator;
- spaceData.zValue = 2;
- graphicsRegion(element.nextSiblingElement(spaceData.name), spaceData, scene);
- GraphicRegion::Data imageData;
- imageData.color = QColor::fromRgb(255, 120, 0, 80);
- imageData.name = "ImageRegion";
- imageData.region = (int)GraphicRegion::Image;
- imageData.zValue = 1;
- graphicsRegion(element.nextSiblingElement(imageData.name), imageData, scene);
- GraphicRegion::Data noiseData;
- noiseData.color = QColor::fromRgb(43, 39, 128, 80);
- noiseData.name = "NoiseRegion";
- noiseData.region = (int)GraphicRegion::Noise;
- noiseData.zValue = 2;
- graphicsRegion(element.nextSiblingElement(noiseData.name), noiseData, scene);
- GraphicRegion::Data tableData;
- tableData.color = QColor::fromRgb(220, 246, 0, 80);
- tableData.name = "TableRegion";
- tableData.region = (int)GraphicRegion::Table;
- tableData.zValue = 2;
- graphicsRegion(element.nextSiblingElement(tableData.name), tableData, scene);
- GraphicRegion::Data mathsData;
- mathsData.color = QColor::fromRgb(170, 0, 255, 80);
- mathsData.name = "MathsRegion";
- mathsData.region = (int)GraphicRegion::Maths;
- mathsData.zValue = 3;
- graphicsRegion(element.nextSiblingElement(mathsData.name), mathsData, scene);
- GraphicRegion::Data graphicData;
- graphicData.color = QColor::fromRgb(255, 0, 144, 80);
- graphicData.name = "GraphicRegion";
- graphicData.region = (int)GraphicRegion::Graphic;
- graphicData.zValue = 2;
- graphicsRegion(element.nextSiblingElement(graphicData.name), graphicData, scene);
- GraphicRegion::Data chartData;
- chartData.color = QColor::fromRgb(0, 204, 255, 80);
- chartData.name = "ChartRegion";
- chartData.region = (int)GraphicRegion::Chart;
- chartData.zValue = 2;
- graphicsRegion(element.nextSiblingElement(chartData.name), chartData, scene);
+ for(int i = 0; i < 9; i++)
+ graphicsRegion(element.nextSiblingElement(itemsData[i].name), itemsData[i],
scene);
}
--
1.7.2.5