Browse Source

import svgeditor from e1210

tuxun 2 years ago
parent
commit
6bc0ca1bc4
20 changed files with 3863 additions and 0 deletions
  1. 219 0
      chemin.cpp
  2. 71 0
      chemin.h
  3. 154 0
      draglabel.cpp
  4. 27 0
      draglabel.h
  5. 215 0
      files/bubbles.svg
  6. 77 0
      files/cubic.svg
  7. 72 0
      files/spheres.svg
  8. 647 0
      forme.cpp
  9. 100 0
      forme.h
  10. 62 0
      main.cpp
  11. 221 0
      mainwindow.cpp
  12. 82 0
      mainwindow.h
  13. 620 0
      selectsettingwindow.cpp
  14. 107 0
      selectsettingwindow.h
  15. 795 0
      svgview.cpp
  16. 91 0
      svgview.h
  17. BIN
      svgviewer
  18. 30 0
      svgviewer.pro
  19. 267 0
      svgviewer.pro.user
  20. 6 0
      svgviewer.qrc

+ 219 - 0
chemin.cpp

@@ -0,0 +1,219 @@
+#include "chemin.h"
+//constructors:
+drawPath::drawPath( ):QGraphicsItem()
+{
+   this->setAcceptedMouseButtons(Qt::AllButtons);
+    this->dest=QPointF(-111,-111);
+
+    this->path=QPainterPath();
+    //std::cout<<"drawpath(void)"<<std::endl;
+    this->nodes_number=0;
+    setAcceptDrops(true);
+
+}
+
+drawPath::~drawPath()
+{}
+
+//accesseur: set true if param =true
+void drawPath::setrealdraw(bool param)
+{
+    isrealdraw=param;
+    //foreachsubpath: setreal or not;
+}
+void drawPath::mousePressEvent(QMouseEvent *event)
+{
+    std::cout<<"drawpath(reealmousePressEvent)"<<std::endl;
+//    this->setAcceptedMouseButtons(Qt::AllButtons);
+event->accept();
+}
+
+
+drawPath& drawPath::operator=(drawPath const&
+sourcedecopie)
+
+{
+    this->origin=sourcedecopie.origin;
+    this->dest=sourcedecopie.dest;
+this->nodes_number=sourcedecopie.nodes_number;
+    this->path=QPainterPath(sourcedecopie.path);
+this->isrealdraw=sourcedecopie.isrealdraw;
+    std::cout<<"drawpath=()"<<std::endl;
+  //  this->setAcceptedMouseButtons(Qt::AllButtons);
+
+return  *this;
+}
+
+//hazardous copy constructor
+drawPath::drawPath(const drawPath &sourcedecopie):QGraphicsItem()
+{
+
+    this->origin=sourcedecopie.origin;
+    this->dest=sourcedecopie.dest;
+    this->path=QPainterPath(sourcedecopie.path);
+this->isrealdraw=sourcedecopie.isrealdraw;
+this->nodes_number=sourcedecopie.nodes_number;
+    //this->setAcceptedMouseButtons(Qt::AllButtons);
+
+    /*
+    std::cout<<":drawpath l53:drawPath(const drawPath &)"<<std::endl;
+
+    std::cout<<sourcedecopie.path.currentPosition().toPoint().x()<<":"<<sourcedecopie.path.currentPosition().toPoint().y()<<std::endl;
+    std::cout<<this->path.currentPosition().toPoint().x()<<":"<<this->path.currentPosition().toPoint().y()<<std::endl;
+
+*/
+}
+
+QRectF drawPath::boundingRect() const
+  {
+      //qreal penWidth = 1;
+      return  this->path.boundingRect();
+  }
+
+  void drawPath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+             QWidget *widget)
+  {
+
+      Q_UNUSED(option);
+      Q_UNUSED(widget);
+      //Q_UNUSED(painter);
+
+    //  painter->setBrush(Qt::NoBrush);
+if(isrealdraw)
+      painter->setPen(QPen(Qt::blue, 1));
+else
+    painter->setPen(QPen(Qt::red, 1));
+
+
+      painter->drawEllipse(-2,-2,4,4);
+
+     painter->drawPath(this->path);
+  }
+
+
+//  void drawPath::moveTo(QPointF desti)
+//  {
+//  this->path.moveTo(desti);
+//      this->node_number++;
+
+
+//  }
+
+
+  void drawPath::lineTo(QPointF desti)
+  {
+
+      //ahaha whaaaaaaaaat ????
+      //ne jamais  remettre!!!
+
+ //    std::cout<<"drawpath:lineto(qpf)"<<desti.x()<<desti.y()<<std::endl;
+      if(nodes_number==1)
+      {
+this->dest=desti;
+   //   std::cout<<" drawpath:lineto(dest)const:"<<this->dest.x()<<this->dest.y()<<std::endl;
+}
+      else
+      {
+this->dest=desti;
+      std::cout<<" drawpath:lineto(dest)const: but nodeisempty"<<this->dest.x()<<this->dest.y()<<std::endl;
+}
+      //ca marche mieux!
+  this->path.lineTo(desti);
+      this->nodes_number++;
+
+
+
+  }
+  drawPath::drawPath(QPointF origine)
+  {
+this->origin=origine;
+     // this->setAcceptedMouseButtons(Qt::AllButtons);
+  //    std::cout<<"drawpath(qpf)"<<std::endl;
+     // std::cout<<"drawpath(qpf)"<<origine.x()<<origine.y()<<std::endl;
+
+       this->path=QPainterPath(origine);
+      this->nodes_number=1;
+
+      this->dest=QPointF(-666,-666);
+
+    //  this->lineTo(origine);
+
+
+  }
+
+
+  drawPath::drawPath(QPointF origine,QPointF desti)
+  {
+this->path=QPainterPath(origine);
+    this->nodes_number=1;
+
+
+      this->dest=desti;
+      std::cout<<" drawpath(orig,dest)const:"<<this->dest.x()<<this->dest.y()<<std::endl;
+
+      this->origin=origine;
+      this->lineTo(desti);
+    //  this->setAcceptedMouseButtons(Qt::AllButtons);
+
+
+  }
+
+  //is static
+  int drawPath::getnode_number()const{
+   return this->nodes_number;
+
+      // :/
+  }
+
+  //is static
+  bool drawPath::isvalid() const{
+      if(getnode_number()==2)
+      return  true;
+      else return false;
+
+      // :/
+  }
+  QPainterPath drawPath::getpath() const{
+     std::cout<<"QPainterPath drawpath::getpath()const origin:"<<this->origin.x()<<this->origin.y()<<std::endl;
+      std::cout<<"QPainterPath drawpath::getpath()const dest:"<<this->dest.x()<<this->dest.y()<<std::endl;
+
+  return this->path;
+  }
+
+//drawPath::drawPath(QStringList *toadd)
+//{
+//    QStringList list1 = toadd->at(0).split(":", QString::SkipEmptyParts);
+//int i=0;
+//    //l'origine x du chemin est le premier numbre de la list, y le deuxieme
+//    this->origin=QPointF(list1.at(0).toFloat(),list1.at(1).toFloat());
+//    QPainterPath   path (this->origin);
+//    //node_number++;
+//    int node_number=1;
+
+////on trace le chemin pour tous les points restants
+//   for (i=1;i < toadd->size(); ++i)
+//    {
+//       node_number++;
+
+//        list1 = toadd->at(i).split(":", QString::SkipEmptyParts);
+//        this->dest=QPointF(list1.at(0).toFloat(),list1.at(1).toFloat());
+//        path.lineTo(this->dest);
+//        //path.setAcceptedMouseButtons(Qt::AllButtons);
+
+//         //std::cout<<i<<".addshpe(stringlist)."<<list1.at(0).toFloat()<<":"<<list1.at(1).toFloat()<<std::endl;
+//    }
+//   if (i>2)
+//       qDebug("drawpath with more than 2nodes");
+//    //QPen pen(Qt::blue, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+//    //this->sceneVue->fitInView(this->sceneConteneur->addPath(shape,pen));
+//}
+
+/*
+void drawPath::lineTo(float x, float  y)
+{this->path->lineTo(x,y);
+}
+
+void drawPath::lineTo(QPointF target_node)
+{this->path->lineTo(target_node);
+}
+*/

+ 71 - 0
chemin.h

@@ -0,0 +1,71 @@
+#ifndef DRAWPATH_H
+#define DRAWPATH_H
+#include <QPointF>
+#include <QPainterPath>
+#include  <QStringList>
+#include  <QPen>
+#include  <QtWidgets/QGraphicsItem>
+#include <QtWidgets/QtWidgets>
+
+#include <iostream>
+
+class drawPath: public QGraphicsItem
+{
+public:
+    void setrealdraw(bool param);
+
+    //constructors and  destructors
+    drawPath();
+    ~drawPath();
+    drawPath(QPointF origine);
+    drawPath(QPointF origine,QPointF desti);
+//copy constructor
+    drawPath (drawPath const& sourcedecopie);
+
+    drawPath& operator=(drawPath const&
+    sourcedecopie);
+
+    /* drawPath& operator=( drawPath const){
+         //  QPainterPath path(arg.path);
+       }
+       */
+    //public methods:
+    QRectF boundingRect() const;
+    //drawPath(QStringList *toadd);
+
+    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+               QWidget *widget);
+    void lineTo(QPointF desti);
+    void moveTo(QPointF desti);
+
+
+    //getters:
+    QPainterPath getpath() const;
+ bool isvalid(void) const;
+ int getnode_number() const;
+private:
+
+    bool isrealdraw;
+
+//    bool is_start;
+   // bool is_end;
+    QPointF origin;
+    QPointF dest;
+   // bool  visible;
+   // void lineTo(float x, float  y);
+    //QPointF currentPosition();
+    QPainterPath  path;
+
+  int nodes_number;
+protected:
+  void mousePressEvent(QMouseEvent *event);
+
+};
+
+/*
+bool operator==( drawPath a, bool b){
+    return a.isvalid()&&b;
+
+};*/
+
+#endif // DRAWPATH_H

+ 154 - 0
draglabel.cpp

@@ -0,0 +1,154 @@
+#include "draglabel.h"
+
+#include <QtWidgets>
+
+DragLabel::DragLabel(const QString &text, QTableWidgetItem *parent)
+
+{
+    QFontMetrics metric(font());
+    QSize size = metric.size(Qt::TextSingleLine, text);
+//this->setAcceptDrops(true);
+    QImage image(size.width() + 12, size.height() + 12, QImage::Format_ARGB32_Premultiplied);
+    image.fill(qRgba(0, 0, 0, 0));
+
+    QFont font;
+    font.setStyleStrategy(QFont::ForceOutline);
+
+    QLinearGradient gradient(0, 0, 0, image.height()-1);
+    gradient.setColorAt(0.0, Qt::white);
+    gradient.setColorAt(0.2, QColor(200, 200, 255));
+    gradient.setColorAt(0.8, QColor(200, 200, 255));
+    gradient.setColorAt(1.0, QColor(127, 127, 200));
+
+    QPainter painter;
+    painter.begin(&image);
+    painter.setRenderHint(QPainter::Antialiasing);
+    painter.setBrush(gradient);
+   // painter.drawRoundedRect(QRectF(0.5, 0.5, image.width()-1, image.height()-1),
+                            //25, 25, Qt::RelativeSize);
+
+    painter.setFont(font);
+    painter.setBrush(Qt::black);
+    painter.drawText(QRect(QPoint(6, 6), size), Qt::AlignCenter, text);
+    painter.end();
+
+   //setPixmap(QPixmap::fromImage(image));
+    m_labelText = text;
+}
+
+void DragLabel::dragEnterEvent(QDragEnterEvent *event)
+{
+    event->ignore();
+
+//    if (event->mimeData()->hasFormat("application/x-fridgemagnet")) {
+//        if (children().contains(event->source())) {
+//            event->setDropAction(Qt::MoveAction);
+//            event->accept();
+//        } else {
+//            event->acceptProposedAction();
+//        }
+//    } else if (event->mimeData()->hasText()) {
+//        event->acceptProposedAction();
+//    } else {
+//        event->ignore();
+//    }
+}
+
+void DragLabel::dragMoveEvent(QDragMoveEvent *event)
+{
+    event->ignore();
+
+//    if (event->mimeData()->hasFormat("application/x-fridgemagnet")) {
+//        if (children().contains(event->source())) {
+//            event->setDropAction(Qt::MoveAction);
+//            event->accept();
+//        } else {
+//            event->acceptProposedAction();
+//        }
+//    } else if (event->mimeData()->hasText()) {
+//        event->acceptProposedAction();
+//    } else {
+//        event->ignore();
+//    }
+}
+
+void DragLabel::dropEvent(QDropEvent *event)
+{
+    event->ignore();
+
+//    if (event->mimeData()->hasFormat("application/x-fridgemagnet")) {
+//        const QMimeData *mime = event->mimeData();
+//        QByteArray itemData = mime->data("application/x-fridgemagnet");
+//        QDataStream dataStream(&itemData, QIODevice::ReadOnly);
+
+//        QString text;
+//        QPoint offset;
+//        dataStream >> text >> offset;
+//        DragLabel *newLabel = new DragLabel(text, this);
+//        newLabel->move(event->pos() - offset);
+//        newLabel->show();
+//        //newLabel->setAttribute(Qt::WA_DeleteOnClose);
+
+//        if (event->source() == this) {
+//            event->setDropAction(Qt::MoveAction);
+//            event->accept();
+//        } else {
+//            event->acceptProposedAction();
+//        }
+//    } else if (event->mimeData()->hasText()) {
+//        QStringList pieces = event->mimeData()->text().split(QRegExp("\\s+"),
+//                             QString::SkipEmptyParts);
+//        QPoint position = event->pos();
+
+//        foreach (QString piece, pieces) {
+//            DragLabel *newLabel = new DragLabel(piece, this);
+//            newLabel->move(position);
+//            newLabel->show();
+//           // newLabel->setAttribute(Qt::WA_DeleteOnClose);
+
+//            position += QPoint(newLabel->width(), 0);
+//        }
+
+//        event->acceptProposedAction();
+//    } else {
+//        event->ignore();
+//    }
+}
+
+void DragLabel::mousePressEvent(QMouseEvent *event)
+{
+    event->ignore();
+
+//    DragLabel *child = static_cast<DragLabel*>(childAt(event->pos()));
+////    if (!child)
+////    {qDebug()<<"ragLabel::mousePressEvent::DragLabelnochild";return;
+////}else qDebug()<<child->text();
+//   // qDebug()<<event->pos();
+//    QPoint hotSpot = event->pos();// - child->pos();
+
+//    QByteArray itemData;
+//    QDataStream dataStream(&itemData, QIODevice::WriteOnly);
+//    dataStream << this->labelText() << QPoint(hotSpot);
+
+//    QMimeData *mimeData = new QMimeData;
+//    mimeData->setData("application/x-fridgemagnet", itemData);
+//    //mimeData->setText(child->labelText());
+//mimeData->setColorData(QColor(Qt::black));
+//    QDrag *drag = new QDrag(this);
+//    drag->setMimeData(mimeData);
+//   // drag->setPixmap(*child->pixmap());
+//    drag->setHotSpot(hotSpot);
+
+//   // child->hide();
+
+//    if (drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction) == Qt::MoveAction)
+//       {} //child->close();
+//    else
+//        {
+//        }//child->show();
+}
+
+QString DragLabel::labelText() const
+{
+    return m_labelText;
+}

+ 27 - 0
draglabel.h

@@ -0,0 +1,27 @@
+#ifndef DRAGLABEL_H
+#define DRAGLABEL_H
+#include <QLabel>
+#include <QTableWidgetItem>
+
+
+class QDragEnterEvent;
+class QDragMoveEvent;
+class QFrame;
+
+class DragLabel : public QTableWidgetItem
+{
+public:
+    DragLabel(const QString &text, QTableWidgetItem *parent=NULL);
+    QString labelText() const;
+     QLinearGradient gradient;
+protected:
+
+    void dragEnterEvent(QDragEnterEvent *event);
+    void dragMoveEvent(QDragMoveEvent *event);
+    void dropEvent(QDropEvent *event);
+    void mousePressEvent(QMouseEvent *event);
+private:
+    QString m_labelText;
+};
+
+#endif // DRAGLABEL_H

+ 215 - 0
files/bubbles.svg

@@ -0,0 +1,215 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg width="20cm" height="15cm" viewBox="0 0 800 600"
+    xmlns="http://www.w3.org/2000/svg"
+    xmlns:xlink="http://www.w3.org/1999/xlink/"
+    baseProfile="tiny" version="1.2">
+  <title>Spheres</title>
+  <desc>Semi-transparent bubbles on a colored background.</desc>
+    <defs>
+      <!-- Create radial gradients for each bubble. -->
+      <radialGradient id="blueBubble" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="-50">
+        <stop offset="0%" stop-color="white" stop-opacity="1" />
+        <stop offset="25%" stop-color="#cdcdff" stop-opacity=".65" />
+        <stop offset="100%" stop-color="#cdaacd" stop-opacity=".75" />
+      </radialGradient>
+      <radialGradient id="redBubble" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="-50">
+        <stop offset="0%" stop-color="white" stop-opacity="1" />
+        <stop offset="25%" stop-color="#ffcdcd" stop-opacity=".65" />
+        <stop offset="100%" stop-color="#bbbb99" stop-opacity=".75" />
+      </radialGradient>
+      <radialGradient id="greenBubble" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="-50">
+        <stop offset="0%" stop-color="white" stop-opacity="1" />
+        <stop offset="25%" stop-color="#cdffcd" stop-opacity=".65" />
+        <stop offset="100%" stop-color="#99aaaa" stop-opacity=".75" />
+      </radialGradient>
+      <radialGradient id="yellowBubble" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="-50">
+        <stop offset="0%" stop-color="white" stop-opacity="1" />
+        <stop offset="25%" stop-color="#ffffcd" stop-opacity=".65" />
+        <stop offset="100%" stop-color="#bbbbaa" stop-opacity=".75" />
+      </radialGradient>
+      <radialGradient id="background" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="400" fx="250" fy="250">
+        <stop offset="0%" stop-color="#ffffee" />
+        <stop offset="100%" stop-color="#ccccaa" />
+      </radialGradient>
+      <linearGradient id="surface" gradientUnits="userSpaceOnUse"
+                      x1="-100" y1="200" x2="400" y2="200">
+        <stop offset="0%" stop-color="#ffffcc" />
+        <stop offset="100%" stop-color="#bbbb88" />
+      </linearGradient>
+
+      <!-- Create radial gradients for each circle to make them look like
+           spheres. -->
+      <radialGradient id="blueSphere" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="-50">
+        <stop offset="0%" stop-color="white" />
+        <stop offset="75%" stop-color="blue" />
+        <stop offset="100%" stop-color="#222244" />
+      </radialGradient>
+      <radialGradient id="redSphere" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="-50">
+        <stop offset="0%" stop-color="white" />
+        <stop offset="75%" stop-color="red" />
+        <stop offset="100%" stop-color="#442222" />
+      </radialGradient>
+      <radialGradient id="greenSphere" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="-50">
+        <stop offset="0%" stop-color="white" />
+        <stop offset="75%" stop-color="green" />
+        <stop offset="100%" stop-color="#113311" />
+      </radialGradient>
+      <radialGradient id="yellowSphere" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="-50">
+        <stop offset="0%" stop-color="white" />
+        <stop offset="75%" stop-color="yellow" />
+        <stop offset="100%" stop-color="#444422" />
+      </radialGradient>
+      <radialGradient id="shadowGrad" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="50">
+        <stop offset="0%" stop-color="black" stop-opacity="1.0" />
+        <stop offset="100%" stop-color="black" stop-opacity="0.0" />
+      </radialGradient>
+
+      <!-- Define a shadow for each sphere. -->
+      <circle id="shadow" fill="url(#shadowGrad)" cx="0" cy="0" r="100" />
+      <g id="bubble">
+        <circle fill="black" cx="0" cy="0" r="50" />
+        <circle fill="#a6ce39" cx="0" cy="0" r="33" />
+        <path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10
+                              L -11,22 L -1,12 Z" />
+        <circle cx="0" cy="0" r="100" />
+      </g>
+    </defs>
+  <g>
+    <rect fill="url(#background)" x="0" y="0" width="800" height="600" />
+  </g>
+
+  <g transform="translate(200,700)">
+    <use xlink:href="#bubble" fill="url(#blueBubble)" />
+    <animateTransform attributeName="transform" type="translate" additive="sum"
+        values="0,0; 0,-800" begin="1s" dur="10s" fill="freeze" repeatCount="indefinite" />
+  </g>
+  <g transform="translate(315,700)">
+    <g transform="scale(0.5,0.5)">
+      <use xlink:href="#bubble" fill="url(#redBubble)" />
+    </g>
+    <animateTransform attributeName="transform" type="translate" additive="sum"
+        values="0,0; 0,-800" begin="3s" dur="7s" fill="freeze" repeatCount="indefinite" />
+  </g>
+  <g transform="translate(80,700)">
+    <g transform="scale(0.65,0.65)">
+      <use xlink:href="#bubble" fill="url(#greenBubble)" />
+    </g>
+    <animateTransform attributeName="transform" type="translate" additive="sum"
+        values="0,0; 0,-800" begin="5s" dur="9s" fill="freeze" repeatCount="indefinite" />
+  </g>
+  <g transform="translate(255,700)">
+    <g transform="scale(0.3,0.3)">
+      <use xlink:href="#bubble" fill="url(#yellowBubble)" />
+    </g>
+    <animateTransform attributeName="transform" type="translate" additive="sum"
+        values="0,0; 0,-800" begin="2s" dur="6s" fill="freeze" repeatCount="indefinite" />
+  </g>
+  <g transform="translate(565,700)">
+    <g transform="scale(0.4,0.4)">
+      <use xlink:href="#bubble" fill="url(#blueBubble)" />
+    </g>
+    <animateTransform attributeName="transform" type="translate" additive="sum"
+        values="0,0; 0,-800" begin="4s" dur="8s" fill="freeze" repeatCount="indefinite" />
+  </g>
+  <g transform="translate(715,700)">
+    <g transform="scale(0.6,0.6)">
+      <use xlink:href="#bubble" fill="url(#redBubble)" />
+    </g>
+    <animateTransform attributeName="transform" type="translate" additive="sum"
+        values="0,0; 0,-800" begin="1s" dur="4s" fill="freeze" repeatCount="indefinite" />
+  </g>
+  <g transform="translate(645,700)">
+    <g transform="scale(0.375,0.375)">
+      <use xlink:href="#bubble" fill="url(#greenBubble)" />
+    </g>
+    <animateTransform attributeName="transform" type="translate" additive="sum"
+        values="0,0; 0,-800" begin="0s" dur="11s" fill="freeze" repeatCount="indefinite" />
+  </g>
+  <g transform="translate(555,700)">
+    <g transform="scale(0.9,0.9)">
+      <use xlink:href="#bubble" fill="url(#yellowBubble)" />
+    </g>
+    <animateTransform attributeName="transform" type="translate" additive="sum"
+        values="0,0; 0,-800" begin="3s" dur="7.5s" fill="freeze" repeatCount="indefinite" />
+  </g>
+
+  <g transform="translate(360,700)">
+    <g transform="scale(0.5,0.5)">
+      <use xlink:href="#bubble" fill="url(#blueBubble)" />
+    </g>
+    <animateTransform attributeName="transform" type="translate" additive="sum"
+        values="0,0; 0,-800" begin="3s" dur="6s" fill="freeze" repeatCount="indefinite" />
+  </g>
+  <g transform="translate(215,700)">
+    <g transform="scale(0.45,0.45)">
+      <use xlink:href="#bubble" fill="url(#redBubble)" />
+    </g>
+    <animateTransform attributeName="transform" type="translate" additive="sum"
+        values="0,0; 0,-800" begin="5.5s" dur="7s" fill="freeze" repeatCount="indefinite" />
+  </g>
+  <g transform="translate(420,700)">
+    <g transform="scale(0.75,0.75)">
+      <use xlink:href="#bubble" fill="url(#greenBubble)" />
+    </g>
+    <animateTransform attributeName="transform" type="translate" additive="sum"
+        values="0,0; 0,-800" begin="1s" dur="9s" fill="freeze" repeatCount="indefinite" />
+  </g>
+  <g transform="translate(815,700)">
+    <g transform="scale(0.6,0.6)">
+      <use xlink:href="#bubble" fill="url(#yellowBubble)" />
+    </g>
+    <animateTransform attributeName="transform" type="translate" additive="sum"
+        values="0,0; 0,-800" begin="2s" dur="9.5s" fill="freeze" repeatCount="indefinite" />
+  </g>
+
+  <g transform="translate(225,375)" >
+    <g transform="scale(1.0,0.5)" >
+      <path d="M 0 0 L 350 0 L 450 450 L -100 450 z"
+            fill="url(#surface)" stroke="none" />
+    </g>
+  </g>
+    <g transform="translate(200,0)" >
+    <g transform="translate(200,490) scale(2.0,1.0) rotate(45)" >
+      <rect fill="#a6ce39" x="-69" y="-69" width="138" height="138" />
+      <circle fill="black" cx="0" cy="0" r="50" />
+      <circle fill="#a6ce39" cx="0" cy="0" r="33" />
+      <path fill="black" d="M 37,50 L 50,37 L 12,-1 L 22,-11 L 10,-24 L -24,10
+                            L -11,22 L -1,12 Z" />
+      <animateTransform attributeName="transform"  type="rotate" additive="sum" values="0; 360"
+	         begin="0s" dur="10s" fill="freeze" repeatCount="indefinite" />
+    </g>
+    <g transform="translate(200,375)">
+      <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+      <circle fill="url(#blueSphere)" cx="0" cy="0" r="100" />
+    </g>
+    <g transform="translate(315,440)">
+      <g transform="scale(0.5,0.5)">
+        <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+        <circle fill="url(#redSphere)" cx="0" cy="0" r="100" />
+      </g>
+    </g>
+    <g transform="translate(80,475)">
+      <g transform="scale(0.65,0.65)">
+        <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+        <circle fill="url(#greenSphere)" cx="0" cy="0" r="100" />
+      </g>
+    </g>
+    <g transform="translate(255,525)">
+      <g transform="scale(0.3,0.3)">
+        <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+        <circle fill="url(#yellowSphere)" cx="0" cy="0" r="100" />
+      </g>
+    </g>
+  </g>
+</svg>

+ 77 - 0
files/cubic.svg

@@ -0,0 +1,77 @@
+<?xml version="1.0" standalone="no"?>
+<svg width="10cm" height="10cm" viewBox="0 0 1000 1000"
+     xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny">
+  <title>Example cubic02 - cubic Bezier commands in path data</title>
+  <desc>Picture showing examples of "C" and "S" commands,
+        along with annotations showing the control points
+        and end points</desc>
+
+  <rect fill="none" stroke="blue" stroke-width="1" x="1" y="1" width="998" height="998" />
+
+  <!-- Path 1 -->
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="100,200 100,100" />
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="400,100 400,200" />
+  <path fill="none" stroke="red" stroke-width="5" d="M100,200 C100,100 400,100 400,200" />
+  <circle fill="none" stroke="#888888" stroke-width="2" cx="100" cy="200" r="10" />
+  <circle fill="none" stroke="#888888" stroke-width="2" cx="400" cy="200" r="10" />
+  <circle class="CtlPoint" cx="100" cy="100" r="10" />
+  <circle class="CtlPoint" cx="400" cy="100" r="10" />
+  <text text-anchor="middle" font-size="22" font-family="Verdana" x="250" y="275">M100,200 C100,100 400,100 400,200</text>
+
+  <!-- Path 2 -->
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="100,500 25,400" />
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="475,400 400,500" />
+  <path fill="none" stroke="red" stroke-width="5" d="M100,500 C25,400 475,400 400,500" />
+  <circle fill="none" stroke="#888888" stroke-width="2" cx="100" cy="500" r="10" />
+  <circle fill="none" stroke="#888888" stroke-width="2" cx="400" cy="500" r="10" />
+  <circle fill="#888888" stroke="none" cx="25" cy="400" r="10" />
+  <circle fill="#888888" stroke="none" cx="475" cy="400" r="10" />
+  <text text-anchor="middle" font-size="22" font-family="Verdana" x="250" y="575">M100,500 C25,400 475,400 400,500</text>
+
+  <!-- Path 3 -->
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="100,800 175,700" />
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="325,700 400,800" />
+  <path fill="none" stroke="red" stroke-width="5" d="M100,800 C175,700 325,700 400,800" />
+  <circle fill="none" stroke="#888888" stroke-width="2" cx="100" cy="800" r="10" />
+  <circle fill="none" stroke="#888888" stroke-width="2" cx="400" cy="800" r="10" />
+  <circle fill="#888888" stroke="none" cx="175" cy="700" r="10" />
+  <circle fill="#888888" stroke="none" cx="325" cy="700" r="10" />
+  <text text-anchor="middle" font-size="22" font-family="Verdana" x="250" y="875">M100,800 C175,700 325,700 400,800</text>
+
+  <!-- Path 4 -->
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="600,200 675,100" />
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="975,100 900,200" />
+  <path fill="none" stroke="red" stroke-width="5" d="M600,200 C675,100 975,100 900,200" />
+  <circle fill="none" stroke="#888888" stroke-width="2" cx="600" cy="200" r="10" />
+  <circle fill="none" stroke="#888888" stroke-width="2" cx="900" cy="200" r="10" />
+  <circle fill="#888888" stroke="none" cx="675" cy="100" r="10" />
+  <circle fill="#888888" stroke="none" cx="975" cy="100" r="10" />
+  <text text-anchor="middle" font-size="22" font-family="Verdana" x="750" y="275">M600,200 C675,100 975,100 900,200</text>
+
+  <!-- Path 5 -->
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="600,500 600,350" />
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="900,650 900,500" />
+  <path fill="none" stroke="red" stroke-width="5" d="M600,500 C600,350 900,650 900,500" />
+  <circle fill="none" stroke="#888888" stroke-width="2" cx="600" cy="500" r="10" />
+  <circle fill="none" stroke="#888888" stroke-width="2" cx="900" cy="500" r="10" />
+  <circle fill="#888888" stroke="none" cx="600" cy="350" r="10" />
+  <circle fill="#888888" stroke="none" cx="900" cy="650" r="10" />
+  <text text-anchor="middle" font-size="22" font-family="Verdana" x="750" y="575">M600,500 C600,350 900,650 900,500</text>
+
+  <!-- Path 6 (C and S command) -->
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="600,800 625,700" />
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="725,700 750,800" />
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="750,800 775,900" />
+  <polyline fill="none" stroke="#888888" stroke-width="2" points="875,900 900,800" />
+  <path fill="none" stroke="red" stroke-width="5" d="M600,800 C625,700 725,700 750,800
+                                       S875,900 900,800" />
+  <circle fill="none" stroke="#888888" stroke-width="2" cx="600" cy="800" r="10" />
+  <circle fill="none" stroke="#888888" stroke-width="2" cx="750" cy="800" r="10" />
+  <circle fill="none" stroke="#888888" stroke-width="2" cx="900" cy="800" r="10" />
+  <circle fill="#888888" stroke="none" cx="625" cy="700" r="10" />
+  <circle fill="#888888" stroke="none" cx="725" cy="700" r="10" />
+  <circle fill="#888888" stroke="none" cx="875" cy="900" r="10" />
+  <circle fill="none" stroke="blue" stroke-width="4" cx="775" cy="900" r="9" />
+  <text text-anchor="middle" font-size="22" font-family="Verdana" x="750" y="945">M600,800 C625,700 725,700 750,800</text>
+  <text text-anchor="middle" font-size="22" font-family="Verdana" x="750" y="975">S875,900 900,800</text>
+</svg>

+ 72 - 0
files/spheres.svg

@@ -0,0 +1,72 @@
+<?xml version="1.0" standalone="no"?>
+<svg width="8cm" height="8cm" viewBox="0 0 400 400"
+    xmlns="http://www.w3.org/2000/svg"
+    xmlns:xlink="http://www.w3.org/1999/xlink/"
+    baseProfile="tiny" version="1.2">
+  <title>Spheres</title>
+  <desc>Gradient filled spheres with different colors.</desc>
+    <defs>
+      <!-- Create radial gradients for each circle to make them look like
+           spheres. -->
+      <radialGradient id="blueSphere" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="-50">
+        <stop offset="0%" stop-color="white" />
+        <stop offset="75%" stop-color="blue" />
+        <stop offset="100%" stop-color="#222244" />
+      </radialGradient>
+      <radialGradient id="redSphere" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="-50">
+        <stop offset="0%" stop-color="white" />
+        <stop offset="75%" stop-color="red" />
+        <stop offset="100%" stop-color="#442222" />
+      </radialGradient>
+      <radialGradient id="greenSphere" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="-50">
+        <stop offset="0%" stop-color="white" />
+        <stop offset="75%" stop-color="green" />
+        <stop offset="100%" stop-color="#113311" />
+      </radialGradient>
+      <radialGradient id="yellowSphere" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="-50">
+        <stop offset="0%" stop-color="white" />
+        <stop offset="75%" stop-color="yellow" />
+        <stop offset="100%" stop-color="#444422" />
+      </radialGradient>
+      <radialGradient id="shadowGrad" gradientUnits="userSpaceOnUse"
+                      cx="0" cy="0" r="100" fx="-50" fy="50">
+        <stop offset="0%" stop-color="black" stop-opacity="1.0" />
+        <stop offset="100%" stop-color="white" stop-opacity="0.0" />
+      </radialGradient>
+
+      <!-- Define a shadow for each sphere. -->
+      <circle id="shadow" fill="url(#shadowGrad)" cx="0" cy="0" r="100" />
+    </defs>
+  <g fill="#ffee99" stroke="none" >
+    <rect x="0" y="0" width="400" height="400" />
+  </g>
+  <g fill="white" stroke="none" >
+    <rect x="0" y="175" width="400" height="225" />
+  </g>
+  <g transform="translate(200,175)">
+    <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+    <circle fill="url(#blueSphere)" cx="0" cy="0" r="100" />
+  </g>
+  <g transform="translate(315,240)">
+    <g transform="scale(0.5,0.5)">
+      <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+      <circle fill="url(#redSphere)" cx="0" cy="0" r="100" />
+    </g>
+  </g>
+  <g transform="translate(80,275)">
+    <g transform="scale(0.65,0.65)">
+      <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+      <circle fill="url(#greenSphere)" cx="0" cy="0" r="100" />
+    </g>
+  </g>
+  <g transform="translate(255,325)">
+    <g transform="scale(0.3,0.3)">
+      <use xlink:href="#shadow" transform="translate(25,55) scale(1.0,0.5)" />
+      <circle fill="url(#yellowSphere)" cx="0" cy="0" r="100" />
+    </g>
+  </g>
+</svg>

+ 647 - 0
forme.cpp

@@ -0,0 +1,647 @@
+#include "forme.h"
+#include "selectsettingwindow.h"
+/*map:
+ * constructors
+ * copie makers
+ * herited fonctions
+ * fonctions
+ * getter/setters
+ * events
+ * destruction!!!
+ */
+
+
+
+void Forme::setcolor(QString color)
+{this->fillcolor.setNamedColor(color);
+    if(!this->fillcolor.isValid())
+    {
+        this->brush=Qt::NoBrush;
+
+
+      //  this->fillcolor(Qt::NoPen);
+    }
+    else{
+        this->brush=Qt::SolidPattern;
+        this->brush.setColor(this->fillcolor);
+    }
+this->update();}
+
+
+
+
+
+void Forme::setstrokewidth(QString width)
+{
+
+    if(width=="none")
+    {
+        this->pen.setStyle(Qt::NoPen);
+
+        //painter->setBrush(this->strokecolor);
+      //  painter->setPen(Qt::NoPen);
+    //    painter->setPen(QPen(this->strokecolor, 1));
+     //   painter->setPen(Qt::SolidLine);
+
+    }
+    else
+
+    {
+        this->pen.setStyle(Qt::SolidLine);
+    }
+}
+
+void Forme::setstrokecolor(QString color)
+{this->strokecolor.setNamedColor(color);
+    if(!this->strokecolor.isValid())
+    {
+        this->pen.setStyle(Qt::NoPen);
+
+        //painter->setBrush(this->strokecolor);
+      //  painter->setPen(Qt::NoPen);
+    //    painter->setPen(QPen(this->strokecolor, 1));
+     //   painter->setPen(Qt::SolidLine);
+
+    }
+    else
+
+    {
+        this->pen.setColor(this->strokecolor);
+        this->pen.setStyle(Qt::SolidLine);
+    }
+this->update();}
+
+/*****************constructors******************/
+
+
+
+Forme::Forme(QPointF origin, QGraphicsItem *parent):
+    QGraphicsItem(parent)
+{
+    //this->drpathsnmbr=0;
+    this->strokecolor= QColor(Qt::blue);
+    this->fillcolor=QColor(Qt::green);
+    setAcceptDrops(true);
+    this->setAcceptedMouseButtons(Qt::AllButtons);
+
+    this->pathsnmbr=0;
+    this->nodenumber=1;
+this->isrealdraw=true;
+    QStringList pathstringcomputedlist;
+    this->pathstringcomputedlist.append("break");
+    this->pathstringcomputedlist.append(QVariant(origin.x()).toString()+':'+QVariant(origin.y()).toString());
+
+    QStringList pathstringlist;// ("");
+    QList<drawPath> shape;
+    this->shape<<drawPath(origin);
+//    drawPath *shape[]={new drawPath(origin)};
+    // this->shape[pathsnmbr]=new drawPath(QPointF(x,y));
+    this->path= QPainterPath(origin);
+    this->lastpoint=origin;
+
+   //this->nodenumber++;
+    ///this->pathstringlist=NULL;
+    //this->setParent(parent);
+    //setCursor(Qt::OpenHandCursor);
+this->setZValue(0);
+   // this->setFlag(QGraphicsItem::ItemIsSelectable,true);
+ //   this->setFlag(QGraphicsItem::ItemIsMovable,true);
+    //   drawPath temp(currentPosition());
+    //         this->shape.append(temp);
+}
+
+
+
+//*****************copie makers******************//
+Forme& Forme::operator=(Forme const& sourcedecopie)
+
+{
+
+    this->lastpoint=sourcedecopie.lastpoint;
+    //QGraphicsItem(this);
+    std::cout<<"copiteur=!\n"<<std::endl;
+    // this->setSelected(sourcedecopie.isSelected());
+    int i=0;
+    QStringList pathstringcomputedlist(sourcedecopie.pathstringcomputedlist);
+    QStringList pathstringlist(sourcedecopie.pathstringlist);
+
+        this->shape=((sourcedecopie.shape));
+
+
+    this->path= QPainterPath(sourcedecopie.path);
+    this->pathsnmbr=sourcedecopie.pathsnmbr;
+    this->nodenumber=sourcedecopie.nodenumber;
+     this->setAcceptedMouseButtons(Qt::AllButtons);
+    this->setFlags(sourcedecopie.flags());
+    setAcceptDrops(true);
+    return  *this;
+
+}
+
+////hazardous copy constructor
+//Forme::Forme(const Forme &sourcedecopie):QGraphicsItem()
+//{
+//    //wtf    QPainterPath path(arg.path);
+//    int i;
+//    std::cout<<"copiteur&!\n"<<std::endl;
+//    this->lastpoint=sourcedecopie.lastpoint;
+
+//         this->shape=sourcedecopie.shape;
+
+//     // this->shape=sourcedecopie.shape;
+
+//    this->pathsnmbr=sourcedecopie.pathsnmbr;
+//    this->nodenumber=sourcedecopie.nodenumber;
+//    this->path= QPainterPath(sourcedecopie.path);
+// //   setCursor(Qt::OpenHandCursor);
+//    std::cout<<"copiteur de fonction!\n"<<std::endl;
+//    this->setFlags(sourcedecopie.flags());
+//    this->setSelected(sourcedecopie.isSelected());
+//    QStringList pathstringcomputedlist(sourcedecopie.pathstringcomputedlist);
+//    QStringList pathstringlist(sourcedecopie.pathstringlist);
+
+//}
+
+//*****************************"herited"**************//
+
+
+void Forme::lineTo(QPointF target_node)
+{
+
+    this->lineto(target_node.x(),target_node.y());
+    //  this->pathstringcomputedlist.append(QVariant(target_node.x()).toString()+':'+QVariant(target_node.y()).toString());
+
+}
+
+
+void Forme::paint(QPainter *painter,
+                      const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+    Q_UNUSED(option);
+    Q_UNUSED(widget);
+  //  std::cout<<"Forme painteur!\n"<<std::endl;
+
+//    if(isrealdraw)
+//{
+//        painter->setBrush(Qt::Dense3Pattern);
+        painter->setBrush(this->brush);
+
+        //painter->setBrush(this->strokecolor);
+  painter->setPen(this->pen);
+//        painter->setPen(QPen(this->strokecolor, 1));
+//        painter->setPen(Qt::SolidLine);
+//    }
+//    else
+//        painter->setPen(QPen(Qt::red, 1));
+
+
+    // painter->scale(-1,-1);
+    painter->drawPath(this->path);
+    //painter->scale(-1,-1);
+
+    //this->setParent(widget);
+    //painter->drawRoundedRect(boundingRect(), 50, 50, Qt::RelativeSize);
+    //ca cest maarant
+    bool visu=false;
+    int i;
+    if(visu)
+    {
+        for (i=0;i<this->path.elementCount();i++)
+
+        {
+            if(i==0)
+            {        painter->setPen(QPen(Qt::green, 1));
+                painter->setBrush(QColor(Qt::green));
+
+                painter->drawText(path.elementAt(i).x-5,path.elementAt(i).y-5,"Start");
+                painter->drawEllipse(path.elementAt(i).x-2,path.elementAt(i).y-2,4,4);
+            }
+            else if (i==this->path.elementCount()-1)
+            {
+                painter->setBrush(QColor(Qt::yellow));
+
+                painter->setPen(QPen(Qt::yellow, 1));
+                painter->drawText(path.elementAt(i).x-2,path.elementAt(i).y-2,"End");
+                painter->drawEllipse(path.elementAt(i).x-2,path.elementAt(i).y-2,4,4);
+            }
+            else {
+                painter->drawEllipse(path.elementAt(i).x-2,path.elementAt(i).y-2,4,4);
+
+            }
+        }
+
+    }}
+
+QRectF Forme::boundingRect() const
+{    return this->path.boundingRect();
+
+}
+
+QPointF Forme:: currentPosition(void)
+{
+    return this->path.currentPosition();
+}
+/*************************************fonctions***************************************************/
+void Forme:: ping(void) const
+{
+    // qDebug("pingselectdrawpath");
+    std::cout<<this->getnode_number()<<"nodes."<<this->getpath_number()<<"subpaths:"<<std::endl;
+
+}
+
+void Forme:: pingname(void) const
+{
+    std::cout<<"Forme(pingname)"<<std::endl;
+
+
+}
+void Forme::lineto(float x, float  y)
+{
+    //   std::cout<<"Forme::lineto(coords="<<QVariant(lastpoint.x()).toString().toStdString()+QVariant(lastpoint.y()).toString().toStdString()<<")"<<std::endl;
+     //std::cout<<"Forme::lineto(coords="<<QVariant(x).toString()<<':'<<QVariant(y).toString()<<")"<<std::endl;
+
+//   std::cout<<"Forme::lineto(coords="<<QVariant(lastpoint.x()).toString().toStdString()+QVariant(lastpoint.y()).toString().toStdString()<<")"<<std::endl;
+    this->pathstringcomputedlist.append(QVariant(x).toString()+':'+QVariant(y).toString());
+//std::cout<<pathstringcomputedlist.join("").toStdString();
+    if( this->nodenumber==0)
+    {
+      //  std::cout<<"Forme:lineto:butnodenmber=0!"<<std::endl;
+
+        //QStringList pathstringcomputedlist;;
+        //QStringList pathstringlist ("");
+        //pathstringcomputedlist<<"break";
+        this->lastpoint=QPointF(x,y);
+        this->path.lineTo(QPointF(x,y));
+
+        //this->pathstringcomputedlist.append(QVariant(x).toString()+':'+QVariant(y).toString());
+
+    }
+    else
+    {
+
+        if(nodenumber%2)
+        {
+
+            //1,3,5nodes
+        //    std::cout<<"Forme:lineto:impair!"<<nodenumber<<std::endl;
+
+
+            this->shape<<drawPath(lastpoint);
+            this->shape.last().setrealdraw(this->isrealdraw);
+
+            this->shape.last().lineTo(QPointF(x,y));
+            this->nodenumber++;
+            this->pathsnmbr++;
+
+            this->path.lineTo(QPointF(x,y));
+            this->lastpoint=QPointF(x,y);
+
+        }else
+        {
+      //      std::cout<<"Forme:lineto:pair!"<<nodenumber<<std::endl;
+
+            //2,4,6nodes
+
+
+            this->nodenumber++;
+          this->shape<<drawPath(lastpoint);
+            this->shape.last().setrealdraw(this->isrealdraw);
+
+          this->shape.last().lineTo(QPointF(x,y));
+
+          // this->shape<<drawPath(QPointF(x,y));
+
+
+           this-> pathsnmbr++;
+
+           this-> lastpoint=QPointF(x,y);
+
+            this->path.lineTo(QPointF(x,y));
+        }
+
+
+
+    }
+}
+/*
+void Forme::breakpath(QPointF dest)
+{
+    //this->tempbroke=true;
+    //  this->nodenumber=0;
+    // this->pathsnmbr++;
+
+    //suspect!!!
+    std::cout<<"Forme(breakpath)"<<std::endl;
+    //  this->shape[pathsnmbr]=new drawPath(this->path.currentPosition(););
+
+    //    this->path.moveTo(dest);
+    //his->shape[pathsnmbr]->lineTo(this->path.currentPosition());
+    this->shape[pathsnmbr]->moveTo(dest);
+
+    this->pathstringcomputedlist.append("break");
+
+    this->pathstringcomputedlist.append(QVariant(dest.x()).toString()+':'+QVariant(dest.y()).toString());
+}*/
+
+//***************************************setters and getters************************************//
+//***************************************setters and getters************************************//
+//***************************************setters and getters************************************//
+QPainterPath Forme::getpath() const{
+    return this->path;
+}
+QList<drawPath>  Forme::getshape() {
+    return (this->shape);
+}
+
+int Forme::getnode_number() const{
+    return this->nodenumber;
+}
+// :/
+int Forme::getpath_number() const{
+    return this->pathsnmbr;
+
+    // :/
+}
+
+
+QStringList Forme::getstring(void) const
+
+{
+    return this->pathstringlist;
+}
+
+QStringList Forme::getcomputedstring(void) const
+
+{
+    return this->pathstringcomputedlist;
+}
+
+void Forme::setstring(QStringList toset)
+
+{
+    this->pathstringlist=toset;
+}
+
+
+
+//********************************************events*****************************************//
+//********************************************events*****************************************//
+//********************************************events*****************************************//
+
+
+void Forme::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
+{
+    if (event->mimeData()->hasColor()) {
+        event->setAccepted(true);
+
+        //dragOver = true;
+        update();
+    } else {
+        event->setAccepted(false);
+    }
+    std::cout<<"Forme(dragEnterEvent)"<<std::endl;
+
+}
+void Forme::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
+{
+    Q_UNUSED(event);
+    std::cout<<"Forme(dragLeaveEvent)"<<std::endl;
+
+    //dragOver = false;
+    update();
+}
+void Forme::dropEvent(QGraphicsSceneDragDropEvent *event)
+{
+    //dragOver = false;
+    if (event->mimeData()->hasColor())
+        update();
+    std::cout<<"Forme(dropEvent)"<<std::endl;
+    //this->fillcolor = qvariant_cast<QColor>(event->mimeData()->colorData());
+    this->update();
+}
+
+
+void Forme::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+    //switch()
+//    event->accept();
+    qDebug()<<"forme::mousePressEvent";
+    selectsettingwindow *truc=new selectsettingwindow();
+    truc->show();
+//emit(formeclicked());
+ //   std::cout<<"forme mousePressEvent"<<std::endl;
+//   // setCursor(Qt::ClosedHandCursor);
+//    if(this->isSelected())
+//    {
+//        this->setSelected(false);
+//        //this->setActive(false);
+//       this->setGraphicsEffect(0);
+//    }
+//    else{
+//        this->setSelected(true);
+//        //this->setActive(true);
+
+//        QGraphicsDropShadowEffect* green_colorize=new QGraphicsDropShadowEffect();
+//         green_colorize->setColor(QColor().green());
+//        this->setGraphicsEffect(green_colorize);
+//    }
+  event->accept();
+
+
+
+}
+
+
+void Forme::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+    //setCursor(Qt::OpenHandCursor);
+    event->accept();
+    qDebug()<<"forme::mouserelevent";
+
+    //this->scene()
+}
+
+
+
+//accesseur: set true if param =true
+void Forme::setrealdraw(bool param)
+{
+    isrealdraw=param;
+    //foreachsubpath: setreal or not;
+}
+
+//june2017
+
+
+
+
+//Forme::~Forme()
+
+
+//{
+    //delete this->shape;
+//}
+
+//blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
+//blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
+//blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
+//blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
+//blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
+//blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
+//blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
+//blablablablablablablablablablablablablablablablablablablablablablablablablablablabla
+//to delete
+//Forme::Forme(QGraphicsItem *parent):
+//    QGraphicsItem(parent)
+//{
+//    path= QPainterPath();
+//    this->pathsnmbr=-1;
+    //this->drpathsnmbr=0;
+    //   this->path=QPainterPath();
+
+//    this->nodenumber=0;
+    //QString name=("notset");
+//    std::cout<<"Forme(0);"<<std::endl;
+
+
+//    QList<drawPath> shape;
+
+
+
+
+
+//    QStringList pathstringcomputedlist;
+//    pathstringcomputedlist<<"break";
+//    QStringList pathstringlist ("");
+    //  this->setAcceptedMouseButtons(Qt::AllButtons);
+    //setAcceptedMouseButtons(Qt::LeftButton);
+    //this->tempbroke=false;
+    // setAcceptDrops(true);
+    //this->setParent(parent);
+//    this->setFlag(QGraphicsItem::ItemIsSelectable,true);
+//    this->setFlag(QGraphicsItem::ItemIsMovable,true);
+//    setCursor(Qt::OpenHandCursor);
+//    this->lastpoint=QPointF(-999,-999);
+//}
+
+/*
+void Forme::add_shape(QStringList *toadd)
+{
+    int i=0,point_count=toadd->size();
+
+    QStringList list1 = toadd->at(0).split(":", QString::SkipEmptyParts);
+    QList<drawPath> *shape;
+//ontrace le prmuer trait
+//!!!
+//!
+//!
+//!
+//!
+//! this->shape[0]= drawPath(QPointF(list1.at(0).toFloat(),list1.at(1).toFloat()));
+
+
+void Forme::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+    std::cout<<"Forme(mousemoveEvent)"<<std::endl;
+   event->ignore();
+
+setCursor(Qt::OpenHandCursor);
+}
+
+
+    //QStringList list2 = toadd->at(i+1).split(":", QString::SkipEmptyParts);
+    for (i;i < point_count-1; ++i)
+    {
+        pathsnmbr++;
+        std::cout<<i<<".275addshpe(stringlist):Forme."<<list1.at(0).toFloat()<<":"<<list1.at(1).toFloat()<<std::endl;
+
+        list1 = toadd->at(i).split(":", QString::SkipEmptyParts);
+
+        //!\//pseudo worked: added multiple ligne with a very rounded value :p
+       // remeber!pth.lineTo(cl.toDouble( list1.at(0)),cl.toDouble( list1.at(1)));
+
+     //!!!   this->lineTo(list1.at(0).toFloat(),list1.at(1).toFloat());
+
+    }
+
+    QPen visiblepen(Qt::blue, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+    QPen normalpen(Qt::blue, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+
+//Qpath.setPen(pen);
+  //  Qpath.setPath(pth);
+    //this->sceneConteneur->addPath(pth_end,redpen);
+
+
+    drawPath pth_start;
+
+switch(this->startpath_mode)
+{
+    case topright:
+        this-> pth_start=new drawPath(this->path.boundingRect().topRight());
+        this->pth_start->lineTo(QPointF(list1.at(0).toFloat(),list1.at(1).toFloat()));
+        pth_start.is_realdraw=false;
+        break;
+
+    case bottomright:
+    //pth_start= drawPath(this->path.boundingRect().bottomRight());
+    this-> pth_start=new drawPath(this->path.boundingRect().bottomRight());
+
+    pth_start.lineTo(QPointF(list1.at(0).toFloat(),list1.at(1).toFloat()));
+    pth_start.is_realdraw=false;
+break;
+case topleft:
+    //pth_start= drawPath(this->path.boundingRect().topLeft());
+    this-> pth_start=new drawPath(this->path.boundingRect().topLeft());
+
+    pth_start.lineTo(QPointF(list1.at(0).toFloat(),list1.at(1).toFloat()));
+    pth_start.is_realdraw=false;
+
+break;
+case bottomleft:
+    this-> pth_start=new drawPath(this->path.boundingRect().bottomLeft());
+
+    drawPath pth_start(this->path.boundingRect().bottomLeft());
+    pth_start.lineTo(QPointF(list1.at(0).toFloat(),list1.at(1).toFloat()));
+    pth_start.is_realdraw=false;
+
+break;
+    defaut:break;
+}
+
+    drawPath pth_end(this->currentPosition());
+    switch(this->endpath_mode)
+    {
+case topright:pth_end.lineTo(this->path.boundingRect().topRight());
+break;
+    case bottomright:pth_end.lineTo(this->path.boundingRect().bottomRight());
+        pth_end.is_realdraw=false;
+
+    break;
+    case topleft:pth_end.lineTo(this->path.boundingRect().topLeft());
+
+    break;
+    case bottomleft:pth_end.lineTo(this->path.boundingRect().bottomLeft());
+
+    break;
+
+    }
+ }
+    //   this->sceneVue->fitInView(this->sceneConteneur->addPath(pth,visiblepen));
+*/
+
+
+//hazardous copy constructor
+
+
+/*
+     //!??
+    Forme::Forme(const QGraphicsItem &arg)
+    {
+    //wtf    QPainterPath path(arg.path);
+        int i=0;
+
+        for(i;i<arg.)
+        this->shape=arg.shape;
+        this->pathsnmbr=arg.pthnmb;
+    }
+    */

+ 100 - 0
forme.h

@@ -0,0 +1,100 @@
+#ifndef Forme_H
+#define Forme_H
+
+#include "chemin.h"
+
+#include <QList>
+//#include <QtWidgets/QtWidgets>
+class Forme: public QGraphicsItem
+{
+public:
+    //Forme(QGraphicsItem *parent=NULL);
+
+    void lineto(float x, float  y);
+
+    void lineTo(QPointF target_node);
+    Forme(QPointF origin, QGraphicsItem *parent=NULL);
+   // Forme(const Forme&);
+    Forme& operator=(Forme const&  sourcedecopie);
+
+    void setcolor(QString fcolor);
+    void setstrokecolor(QString scolor);
+    void setstrokewidth(QString width);
+    //~Forme();
+    QList<drawPath> getshape() ;
+    void setrealdraw(bool);
+
+signals:
+    void formeclicked(void) const;
+void ping(void) const;
+private:
+QStringList pathstringlist;
+bool tempbroke;
+//void breakpath(QPointF dest);
+//int     drpathsnmbr;
+
+QStringList pathstringcomputedlist;
+
+QStringList getcomputedstring(void) const;
+QStringList getstring(void) const;
+void  setstring(QStringList toset);
+
+QColor strokecolor;
+
+QColor fillcolor;
+    // Forme();
+
+ // Forme(QGraphicsItem *parent);
+//? Forme(const QGraphicsObject&);
+    //public methods:
+    QRectF boundingRect() const;
+
+    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+               QWidget *widget);
+
+    void pingname(void) const;
+
+    QPainterPath getpath() const;
+
+    int getnode_number() const;
+    int getpath_number() const;
+  //  void add_shape(QStringList *toadd);
+
+    //////////////////////////////////////////////////////////////////////////////
+    //////////////////////////////////////////////////////////////////////////////
+
+    QPointF  lastpoint;
+    bool isrealdraw;
+    QPen pen;
+    QBrush brush;
+//QString name;
+    enum startendpath_mode{none,topleft,bottomleft,topright,bottomright};
+    startendpath_mode endpath_mode;
+    startendpath_mode startpath_mode;
+//drawPath *pth_start;
+//drawPath *pth_end;
+bool visiblestart;
+bool visibleend;
+    QPainterPath path;
+    QPointF currentPosition(void);
+int pathsnmbr;
+int nodenumber;
+QList<drawPath> shape;
+
+protected:
+void mousePressEvent(QGraphicsSceneMouseEvent *event);
+//void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
+void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
+void dropEvent(QGraphicsSceneDragDropEvent *event);
+/* void dragEnterEvent(QDragEnterEvent *event);
+    void dragLeaveEvent(QDragLeaveEvent *event);
+    void dragMoveEvent(QDragMoveEvent *event);
+    void dropEvent(QDropEvent *event);
+    void mousePressEvent(QMouseEvent *event);
+    */
+
+};
+
+#endif // Forme_H

+ 62 - 0
main.cpp

@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+**     of its contributors may be used to endorse or promote products derived
+**     from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QString>
+#ifndef QT_NO_OPENGL
+#include <QGLFormat>
+#endif
+
+#include "mainwindow.h"
+
+int main(int argc, char **argv)
+{
+    Q_INIT_RESOURCE(svgviewer);
+
+    QApplication app(argc, argv);
+
+    MainWindow window;
+    if (argc == 2)
+        window.openFile(argv[1]);
+    else
+        window.openFile(":/files/bubbles.svg");
+    window.show();
+    return app.exec();
+}

+ 221 - 0
mainwindow.cpp

@@ -0,0 +1,221 @@
+
+#include "mainwindow.h"
+
+#include <QtWidgets>
+
+#include "svgview.h"
+
+MainWindow::MainWindow()
+    : QMainWindow()
+    , m_view(new SvgView)
+{
+//les menus:
+    //fichier (ui status ok)
+    //logic status:
+    //should opensettingsof each sorts (machine/cut/app)
+    //already loading 30% svgs
+    //should be able to  rasterize jpg and png
+
+
+
+    QMenu *fileMenu = new QMenu(tr("&File"), this);
+    QAction *openAction = fileMenu->addAction(tr("&Open..."));
+    openAction->setShortcut(QKeySequence(tr("Ctrl+O")));
+
+    QAction *opentestAction = fileMenu->addAction(tr("&Opentestfile..."));
+    openAction->setShortcut(QKeySequence(tr("Ctrl+T")));
+
+    QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+    quitAction->setShortcuts(QKeySequence::Quit);
+    menuBar()->addMenu(fileMenu);
+
+
+
+
+
+
+
+//to do setting menu
+    //(wip:ui)
+    //(todo:logic)
+    QMenu *settingsMenu = new QMenu(tr("&Settings"), this);
+     //popup the machine parameter window
+    QAction *setmachineAction = settingsMenu->addAction(tr("&Machine Settings"));
+    openAction->setShortcut(QKeySequence(tr("Ctrl+M")));
+    //popup the engrave/cut parameter window
+    QAction *setparametersAction = settingsMenu->addAction(tr("&Cut/Engrave Settings"));
+    openAction->setShortcut(QKeySequence(tr("Ctrl+G")));
+
+
+    //popup the engrave/cut parameter window
+    QAction *setapplicationsAction = settingsMenu->addAction(tr("&Application Settings"));
+    openAction->setShortcut(QKeySequence(tr("Ctrl+A")));
+    menuBar()->addMenu(settingsMenu);
+
+
+
+
+
+
+
+
+
+    //vue
+
+    QMenu *viewMenu = new QMenu(tr("&View"), this);
+    m_backgroundAction = viewMenu->addAction(tr("&Background"));
+    m_backgroundAction->setEnabled(false);
+    m_backgroundAction->setCheckable(true);
+    m_backgroundAction->setChecked(false);
+    connect(m_backgroundAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewBackground(bool)));
+
+    m_outlineAction = viewMenu->addAction(tr("Ou&tline"));
+    m_outlineAction->setEnabled(false);
+    m_outlineAction->setCheckable(true);
+    m_outlineAction->setChecked(true);
+    connect(m_outlineAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewOutline(bool)));
+
+    menuBar()->addMenu(viewMenu);
+    //render menu
+
+    QMenu *rendererMenu = new QMenu(tr("&Renderer"), this);
+    m_nativeAction = rendererMenu->addAction(tr("&Native"));
+    m_nativeAction->setCheckable(true);
+    m_nativeAction->setChecked(true);
+#ifndef QT_NO_OPENGL
+    m_glAction = rendererMenu->addAction(tr("Open&GL"));
+    m_glAction->setCheckable(true);
+#endif
+    m_imageAction = rendererMenu->addAction(tr("&Image"));
+    m_imageAction->setCheckable(true);
+
+#ifndef QT_NO_OPENGL
+    rendererMenu->addSeparator();
+    m_highQualityAntialiasingAction = rendererMenu->addAction(tr("&High Quality Antialiasing"));
+    m_highQualityAntialiasingAction->setEnabled(false);
+    m_highQualityAntialiasingAction->setCheckable(true);
+    m_highQualityAntialiasingAction->setChecked(false);
+    connect(m_highQualityAntialiasingAction, SIGNAL(toggled(bool)), m_view, SLOT(setHighQualityAntialiasing(bool)));
+#endif
+
+    QActionGroup *rendererGroup = new QActionGroup(this);
+    rendererGroup->addAction(m_nativeAction);
+#ifndef QT_NO_OPENGL
+    rendererGroup->addAction(m_glAction);
+#endif
+    rendererGroup->addAction(m_imageAction);
+
+    menuBar()->addMenu(rendererMenu);
+
+    connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
+    connect(opentestAction, SIGNAL(triggered()), this, SLOT(opentestFile()));
+    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+    connect(rendererGroup, SIGNAL(triggered(QAction*)),
+            this, SLOT(setRenderer(QAction*)));
+
+
+
+//add_dock();
+this->setMouseTracking (true);
+
+    setCentralWidget(m_view);
+    setWindowTitle(tr("SVG Viewer"));
+}
+
+
+
+
+
+void MainWindow::openFile(const QString &path)
+{
+    QString fileName;
+    if (path.isNull())
+    {fileName="/home/tuxun/Bureau/matricereglagelaser.svg";
+     /*   fileName = QFileDialog::getOpenFileName(this, tr("Open SVG File"),
+                m_currentPath, "SVG files (*.svg *.svgz *.svg.gz)");*/}
+
+    else
+        fileName = path;
+
+    if (!fileName.isEmpty()) {
+        QFile file(fileName);
+        if (!file.exists()) {
+            QMessageBox::critical(this, tr("Open SVG File"),
+                           QString("Could not open file '%1'.").arg(fileName));
+
+            m_outlineAction->setEnabled(false);
+            m_backgroundAction->setEnabled(false);
+            return;
+        }
+
+        m_view->openFile(file);
+
+        if (!fileName.startsWith(":/")) {
+            m_currentPath = fileName;
+            setWindowTitle(tr("%1 - SVGViewer").arg(m_currentPath));
+        }
+
+        m_outlineAction->setEnabled(true);
+        m_backgroundAction->setEnabled(true);
+
+        //resize(m_view->sizeHint() + QSize(80, 80 + menuBar()->height()));
+    }
+}
+
+
+void MainWindow::opentestFile(const QString &path)
+{
+    QString fileName;
+    if (path.isNull())
+    {
+        //fileName="/home/tuxun/Bureau/cheshire-catvinyle1.svg";
+        fileName="/home/tuxun/Bureau/carre.svg";
+     /*   fileName = QFileDialog::getOpenFileName(this, tr("Open SVG File"),
+                m_currentPath, "SVG files (*.svg *.svgz *.svg.gz)");*/}
+
+    else
+        fileName = path;
+
+    if (!fileName.isEmpty()) {
+        QFile file(fileName);
+        if (!file.exists()) {
+            QMessageBox::critical(this, tr("Open SVG File"),
+                           QString("Could not open file '%1'.").arg(fileName));
+
+            m_outlineAction->setEnabled(false);
+            m_backgroundAction->setEnabled(false);
+            return;
+        }
+
+        m_view->openFile(file);
+
+        if (!fileName.startsWith(":/")) {
+            m_currentPath = fileName;
+            setWindowTitle(tr("%1 - SVGViewer").arg(m_currentPath));
+        }
+
+        m_outlineAction->setEnabled(true);
+        m_backgroundAction->setEnabled(true);
+
+        //resize(m_view->sizeHint() + QSize(80, 80 + menuBar()->height()));
+    }
+}
+
+void MainWindow::setRenderer(QAction *action)
+{
+#ifndef QT_NO_OPENGL
+    m_highQualityAntialiasingAction->setEnabled(false);
+#endif
+
+    if (action == m_nativeAction)
+        m_view->setRenderer(SvgView::Native);
+#ifndef QT_NO_OPENGL
+    else if (action == m_glAction) {
+        m_highQualityAntialiasingAction->setEnabled(true);
+        m_view->setRenderer(SvgView::OpenGL);
+    }
+#endif
+    else if (action == m_imageAction) {
+        m_view->setRenderer(SvgView::Image);
+    }
+}

+ 82 - 0
mainwindow.h

@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+**     of its contributors may be used to endorse or promote products derived
+**     from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QString>
+
+class SvgView;
+
+QT_BEGIN_NAMESPACE
+class QAction;
+class QGraphicsView;
+class QGraphicsScene;
+class QGraphicsRectItem;
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    MainWindow();
+    void add_dock(void);
+
+public slots:
+    void openFile(const QString &path = QString());
+    void opentestFile(const QString &path = QString());
+    void setRenderer(QAction *action);
+
+private:
+    QAction *m_nativeAction;
+    QAction *m_glAction;
+    QAction *m_imageAction;
+    QAction *m_highQualityAntialiasingAction;
+    QAction *m_backgroundAction;
+    QAction *m_outlineAction;
+
+    SvgView *m_view;
+
+    QString m_currentPath="/home/tuxun";
+};
+
+#endif

+ 620 - 0
selectsettingwindow.cpp

@@ -0,0 +1,620 @@
+#include "selectsettingwindow.h"
+#include "draglabel.h"
+#include <QVBoxLayout>
+#include <QFile>
+#include <QHeaderView>
+#include <iostream>
+
+#include <QDebug>
+
+selectsettingwindow::selectsettingwindow(QMainWindow *parent) :
+    QMainWindow(parent)
+{
+  //  QString actualrastsettings[16][7];
+    //QString actualcutsettings[16][7];
+    this->m_actualparametersfilename=  QString("qcncdefautmaterial.ini");
+
+    this->textresult=new QTextEdit();
+    if(!this->set_settingspath(QDir::homePath()))
+    {int ret = QMessageBox::warning(this, tr("My Application"),
+                                    tr("The document has been modified.\n"
+                                       "Do you want to save your changes?"),
+                                    QMessageBox::Retry | QMessageBox::Discard
+                                 );
+    if (ret==QMessageBox::Retry)
+    {//
+        qDebug()<<"retretry";
+
+    }
+    else
+    {
+     qDebug()<<"ret  elsesettings directory not set (loadingself destruction)";
+    }}
+    else     {
+        qDebug()<<QString("settings directory set to userdir")<<
+                  this->m_settingsdir->path()<<this->m_actualparametersfilename;
+
+
+    }
+
+
+
+
+    this->saveButton=new QPushButton(QString("savesettings"));//dirsettinglist
+    connect(this->saveButton,SIGNAL(clicked()),this,SLOT(askparametersfilename()));
+    connect(this->setdirButton,SIGNAL(clicked()),this,SLOT(askparametersdirectory()));
+
+    //final:
+    add_dock();
+}
+
+
+bool selectsettingwindow::set_parameterspath(const QString name)
+
+{
+    this->m_actualparametersfilename=name;
+    if(this->m_settingsdir->exists())
+    {
+        if(QFile::exists(this->m_settingsdir->path().append(this->m_actualparametersfilename)))
+        return true;
+    }
+    else
+    {
+        qDebug()<<"parameterpath "<<name<< " not found";
+        return true;
+    }
+
+return true;
+}
+
+bool selectsettingwindow::set_settingspath(const QString path)
+
+{this->m_settingsdir=new QDir();
+    this->m_settingsdir->setPath(path);
+    if(this->m_settingsdir->exists())
+        return true;
+    else
+    {
+        qDebug()<<"dir "<<path<< " not found";
+        return false;
+    }
+
+
+}
+
+//rastsetthispower[i]->setStyleSheet(
+//            QString("background-color:rgb(")
+//            +r
+//            +","
+//            +g
+//            +","
+//            +b
+//            +")"
+//            );
+//qDebug()<<"rasting n°"<<i<<rastsetthispower[i]->styleSheet();
+//qDebug()<<"output:"
+//       <<"background-color:rgb("
+//        <<16*i
+//        <<","
+//        <<16*i
+//        <<","
+//        <<(16*i)
+//        <<")"
+//       ;
+/*
+lignelayrast[i]->addWidget(rastsettingname[i]);
+lignelayrast[i]->addWidget(rastfeed[i]);
+lignelayrast[i]->addWidget(rastpower[i]);
+lignelayrast[i]->addWidget(rastplungedistance[i]);
+lignelayrast[i]->addWidget(rastpassnumber[i]);
+lignelayrast[i]->addWidget(rastgcodevalue[i]);
+lignelayrast[i]->addWidget(rastsetthispower[i]);*/
+
+//demande le nom sous lequel exporter les settings actuels (et les exporte)
+void selectsettingwindow::askparametersfilename()
+{qDebug("askpaparametersfilename");
+    bool ok;
+    QString text = QInputDialog::getText(this,
+                                            tr("Choose a materialsetting file:"),
+                                            tr("QInputDialog::getText()"),
+                                            QLineEdit::Normal,
+                                            "settingnametosave", &ok);
+       if (ok && !text.isEmpty())
+{
+           if(set_parameterspath(text))
+{this->exportsettings(this->m_settingsdir->path().append("/").append(this->m_actualparametersfilename).append(".ini"),this->actualrastsettings,this->actualcutsettings);}
+else {qDebug("unable to create actual setting.ini:");}
+}
+
+
+}
+
+
+
+
+//demande le nom sous lequel exporter les settings actuels (et les exportes)
+void selectsettingwindow::askparametersdirectory()
+{qDebug("askpaparametersdir");
+    bool ok;
+    QString text = QInputDialog::getText(this,
+                                            tr("Choose a materialsetting dir:"),
+                                            tr("QInputDialog::getText() dir"),
+                                            QLineEdit::Normal,
+                                            "settingdirtosave", &ok);
+       if (ok && !text.isEmpty())
+{
+           if(set_parameterspath(text))
+{this->exportsettings(this->m_settingsdir->path().append("/").append(this->m_actualparametersfilename).append(".ini"),this->actualrastsettings,this->actualcutsettings);}
+else {qDebug("unable to create actual setting.ini:");}
+}
+}
+
+
+
+
+void selectsettingwindow::add_dock(void)
+{
+QWidget *minisavewidget=new QWidget();
+    QVBoxLayout *minisavelayout=new QVBoxLayout();
+     QPushButton *setdirButton=new QPushButton(this->m_settingsdir->path());
+     setdirButton->setToolTip(tr("Select a directory for your settings files"));
+     QPushButton *openButton=new QPushButton(this->m_actualparametersfilename);
+     openButton->setToolTip("Select a settings files from the above directory");
+
+
+
+   minisavelayout->addWidget(setdirButton);
+ minisavelayout->addWidget(openButton);
+ minisavelayout->addWidget(this->saveButton);
+
+ minisavewidget->setLayout(minisavelayout);
+
+this->setCentralWidget(minisavewidget);
+
+
+//     minisavelayout
+
+
+this->l_dock=new QDockWidget();
+
+ //todo WIP!!!
+if((this->m_actualparametersfilename)==NULL)
+{
+//ca, ca fait semblant? que devient result?
+    QString defaultsettingsresult=this->exportsettings("/home/tuxun/qcncdefautmaterial.ini",defaultrastsettings,defaultcutsettings);
+this->m_actualparametersfilename=  QString("qcncdefautmaterial.ini");
+    textresult->setText(defaultsettingsresult);
+    textresult->setWindowTitle(this->m_actualparametersfilename);
+    textresult->show();
+
+}
+else
+{
+    QString defaultsettingsresult=this->exportsettings(this->m_settingsdir->path().append(this->m_actualparametersfilename),defaultrastsettings,defaultcutsettings);
+    this->m_actualparametersfilename= QString("dafuk.ini");
+    textresult->setWindowTitle(this->m_actualparametersfilename);
+
+    textresult->setText(defaultsettingsresult);
+    textresult->show();
+
+}
+
+for (int i=0;i<15;i++)
+{
+
+    this->actualrastsettings[i][0]=defaultrastsettings[i][0];
+  //  qDebug()<<i<<actualrastsettings[i][0];
+
+
+    this->actualrastsettings[i][1]=defaultrastsettings[i][1];
+    this->actualrastsettings[i][2]=defaultrastsettings[i][2];
+    this->actualrastsettings[i][3]=defaultrastsettings[i][3];
+    this->actualrastsettings[i][4]=defaultrastsettings[i][4];
+    this->actualrastsettings[i][5]=defaultrastsettings[i][5];
+    this->actualrastsettings[i][6]=defaultrastsettings[i][6];
+
+
+    this->actualcutsettings[i][0]=defaultcutsettings[i][0];
+    this->actualcutsettings[i][1]=defaultcutsettings[i][1];
+    this->actualcutsettings[i][2]=defaultcutsettings[i][2];
+    this->actualcutsettings[i][3]=defaultcutsettings[i][3];
+    this->actualcutsettings[i][4]=defaultcutsettings[i][4];
+    this->actualcutsettings[i][5]=defaultcutsettings[i][5];
+    this->actualcutsettings[i][6]=defaultcutsettings[i][6];
+
+
+}
+qDebug("starting using actualsettings copied from default");
+
+this->container_rast=new QTableWidget(16,7,this);
+qDebug("containerok");
+
+
+ //  cubesHeaderItem->setIcon(QIcon(QPixmap("/home/tuxun/rotate.png")));
+  // cubesHeaderItem->setTextAlignment(Qt::AlignVCenter);
+
+//   this->container_rast->setItem(0, 0, cubesHeaderItem);
+
+QTableWidgetItem *nameHeaderItem = new QTableWidgetItem("name");
+QTableWidgetItem *feedHeaderItem = new QTableWidgetItem("feed");
+QTableWidgetItem *powerHeaderItem = new QTableWidgetItem("power");
+QTableWidgetItem *zeachpasseHeaderItem = new QTableWidgetItem("-z/layer");
+QTableWidgetItem *numberpassesHeaderItem = new QTableWidgetItem("#layer");
+QTableWidgetItem *gcodevalueHeaderItem = new QTableWidgetItem("gcode");
+QTableWidgetItem *colorHeaderItem = new QTableWidgetItem("rgb");
+
+this->container_rast->verticalHeader()->hide();
+nameHeaderItem->setToolTip("nom du parametre");
+feedHeaderItem->setToolTip("vitesse avance");
+powerHeaderItem->setToolTip("puissance par passe");
+zeachpasseHeaderItem->setToolTip("profondeur par passe");
+numberpassesHeaderItem->setToolTip("nombre de passes");
+gcodevalueHeaderItem->setToolTip("gcode a envoyer");
+colorHeaderItem->setToolTip("couleur du paramètre");
+this->container_rast->setHorizontalHeaderItem( 0, nameHeaderItem);
+this->container_rast->setHorizontalHeaderItem( 1, feedHeaderItem);
+this->container_rast->setHorizontalHeaderItem( 2, powerHeaderItem);
+this->container_rast->setHorizontalHeaderItem( 3, zeachpasseHeaderItem);
+this->container_rast->setHorizontalHeaderItem( 4, numberpassesHeaderItem);
+this->container_rast->setHorizontalHeaderItem( 5, gcodevalueHeaderItem);
+this->container_rast->setHorizontalHeaderItem( 6, colorHeaderItem);
+
+
+
+QLabel *rastsettingname[16];
+QLabel *rastfeed[16];
+QLabel *rastpower[16];
+QLabel *rastplungedistance[16];
+QLabel *rastpassnumber[16];
+QLabel *rastgcodevalue[16];
+DragLabel *rastsetthispower[16];
+QHBoxLayout *lignelayrast[16];
+
+QVBoxLayout *collayrast=new QVBoxLayout();
+collayrast->setMargin(0);
+
+
+for (int i=0;i<15;i++)
+{
+    lignelayrast[i]=new QHBoxLayout();
+lignelayrast[i]->setMargin(0);
+
+
+rastsettingname[i]=new QLabel(actualrastsettings[i][0]);
+
+rastfeed[i]=new QLabel(actualrastsettings[i][1]);
+rastpower[i]=new QLabel(actualrastsettings[i][2]);
+rastplungedistance[i]=new QLabel(actualrastsettings[i][3]);
+rastpassnumber[i]=new QLabel(actualrastsettings[i][4]);
+rastgcodevalue[i]=new QLabel(actualrastsettings[i][5]);
+
+
+QString  r,g,b;
+r.setNum(16*i);
+g.setNum(16*i);
+b.setNum(16*i);
+rastsetthispower[i]=new DragLabel(r+b+g);
+rastsetthispower[i]->setBackgroundColor(QColor(r.toInt(),g.toInt(),b.toInt()));
+
+this->container_rast->setItem(i, 0, new QTableWidgetItem(actualrastsettings[i][0]));
+this->container_rast->setItem(i, 1, new QTableWidgetItem(actualrastsettings[i][1]));
+this->container_rast->setItem(i, 2, new QTableWidgetItem(actualrastsettings[i][2]));
+this->container_rast->setItem(i, 3, new QTableWidgetItem(actualrastsettings[i][3]));
+this->container_rast->setItem(i, 4, new QTableWidgetItem(actualrastsettings[i][4]));
+this->container_rast->setItem(i, 5, new QTableWidgetItem(actualrastsettings[i][5]));
+
+//oups le draglabel
+//this->container_rast->sel
+this->container_rast->setItem(i, 6,rastsetthispower[i]);
+collayrast->addLayout(lignelayrast[i]);
+}
+qDebug("ending using actualsettings copied from default");
+
+//stream.writeEndDocument();
+
+//!this->container_rast->setLayout(collayrast);
+l_dock->setWidget(this->container_rast);
+l_dock->setWindowTitle("parametre de gravure");
+
+addDockWidget(Qt::LeftDockWidgetArea,l_dock);
+
+//end rast zone
+//qDebug()<<"interzone";
+/////////////////////////////////////////////////////////////////
+////////////////cutzone - rdockwidget/////////////////////////////
+/////////////////////////////////////////////////////////////////
+
+this->r_dock=new QDockWidget();
+
+
+
+
+this->container_cut=new QTableWidget(16,7,this);
+
+
+
+
+ //  cubesHeaderItem->setIcon(QIcon(QPixmap("/home/tuxun/rotate.png")));
+  // cubesHeaderItem->setTextAlignment(Qt::AlignVCenter);
+
+//   this->container_rast->setItem(0, 0, cubesHeaderItem);
+
+//QTableWidgetItem *nameHeaderItem = new QTableWidgetItem("name");
+//QTableWidgetItem *feedHeaderItem = new QTableWidgetItem("feed");
+//QTableWidgetItem *powerHeaderItem = new QTableWidgetItem("power");
+//QTableWidgetItem *zeachpasseHeaderItem = new QTableWidgetItem("-z/passes");
+//QTableWidgetItem *numberpassesHeaderItem = new QTableWidgetItem("number of passes");
+//QTableWidgetItem *gcodevalueHeaderItem = new QTableWidgetItem("gcode value");
+//QTableWidgetItem *colorHeaderItem = new QTableWidgetItem("color");
+
+this->container_cut->setHorizontalHeaderItem( 6, nameHeaderItem);
+this->container_cut->setHorizontalHeaderItem( 5, feedHeaderItem);
+this->container_cut->setHorizontalHeaderItem( 4, powerHeaderItem);
+this->container_cut->setHorizontalHeaderItem( 3, zeachpasseHeaderItem);
+this->container_cut->setHorizontalHeaderItem( 2, numberpassesHeaderItem);
+this->container_cut->setHorizontalHeaderItem( 1, gcodevalueHeaderItem);
+this->container_cut->setHorizontalHeaderItem( 0, colorHeaderItem);
+this->container_cut->verticalHeader()->hide();
+//this->container_cut->setStatusTip();
+
+
+QLabel *cutsettingname[16];
+QLabel *cutfeed[16];
+QLabel *cutpower[16];
+QLabel *cutplungedistance[16];
+QLabel *cutpassnumber[16];
+QLabel *cutgcodevalue[16];
+DragLabel *cutsetthispower[16];
+QHBoxLayout *lignelay_cut[16];
+
+
+
+QVBoxLayout *collay_cut=new QVBoxLayout();
+collay_cut->setMargin(0);
+
+
+
+
+for (int j=0;j<15;j++)
+{
+
+
+    lignelay_cut[j]=new QHBoxLayout();
+    lignelay_cut[j]->setMargin(0);
+    cutsettingname[j]=new QLabel(actualcutsettings[j][0]);
+    cutfeed[j]=new QLabel(actualcutsettings[j][1]);
+    cutpower[j]=new QLabel(actualcutsettings[j][2]);
+    cutplungedistance[j]=new QLabel(actualcutsettings[j][3]);
+    cutpassnumber[j]=new QLabel(actualcutsettings[j][4]);
+    cutgcodevalue[j]=new QLabel(actualcutsettings[j][5]);
+
+
+    //rastsetthispower[i]->setStyleSheet(
+    //            QString("background-color:rgb(")
+    //            +r
+    //            +","
+    //            +g
+    //            +","
+    //            +b
+    //            +")"
+    //            );
+    //qDebug()<<"rasting n°"<<i<<rastsetthispower[i]->styleSheet();
+    //qDebug()<<"output:"
+    //       <<"background-color:rgb("
+    //        <<16*i
+    //        <<","
+    //        <<16*i
+    //        <<","
+    //        <<(16*i)
+    //        <<")"
+    //       ;
+
+QString  r,g,b;
+r.setNum(16*j);
+g.setNum(16*j);
+b.setNum(16*j);
+
+cutsetthispower[j]=new DragLabel(r+b+g);
+cutsetthispower[j]->setBackgroundColor(QColor(actualcutsettings[j][6]));
+
+this->container_cut->setItem(j, 6, new QTableWidgetItem(actualcutsettings[j][0]));
+this->container_cut->setItem(j, 5, new QTableWidgetItem(actualcutsettings[j][1]));
+this->container_cut->setItem(j, 4, new QTableWidgetItem(actualcutsettings[j][2]));
+this->container_cut->setItem(j, 3, new QTableWidgetItem(actualcutsettings[j][3]));
+this->container_cut->setItem(j, 2, new QTableWidgetItem(actualcutsettings[j][4]));
+this->container_cut->setItem(j, 1, new QTableWidgetItem(actualcutsettings[j][5]));
+//connect(m_backgroundAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewBackground(bool)));
+
+//oups le draglabel
+//this->container_rast->sel
+this->container_cut->setItem(j, 0,cutsetthispower[j]);
+collay_cut->addLayout(lignelay_cut[j]);
+}
+
+this->container_cut->resizeColumnsToContents();
+this->container_rast->resizeColumnsToContents();
+this->container_cut->setLayout(collay_cut);
+r_dock->setWidget(this->container_cut);
+r_dock->setWindowTitle("parametre de coupe");
+addDockWidget(Qt::RightDockWidgetArea,r_dock);
+
+
+//QXmlStreamReader *xmlresult=new QXmlStreamReader(&output);
+//qDebug("xmlresult:");
+
+//qDebug()<<output.readAll();
+
+//qDebug()<<xmlresult->text().toString();
+
+//QTextEdit *textresult=new QTextEdit(xmlresult->text().toString());
+
+//qDebug("end");
+connect(this->container_rast,SIGNAL(cellChanged(int,int)),this,SLOT(update_engravesetting(int,int)));
+connect(this->container_cut,SIGNAL(cellChanged(int,int)),this,SLOT(update_cuttingsetting(int,int)));
+
+//miss enddoc xml?
+}
+
+//slot
+void selectsettingwindow::update_engravesetting(int settingname,int subsetting){
+    qDebug()<<"engrave setting"<< settingname<<"changed (#"<<subsetting<<"):"<<this->container_rast->item(settingname,subsetting)->text();
+
+    this->actualrastsettings[settingname][subsetting]=this->container_rast->item(settingname,subsetting)->text();
+
+    QString actualsettingsresult=exportsettings("/home/tuxun/qcncactualmaterial.ini",actualrastsettings,actualcutsettings);
+
+
+
+textresult->hide();
+    textresult->setText(actualsettingsresult);
+    textresult->show();
+
+
+}
+
+void selectsettingwindow::update_cuttingsetting(int settingname,int subsetting){
+ qDebug()<<"cutsetting"<< settingname<<"changed (#"<<subsetting<<"):"<<this->container_cut->item(settingname,subsetting)->text();
+//get it in the xml!
+//this->xmlstream->open(actualsettingfile);
+ //updatevalue
+ this->actualcutsettings[settingname][subsetting]=this->container_cut->item(settingname,subsetting)->text();
+   //      close
+              }
+
+//!this->container_rast->setLayout(collayrast);
+/////////////////////////////////////////////////////////////////
+/////////////here should be the end my friend/////////////////////
+/////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////
+//start cut zone
+
+
+//!!!cutsetthispower[j]->setStyleSheet(
+//        QString("background-color:")
+//        +defaultcutsettings[j][6]
+//        );
+//qDebug()<<"cuting n°"<<j<<cutsetthispower[j]->styleSheet();
+//qDebug()<<"output:"
+//       <<"background-color:rgb("
+//        <<16*i
+//        <<","
+//        <<16*i
+//        <<","
+//        <<(16*i)
+//        <<")"
+//       ;
+
+//lignelay_cut[j]->addWidget(cutsetthispower[j]);
+//lignelay_cut[j]->addWidget(cutgcodevalue[j]);
+//lignelay_cut[j]->addWidget(cutpassnumber[j]);
+//lignelay_cut[j]->addWidget(cutplungedistance[j]);
+//lignelay_cut[j]->addWidget(cutpower[j]);
+//lignelay_cut[j]->addWidget(cutfeed[j]);
+//lignelay_cut[j]->addWidget(cutsettingname[j]);
+
+
+//endcutzone
+
+
+//m_dock->setWidget(container);
+QString  selectsettingwindow::exportsettings(QString filename, QString rastsettings[16][7],QString cutsettings[16][7])
+{
+
+    QFile output(filename);
+QString result;
+if(!output.exists())
+//string to export for get a defaut material.ini
+{
+    qDebug()<<filename<<" created";
+    output.open(QIODevice::ReadWrite);
+    this->xmlstream=new QXmlStreamWriter (&output);
+       this->xmlstream->setAutoFormatting(true);
+       this->xmlstream->writeStartDocument();
+//
+       this->xmlstream->writeStartElement("lasermaterialsetting");
+       this->xmlstream->writeAttribute("href", "http://tuxun.fr/xml");
+
+    for (int i=0;i<15;i++)
+    {
+    this->xmlstream->writeStartElement(QString("EngraveSettingNumber%1").arg(i));
+
+    this->xmlstream->writeTextElement("name", rastsettings[i][0]);
+    this->xmlstream->writeTextElement("feed", rastsettings[i][1]);
+    this->xmlstream->writeTextElement("power", rastsettings[i][2]);
+    this->xmlstream->writeTextElement("depth/layer", rastsettings[i][3]);
+    this->xmlstream->writeTextElement("#layer", rastsettings[i][4]);
+    this->xmlstream->writeTextElement("gcode", rastsettings[i][5]);
+    this->xmlstream->writeTextElement("rgb", rastsettings[i][6]);
+    this->xmlstream->writeEndElement(); // lasermaterialsetting
+
+    this->xmlstream->writeEndElement(); // end setting#i
+
+    this->xmlstream->writeStartElement(QString("CutSettingNumber%1").arg(i));
+
+    this->xmlstream->writeTextElement("name", cutsettings[i][0]);
+    this->xmlstream->writeTextElement("feed", cutsettings[i][1]);
+    this->xmlstream->writeTextElement("power", cutsettings[i][2]);
+    this->xmlstream->writeTextElement("depth/layer", cutsettings[i][3]);
+    this->xmlstream->writeTextElement("#layer", cutsettings[i][4]);
+    this->xmlstream->writeTextElement("gcode value", cutsettings[i][5]);
+    this->xmlstream->writeTextElement("rgb", cutsettings[i][6]);
+    this->xmlstream->writeEndElement(); // lasermaterialsetting
+    this->xmlstream->writeEndElement(); // end setting#i
+    this->xmlstream->writeEndDocument();
+
+    }
+    result=output.readAll();
+    output.close();
+
+}
+else
+{
+
+
+    qDebug()<<filename<<" overwritten";
+    output.open(QIODevice::ReadWrite);
+    this->xmlstream=new QXmlStreamWriter (&output);
+       this->xmlstream->setAutoFormatting(true);
+       this->xmlstream->writeStartDocument();
+//
+       this->xmlstream->writeStartElement("lasermaterialsetting");
+       this->xmlstream->writeAttribute("href", "http://tuxun.fr/xml");
+
+    for (int i=0;i<15;i++)
+    {
+    this->xmlstream->writeStartElement(QString("EngraveSettingNumber%1").arg(i));
+
+    this->xmlstream->writeTextElement("name", rastsettings[i][0]);
+    this->xmlstream->writeTextElement("feed", rastsettings[i][1]);
+    this->xmlstream->writeTextElement("power", rastsettings[i][2]);
+    this->xmlstream->writeTextElement("depth/layer", rastsettings[i][3]);
+    this->xmlstream->writeTextElement("#layer", rastsettings[i][4]);
+    this->xmlstream->writeTextElement("gcode", rastsettings[i][5]);
+    this->xmlstream->writeTextElement("rgb", rastsettings[i][6]);
+    this->xmlstream->writeEndElement(); // lasermaterialsetting
+
+    this->xmlstream->writeEndElement(); // end setting#i
+
+    this->xmlstream->writeStartElement(QString("CutSettingNumber%1").arg(i));
+
+    this->xmlstream->writeTextElement("name", cutsettings[i][0]);
+    this->xmlstream->writeTextElement("feed", cutsettings[i][1]);
+    this->xmlstream->writeTextElement("power", cutsettings[i][2]);
+    this->xmlstream->writeTextElement("depth/layer", cutsettings[i][3]);
+    this->xmlstream->writeTextElement("#layer", cutsettings[i][4]);
+    this->xmlstream->writeTextElement("gcode value", cutsettings[i][5]);
+    this->xmlstream->writeTextElement("rgb", cutsettings[i][6]);
+    this->xmlstream->writeEndElement(); // lasermaterialsetting
+    this->xmlstream->writeEndElement(); // end setting#i
+    this->xmlstream->writeEndDocument();
+
+    }
+    result=output.readAll();
+    output.close();
+}
+return result;
+
+}

+ 107 - 0
selectsettingwindow.h

@@ -0,0 +1,107 @@
+#ifndef SELECTSETTINGWINDOW_H
+#define SELECTSETTINGWINDOW_H
+#include <QInputDialog>
+#include <QMainWindow>
+#include <QDockWidget>
+#include <QTableWidget>
+#include <QXmlStreamWriter>
+#include <QtXmlPatterns>
+#include <QTextEdit>
+#include <QPushButton>
+#include <QDir>
+#include <QMessageBox>
+
+class selectsettingwindow : public QMainWindow
+{
+    Q_OBJECT
+public:
+    explicit selectsettingwindow(QMainWindow *parent = 0);
+
+signals:
+public slots:
+    void add_dock(void);
+    void askparametersfilename();
+    void askparametersdirectory();
+
+    void update_engravesetting(int,int);
+    void update_cuttingsetting(int,int);
+
+private:
+    bool set_settingspath(const QString path);
+    //
+
+
+    bool set_parameterspath(const QString name);
+
+    QDir *m_settingsdir;
+
+    QPushButton *saveButton;
+    QPushButton *setdirButton;
+
+
+
+
+    QDockWidget  *l_dock,*r_dock;
+    QTableWidget *container_rast;
+    QTableWidget *container_cut;
+    QXmlStreamWriter *xmlstream;
+    QString *m_settingspath;
+    //name,speed,
+        //power,plunge,
+        //passnumber,gcode s value,colortomatch
+        QString defaultrastsettings[16][7]=
+        {
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"ff000000"}}
+        };
+
+
+        QString defaultcutsettings[16][7]=
+        {
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#000000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#808080"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#c0c0c0"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#ffffff"}},//blanc
+
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#800000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#ff0000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#808000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#ffff00"}},
+
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#008000"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#00ff00"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#008080"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#00ffff"}},
+
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#000080"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#0000ff"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#800080"}},
+            {{"200%"},{"100"},{"100"},{"0"},{"10"},{"256"},{"#ff00ff"}}
+        };
+        QString actualrastsettings[16][7];
+        QString actualcutsettings[16][7];
+        QString m_actualparametersfilename;
+        QTextEdit *textresult;
+        QString exportsettings(QString filename, QString rastsettings[16][7],QString cutsettings[16][7]);
+QFile defaultfileoutput,actualfileoutput;
+
+};
+
+#endif // SELECTSETTINGWINDOW_H

+ 795 - 0
svgview.cpp

@@ -0,0 +1,795 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+**     of its contributors may be used to endorse or promote products derived
+**     from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "svgview.h"
+
+#include <QFile>
+#include <QWheelEvent>
+#include <QMouseEvent>
+#include <QGraphicsRectItem>
+#include <QGraphicsSvgItem>
+#include <QPaintEvent>
+#include <qmath.h>
+
+#ifndef QT_NO_OPENGL
+#include <QGLWidget>
+#endif
+
+SvgView::SvgView(QWidget *parent)
+    : QGraphicsView(parent)
+    , m_renderer(Native)
+    , m_svgItem(0)
+    , m_backgroundItem(0)
+    , m_outlineItem(0)
+{
+    setScene(new QGraphicsScene(this));
+    setTransformationAnchor(AnchorUnderMouse);
+    //setDragMode(ScrollHandDrag);
+    setViewportUpdateMode(FullViewportUpdate);
+    this->setAcceptDrops(true);
+    this->setMouseTracking(true);
+    // Prepare background check-board pattern
+    QPixmap tilePixmap(64, 64);
+    tilePixmap.fill(Qt::white);
+    QPainter tilePainter(&tilePixmap);
+    QColor color(220, 220, 220);
+    tilePainter.fillRect(0, 0, 32, 32, color);
+    tilePainter.fillRect(32, 32, 32, 32, color);
+    tilePainter.end();
+    //setAcceptedMouseButtons(Qt::AllButtons);
+
+this->setEnabled(true);
+    setBackgroundBrush(tilePixmap);
+}
+
+//void SvgView::mouseReleaseEvent(QMouseEvent *event)
+//{
+//  //  qDebug()<<"svgview::mouserelEvent";
+//    event->ignore();
+////       event->accept();
+
+
+//}
+//void SvgView::mousePressEvent(QMouseEvent *event)
+//{
+////    qDebug()<<"svgview::mousePressEvent";
+//    event->ignore();
+
+
+//}
+
+void SvgView::dragEnterEvent(QDragEnterEvent *event)
+{
+    event->ignore();
+
+    if (event->mimeData()->hasFormat("application/x-fridgemagnet")) {
+        if (children().contains(event->source())) {
+            event->setDropAction(Qt::MoveAction);
+            event->accept();
+        } else {
+            event->acceptProposedAction();
+        }
+    } else if (event->mimeData()->hasText()) {
+        event->acceptProposedAction();
+    } else {
+        event->ignore();
+    }
+}
+
+void SvgView::dragMoveEvent(QDragMoveEvent *event)
+{
+    event->ignore();
+
+    if (event->mimeData()->hasFormat("application/x-fridgemagnet")) {
+        if (children().contains(event->source())) {
+            event->setDropAction(Qt::MoveAction);
+            event->accept();
+        } else {
+            event->acceptProposedAction();
+        }
+    } else if (event->mimeData()->hasText()) {
+        event->acceptProposedAction();
+    } else {
+        event->ignore();
+    }
+}
+
+void SvgView::dropEvent(QDropEvent *event)
+{
+    qDebug()<<"svgview dropEvent";
+    event->ignore();
+    if (event->mimeData()->hasFormat("application/x-fridgemagnet")) {
+        qDebug()<<"fridgemagnet dropEvent";
+
+        if (event->mimeData()->hasColor())
+        {        qDebug()<<"hasColor dropEvent";
+}
+    }
+    /*
+        const QMimeData *mime = event->mimeData();
+        QByteArray itemData = mime->data("application/x-fridgemagnet");
+        QDataStream dataStream(&itemData, QIODevice::ReadOnly);
+
+        QColor text;
+        QColor text1;
+        QPoint offset;
+        dataStream >> text >> offset;
+        DragLabel *newLabel = new DragLabel(text.name(), this);
+        newLabel->move(event->pos());
+        newLabel->show();
+        qDebug()<<"svgview dropEvent";
+
+
+      //  newLabel->setAttribute(Qt::WA_DeleteOnClose);
+
+        if (event->source() == this) {
+            event->setDropAction(Qt::MoveAction);
+            event->accept();
+        } else {
+            event->acceptProposedAction();
+        }
+    } else if (event->mimeData()->hasText()) {
+        QStringList pieces = event->mimeData()->text().split(QRegExp("\\s+"),
+                             QString::SkipEmptyParts);
+        QPoint position = event->pos();
+
+        foreach (QString piece, pieces) {
+            DragLabel *newLabel = new DragLabel(piece, this);
+            newLabel->move(position);
+            newLabel->show();
+           // newLabel->setAttribute(Qt::WA_DeleteOnClose);
+
+            position += QPoint(newLabel->width(), 0);
+        }
+
+        event->acceptProposedAction();
+    } else {
+        event->ignore();
+    }*/
+}
+
+void SvgView::mousePressEvent(QMouseEvent *event)
+{
+    /*event->accept();
+
+    Forme *child = static_cast<Forme*>(itemAt(event->pos()));
+    if (!child)
+    {qDebug()<<"svgview mousePressEvent nochild";return;
+}else qDebug()<<child->getcomputedstring();
+    QPoint hotSpot = event->pos() - child->pos().toPoint();
+
+    QByteArray itemData;
+    QDataStream dataStream(&itemData, QIODevice::WriteOnly);
+    dataStream << child->fillcolor << QPoint(hotSpot)<<child->strokecolor;
+
+    QMimeData *mimeData = new QMimeData;
+    mimeData->setData("application/x-fridgemagnet", itemData);
+    mimeData->setText("?");
+
+    QDrag *drag = new QDrag(this);
+    drag->setMimeData(mimeData);
+   //drag->setPixmap(*child->pixmap());
+    drag->setHotSpot(hotSpot);
+
+   // child->hide();
+
+    if (drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction) == Qt::MoveAction)
+       {} //child->close();
+    else
+        child->show();*/