selectsettingwindow.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. #include "selectsettingwindow.h"
  2. #include "draglabel.h"
  3. #include <QVBoxLayout>
  4. #include <QFile>
  5. #include <QHeaderView>
  6. #include <iostream>
  7. #include <QDebug>
  8. selectsettingwindow::selectsettingwindow(QMainWindow *parent) :
  9. QMainWindow(parent)
  10. {
  11. // QString actualrastsettings[16][7];
  12. //QString actualcutsettings[16][7];
  13. this->m_actualparametersfilename= QString("qcncdefautmaterial.ini");
  14. this->textresult=new QTextEdit();
  15. if(!this->set_settingspath(QDir::homePath()))
  16. {int ret = QMessageBox::warning(this, tr("My Application"),
  17. tr("The document has been modified.\n"
  18. "Do you want to save your changes?"),
  19. QMessageBox::Retry | QMessageBox::Discard
  20. );
  21. if (ret==QMessageBox::Retry)
  22. {//
  23. qDebug()<<"retretry";
  24. }
  25. else
  26. {
  27. qDebug()<<"ret elsesettings directory not set (loadingself destruction)";
  28. }}
  29. else {
  30. qDebug()<<QString("settings directory set to userdir")<<
  31. this->m_settingsdir->path()<<this->m_actualparametersfilename;
  32. }
  33. this->saveButton=new QPushButton(QString("savesettings"));//dirsettinglist
  34. connect(this->saveButton,SIGNAL(clicked()),this,SLOT(askparametersfilename()));
  35. //final:
  36. add_dock();
  37. }
  38. QWidget *selectsettingwindow::get_centralwidget()
  39. {return this->minisavewidget;}
  40. bool selectsettingwindow::set_parameterspath(const QString name)
  41. {
  42. this->m_actualparametersfilename=name;
  43. if(this->m_settingsdir->exists())
  44. {
  45. if(QFile::exists(this->m_settingsdir->path().append(this->m_actualparametersfilename)))
  46. return true;
  47. }
  48. else
  49. {
  50. qDebug()<<"parameterpath "<<name<< " not found";
  51. return true;
  52. }
  53. return true;
  54. }
  55. bool selectsettingwindow::set_settingspath(const QString path)
  56. {this->m_settingsdir=new QDir();
  57. this->m_settingsdir->setPath(path);
  58. if(this->m_settingsdir->exists())
  59. return true;
  60. else
  61. {
  62. qDebug()<<"dir "<<path<< " not found";
  63. return false;
  64. }
  65. }
  66. //rastsetthispower[i]->setStyleSheet(
  67. // QString("background-color:rgb(")
  68. // +r
  69. // +","
  70. // +g
  71. // +","
  72. // +b
  73. // +")"
  74. // );
  75. //qDebug()<<"rasting n°"<<i<<rastsetthispower[i]->styleSheet();
  76. //qDebug()<<"output:"
  77. // <<"background-color:rgb("
  78. // <<16*i
  79. // <<","
  80. // <<16*i
  81. // <<","
  82. // <<(16*i)
  83. // <<")"
  84. // ;
  85. /*
  86. lignelayrast[i]->addWidget(rastsettingname[i]);
  87. lignelayrast[i]->addWidget(rastfeed[i]);
  88. lignelayrast[i]->addWidget(rastpower[i]);
  89. lignelayrast[i]->addWidget(rastplungedistance[i]);
  90. lignelayrast[i]->addWidget(rastpassnumber[i]);
  91. lignelayrast[i]->addWidget(rastgcodevalue[i]);
  92. lignelayrast[i]->addWidget(rastsetthispower[i]);*/
  93. //demande le nom sous lequel exporter les settings actuels (et les exporte)
  94. void selectsettingwindow::askparametersfilename()
  95. {qDebug("askpaparametersfilename");
  96. bool ok;
  97. QString text = QInputDialog::getText(this,
  98. tr("Choose a materialsetting file:"),
  99. tr("QInputDialog::getText()"),
  100. QLineEdit::Normal,
  101. "settingnametosave", &ok);
  102. if (ok && !text.isEmpty())
  103. {
  104. if(set_parameterspath(text))
  105. {this->exportsettings(this->m_settingsdir->path().append("/").append(this->m_actualparametersfilename).append(".ini"),this->actualrastsettings,this->actualcutsettings);}
  106. else {qDebug("unable to create actual setting.ini:");}
  107. }
  108. }
  109. //demande le nom sous lequel exporter les settings actuels (et les exportes)
  110. void selectsettingwindow::askparametersdirectory()
  111. {qDebug("askpaparametersdir");
  112. bool ok;
  113. QString text = QInputDialog::getText(this,
  114. tr("Choose a materialsetting dir:"),
  115. tr("QInputDialog::getText() dir"),
  116. QLineEdit::Normal,
  117. "settingdirtosave", &ok);
  118. if (ok && !text.isEmpty())
  119. {
  120. if(set_parameterspath(text))
  121. {this->exportsettings(this->m_settingsdir->path().append("/").append(this->m_actualparametersfilename).append(".ini"),this->actualrastsettings,this->actualcutsettings);}
  122. else {qDebug("unable to create actual setting.ini:");}
  123. }
  124. }
  125. void selectsettingwindow::add_dock(void)
  126. {
  127. this->minisavewidget=new QWidget(this);
  128. QVBoxLayout *minisavelayout=new QVBoxLayout();
  129. this->setdirButton=new QPushButton(this->m_settingsdir->path());
  130. this->setdirButton->setToolTip(tr("Select a directory for your settings files"));
  131. connect(this->setdirButton,SIGNAL(clicked()),this,SLOT(askparametersdirectory()));
  132. QPushButton *openButton=new QPushButton(this->m_actualparametersfilename);
  133. openButton->setToolTip("Select a settings files from the above directory");
  134. minisavelayout->addWidget(setdirButton);
  135. minisavelayout->addWidget(openButton);
  136. minisavelayout->addWidget(this->saveButton);
  137. this->minisavewidget->setLayout(minisavelayout);
  138. //this->setCentralWidget(minisavewidget);
  139. // minisavelayout
  140. this->l_dock=new QDockWidget();
  141. //todo WIP!!!
  142. if((this->m_actualparametersfilename)==NULL)
  143. {
  144. //ca, ca fait semblant? que devient result?
  145. QString defaultsettingsresult=this->exportsettings(this->m_settingspath->append("/qcncdefautmaterial.ini"),defaultrastsettings,defaultcutsettings);
  146. this->m_actualparametersfilename= QString(this->m_settingsdir->path().append(this->m_actualparametersfilename.prepend('/')));
  147. textresult->insertPlainText(defaultsettingsresult);
  148. textresult->setWindowTitle(this->m_actualparametersfilename);
  149. textresult->show();
  150. //qDebug(defaultsettingsresult.toUtf8());
  151. }
  152. else
  153. {
  154. QString defaultsettingsresult=this->exportsettings(this->m_settingsdir->path().append(this->m_actualparametersfilename.prepend('/')),defaultrastsettings,defaultcutsettings);
  155. this->m_actualparametersfilename= QString(this->m_settingsdir->path().append(this->m_actualparametersfilename.prepend('/')));
  156. textresult->setWindowTitle(this->m_actualparametersfilename);
  157. textresult->insertPlainText(defaultsettingsresult);
  158. textresult->show();
  159. }
  160. for (int i=0;i<15;i++)
  161. {
  162. this->actualrastsettings[i][0]=defaultrastsettings[i][0];
  163. // qDebug()<<i<<actualrastsettings[i][0];
  164. this->actualrastsettings[i][1]=defaultrastsettings[i][1];
  165. this->actualrastsettings[i][2]=defaultrastsettings[i][2];
  166. this->actualrastsettings[i][3]=defaultrastsettings[i][3];
  167. this->actualrastsettings[i][4]=defaultrastsettings[i][4];
  168. this->actualrastsettings[i][5]=defaultrastsettings[i][5];
  169. this->actualrastsettings[i][6]=defaultrastsettings[i][6];
  170. this->actualcutsettings[i][0]=defaultcutsettings[i][0];
  171. this->actualcutsettings[i][1]=defaultcutsettings[i][1];
  172. this->actualcutsettings[i][2]=defaultcutsettings[i][2];
  173. this->actualcutsettings[i][3]=defaultcutsettings[i][3];
  174. this->actualcutsettings[i][4]=defaultcutsettings[i][4];
  175. this->actualcutsettings[i][5]=defaultcutsettings[i][5];
  176. this->actualcutsettings[i][6]=defaultcutsettings[i][6];
  177. }
  178. qDebug("starting using actualsettings copied from default");
  179. this->container_rast=new QTableWidget(16,7,this);
  180. qDebug("containerok");
  181. // cubesHeaderItem->setIcon(QIcon(QPixmap("/home/tuxun/rotate.png")));
  182. // cubesHeaderItem->setTextAlignment(Qt::AlignVCenter);
  183. // this->container_rast->setItem(0, 0, cubesHeaderItem);
  184. QTableWidgetItem *nameHeaderItem = new QTableWidgetItem("name");
  185. QTableWidgetItem *feedHeaderItem = new QTableWidgetItem("feed");
  186. QTableWidgetItem *powerHeaderItem = new QTableWidgetItem("power");
  187. QTableWidgetItem *zeachpasseHeaderItem = new QTableWidgetItem("-z/layer");
  188. QTableWidgetItem *numberpassesHeaderItem = new QTableWidgetItem("#layer");
  189. QTableWidgetItem *gcodevalueHeaderItem = new QTableWidgetItem("gcode");
  190. QTableWidgetItem *colorHeaderItem = new QTableWidgetItem("rgb");
  191. this->container_rast->verticalHeader()->hide();
  192. nameHeaderItem->setToolTip("nom du parametre");
  193. feedHeaderItem->setToolTip("vitesse avance");
  194. powerHeaderItem->setToolTip("puissance par passe");
  195. zeachpasseHeaderItem->setToolTip("profondeur par passe");
  196. numberpassesHeaderItem->setToolTip("nombre de passes");
  197. gcodevalueHeaderItem->setToolTip("gcode a envoyer");
  198. colorHeaderItem->setToolTip("couleur du paramètre");
  199. this->container_rast->setHorizontalHeaderItem( 0, nameHeaderItem);
  200. this->container_rast->setHorizontalHeaderItem( 1, feedHeaderItem);
  201. this->container_rast->setHorizontalHeaderItem( 2, powerHeaderItem);
  202. this->container_rast->setHorizontalHeaderItem( 3, zeachpasseHeaderItem);
  203. this->container_rast->setHorizontalHeaderItem( 4, numberpassesHeaderItem);
  204. this->container_rast->setHorizontalHeaderItem( 5, gcodevalueHeaderItem);
  205. this->container_rast->setHorizontalHeaderItem( 6, colorHeaderItem);
  206. QLabel *rastsettingname[16];
  207. QLabel *rastfeed[16];
  208. QLabel *rastpower[16];
  209. QLabel *rastplungedistance[16];
  210. QLabel *rastpassnumber[16];
  211. QLabel *rastgcodevalue[16];
  212. DragLabel *rastsetthispower[16];
  213. QHBoxLayout *lignelayrast[16];
  214. QVBoxLayout *collayrast=new QVBoxLayout();
  215. collayrast->setMargin(0);
  216. for (int i=0;i<15;i++)
  217. {
  218. lignelayrast[i]=new QHBoxLayout();
  219. lignelayrast[i]->setMargin(0);
  220. rastsettingname[i]=new QLabel(actualrastsettings[i][0]);
  221. rastfeed[i]=new QLabel(actualrastsettings[i][1]);
  222. rastpower[i]=new QLabel(actualrastsettings[i][2]);
  223. rastplungedistance[i]=new QLabel(actualrastsettings[i][3]);
  224. rastpassnumber[i]=new QLabel(actualrastsettings[i][4]);
  225. rastgcodevalue[i]=new QLabel(actualrastsettings[i][5]);
  226. QString r,g,b;
  227. r.setNum(16*i);
  228. g.setNum(16*i);
  229. b.setNum(16*i);
  230. rastsetthispower[i]=new DragLabel(r+b+g);
  231. rastsetthispower[i]->setBackgroundColor(QColor(r.toInt(),g.toInt(),b.toInt()));
  232. this->container_rast->setItem(i, 0, new QTableWidgetItem(actualrastsettings[i][0]));
  233. this->container_rast->setItem(i, 1, new QTableWidgetItem(actualrastsettings[i][1]));
  234. this->container_rast->setItem(i, 2, new QTableWidgetItem(actualrastsettings[i][2]));
  235. this->container_rast->setItem(i, 3, new QTableWidgetItem(actualrastsettings[i][3]));
  236. this->container_rast->setItem(i, 4, new QTableWidgetItem(actualrastsettings[i][4]));
  237. this->container_rast->setItem(i, 5, new QTableWidgetItem(actualrastsettings[i][5]));
  238. //oups le draglabel
  239. //this->container_rast->sel
  240. this->container_rast->setItem(i, 6,rastsetthispower[i]);
  241. collayrast->addLayout(lignelayrast[i]);
  242. }
  243. qDebug("ending using actualsettings copied from default");
  244. //stream.writeEndDocument();
  245. //!this->container_rast->setLayout(collayrast);
  246. l_dock->setWidget(this->container_rast);
  247. l_dock->setWindowTitle("parametre de gravure");
  248. addDockWidget(Qt::LeftDockWidgetArea,l_dock);
  249. //end rast zone
  250. //qDebug()<<"interzone";
  251. /////////////////////////////////////////////////////////////////
  252. ////////////////cutzone - rdockwidget/////////////////////////////
  253. /////////////////////////////////////////////////////////////////
  254. this->r_dock=new QDockWidget();
  255. this->container_cut=new QTableWidget(16,7,this);
  256. // cubesHeaderItem->setIcon(QIcon(QPixmap("/home/tuxun/rotate.png")));
  257. // cubesHeaderItem->setTextAlignment(Qt::AlignVCenter);
  258. // this->container_rast->setItem(0, 0, cubesHeaderItem);
  259. //QTableWidgetItem *nameHeaderItem = new QTableWidgetItem("name");
  260. //QTableWidgetItem *feedHeaderItem = new QTableWidgetItem("feed");
  261. //QTableWidgetItem *powerHeaderItem = new QTableWidgetItem("power");
  262. //QTableWidgetItem *zeachpasseHeaderItem = new QTableWidgetItem("-z/passes");
  263. //QTableWidgetItem *numberpassesHeaderItem = new QTableWidgetItem("number of passes");
  264. //QTableWidgetItem *gcodevalueHeaderItem = new QTableWidgetItem("gcode value");
  265. //QTableWidgetItem *colorHeaderItem = new QTableWidgetItem("color");
  266. this->container_cut->setHorizontalHeaderItem( 6, nameHeaderItem);
  267. this->container_cut->setHorizontalHeaderItem( 5, feedHeaderItem);
  268. this->container_cut->setHorizontalHeaderItem( 4, powerHeaderItem);
  269. this->container_cut->setHorizontalHeaderItem( 3, zeachpasseHeaderItem);
  270. this->container_cut->setHorizontalHeaderItem( 2, numberpassesHeaderItem);
  271. this->container_cut->setHorizontalHeaderItem( 1, gcodevalueHeaderItem);
  272. this->container_cut->setHorizontalHeaderItem( 0, colorHeaderItem);
  273. this->container_cut->verticalHeader()->hide();
  274. //this->container_cut->setStatusTip();
  275. QLabel *cutsettingname[16];
  276. QLabel *cutfeed[16];
  277. QLabel *cutpower[16];
  278. QLabel *cutplungedistance[16];
  279. QLabel *cutpassnumber[16];
  280. QLabel *cutgcodevalue[16];
  281. DragLabel *cutsetthispower[16];
  282. QHBoxLayout *lignelay_cut[16];
  283. QVBoxLayout *collay_cut=new QVBoxLayout();
  284. collay_cut->setMargin(0);
  285. for (int j=0;j<15;j++)
  286. {
  287. lignelay_cut[j]=new QHBoxLayout();
  288. lignelay_cut[j]->setMargin(0);
  289. cutsettingname[j]=new QLabel(actualcutsettings[j][0]);
  290. cutfeed[j]=new QLabel(actualcutsettings[j][1]);
  291. cutpower[j]=new QLabel(actualcutsettings[j][2]);
  292. cutplungedistance[j]=new QLabel(actualcutsettings[j][3]);
  293. cutpassnumber[j]=new QLabel(actualcutsettings[j][4]);
  294. cutgcodevalue[j]=new QLabel(actualcutsettings[j][5]);
  295. //rastsetthispower[i]->setStyleSheet(
  296. // QString("background-color:rgb(")
  297. // +r
  298. // +","
  299. // +g
  300. // +","
  301. // +b
  302. // +")"
  303. // );
  304. //qDebug()<<"rasting n°"<<i<<rastsetthispower[i]->styleSheet();
  305. //qDebug()<<"output:"
  306. // <<"background-color:rgb("
  307. // <<16*i
  308. // <<","
  309. // <<16*i
  310. // <<","
  311. // <<(16*i)
  312. // <<")"
  313. // ;
  314. QString r,g,b;
  315. r.setNum(16*j);
  316. g.setNum(16*j);
  317. b.setNum(16*j);
  318. cutsetthispower[j]=new DragLabel(r+b+g);
  319. cutsetthispower[j]->setBackgroundColor(QColor(actualcutsettings[j][6]));
  320. this->container_cut->setItem(j, 6, new QTableWidgetItem(actualcutsettings[j][0]));
  321. this->container_cut->setItem(j, 5, new QTableWidgetItem(actualcutsettings[j][1]));
  322. this->container_cut->setItem(j, 4, new QTableWidgetItem(actualcutsettings[j][2]));
  323. this->container_cut->setItem(j, 3, new QTableWidgetItem(actualcutsettings[j][3]));
  324. this->container_cut->setItem(j, 2, new QTableWidgetItem(actualcutsettings[j][4]));
  325. this->container_cut->setItem(j, 1, new QTableWidgetItem(actualcutsettings[j][5]));
  326. //connect(m_backgroundAction, SIGNAL(toggled(bool)), m_view, SLOT(setViewBackground(bool)));
  327. //oups le draglabel
  328. //this->container_rast->sel
  329. this->container_cut->setItem(j, 0,cutsetthispower[j]);
  330. collay_cut->addLayout(lignelay_cut[j]);
  331. }
  332. this->container_cut->resizeColumnsToContents();
  333. this->container_rast->resizeColumnsToContents();
  334. this->container_cut->setLayout(collay_cut);
  335. r_dock->setWidget(this->container_cut);
  336. r_dock->setWindowTitle("parametre de coupe");
  337. addDockWidget(Qt::RightDockWidgetArea,r_dock);
  338. //QXmlStreamReader *xmlresult=new QXmlStreamReader(&output);
  339. //qDebug("xmlresult:");
  340. //qDebug()<<output.readAll();
  341. //qDebug()<<xmlresult->text().toString();
  342. //QTextEdit *textresult=new QTextEdit(xmlresult->text().toString());
  343. //qDebug("end");
  344. connect(this->container_rast,SIGNAL(cellChanged(int,int)),this,SLOT(update_engravesetting(int,int)));
  345. connect(this->container_cut,SIGNAL(cellChanged(int,int)),this,SLOT(update_cuttingsetting(int,int)));
  346. //miss enddoc xml?
  347. }
  348. //slot
  349. void selectsettingwindow::update_engravesetting(int settingname,int subsetting){
  350. qDebug()<<"engrave setting"<< settingname<<"changed (#"<<subsetting<<"):"<<this->container_rast->item(settingname,subsetting)->text();
  351. this->actualrastsettings[settingname][subsetting]=this->container_rast->item(settingname,subsetting)->text();
  352. QString actualsettingsresult=exportsettings(this->m_actualparametersfilename,actualrastsettings,actualcutsettings);
  353. textresult->hide();
  354. textresult->setText(actualsettingsresult);
  355. textresult->show();
  356. }
  357. void selectsettingwindow::update_cuttingsetting(int settingname,int subsetting){
  358. qDebug()<<"cutsetting"<< settingname<<"changed (#"<<subsetting<<"):"<<this->container_cut->item(settingname,subsetting)->text();
  359. //get it in the xml!
  360. //this->xmlstream->open(actualsettingfile);
  361. //updatevalue
  362. this->actualcutsettings[settingname][subsetting]=this->container_cut->item(settingname,subsetting)->text();
  363. // close
  364. QString actualsettingsresult=exportsettings(this->m_actualparametersfilename,actualrastsettings,actualcutsettings);
  365. }
  366. //!this->container_rast->setLayout(collayrast);
  367. /////////////////////////////////////////////////////////////////
  368. /////////////here should be the end my friend/////////////////////
  369. /////////////////////////////////////////////////////////////////
  370. /////////////////////////////////////////////////////////////////
  371. /////////////////////////////////////////////////////////////////
  372. /////////////////////////////////////////////////////////////////
  373. /////////////////////////////////////////////////////////////////
  374. //start cut zone
  375. //!!!cutsetthispower[j]->setStyleSheet(
  376. // QString("background-color:")
  377. // +defaultcutsettings[j][6]
  378. // );
  379. //qDebug()<<"cuting n°"<<j<<cutsetthispower[j]->styleSheet();
  380. //qDebug()<<"output:"
  381. // <<"background-color:rgb("
  382. // <<16*i
  383. // <<","
  384. // <<16*i
  385. // <<","
  386. // <<(16*i)
  387. // <<")"
  388. // ;
  389. //lignelay_cut[j]->addWidget(cutsetthispower[j]);
  390. //lignelay_cut[j]->addWidget(cutgcodevalue[j]);
  391. //lignelay_cut[j]->addWidget(cutpassnumber[j]);
  392. //lignelay_cut[j]->addWidget(cutplungedistance[j]);
  393. //lignelay_cut[j]->addWidget(cutpower[j]);
  394. //lignelay_cut[j]->addWidget(cutfeed[j]);
  395. //lignelay_cut[j]->addWidget(cutsettingname[j]);
  396. //endcutzone
  397. //m_dock->setWidget(container);
  398. QString selectsettingwindow::exportsettings(QString filename, QString rastsettings[16][7],QString cutsettings[16][7])
  399. {
  400. qDebug()<<filename;
  401. QFile output(filename);
  402. QString result;
  403. if(!output.exists())
  404. //string to export for get a defaut material.ini
  405. {
  406. qDebug()<<filename<<" created";
  407. output.open(QIODevice::ReadWrite);
  408. this->xmlstream=new QXmlStreamWriter (&output);
  409. this->xmlstream->setAutoFormatting(true);
  410. this->xmlstream->writeStartDocument();
  411. //
  412. this->xmlstream->writeStartElement("lasermaterialsetting");
  413. this->xmlstream->writeAttribute("href", "http://tuxun.fr/xml");
  414. for (int i=0;i<15;i++)
  415. {
  416. this->xmlstream->writeStartElement(QString("EngraveSettingNumber%1").arg(i));
  417. this->xmlstream->writeTextElement("name", rastsettings[i][0]);
  418. this->xmlstream->writeTextElement("feed", rastsettings[i][1]);
  419. this->xmlstream->writeTextElement("power", rastsettings[i][2]);
  420. this->xmlstream->writeTextElement("depth/layer", rastsettings[i][3]);
  421. this->xmlstream->writeTextElement("#layer", rastsettings[i][4]);
  422. this->xmlstream->writeTextElement("gcode", rastsettings[i][5]);
  423. this->xmlstream->writeTextElement("rgb", rastsettings[i][6]);
  424. this->xmlstream->writeEndElement(); // lasermaterialsetting
  425. this->xmlstream->writeEndElement(); // end setting#i
  426. this->xmlstream->writeStartElement(QString("CutSettingNumber%1").arg(i));
  427. this->xmlstream->writeTextElement("name", cutsettings[i][0]);
  428. this->xmlstream->writeTextElement("feed", cutsettings[i][1]);
  429. this->xmlstream->writeTextElement("power", cutsettings[i][2]);
  430. this->xmlstream->writeTextElement("depth/layer", cutsettings[i][3]);
  431. this->xmlstream->writeTextElement("#layer", cutsettings[i][4]);
  432. this->xmlstream->writeTextElement("gcode value", cutsettings[i][5]);
  433. this->xmlstream->writeTextElement("rgb", cutsettings[i][6]);
  434. this->xmlstream->writeEndElement(); // lasermaterialsetting
  435. this->xmlstream->writeEndElement(); // end setting#i
  436. this->xmlstream->writeEndDocument();
  437. }
  438. result=output.readAll();
  439. output.close();
  440. }
  441. else
  442. {
  443. qDebug()<<filename<<" overwritten";
  444. output.open(QIODevice::ReadWrite);
  445. this->xmlstream=new QXmlStreamWriter (&output);
  446. this->xmlstream->setAutoFormatting(true);
  447. this->xmlstream->writeStartDocument();
  448. //
  449. this->xmlstream->writeStartElement("lasermaterialsetting");
  450. this->xmlstream->writeAttribute("href", "http://tuxun.fr/xml");
  451. for (int i=0;i<15;i++)
  452. {
  453. this->xmlstream->writeStartElement(QString("EngraveSettingNumber%1").arg(i));
  454. this->xmlstream->writeTextElement("name", rastsettings[i][0]);
  455. this->xmlstream->writeTextElement("feed", rastsettings[i][1]);
  456. this->xmlstream->writeTextElement("power", rastsettings[i][2]);
  457. this->xmlstream->writeTextElement("depth/layer", rastsettings[i][3]);
  458. this->xmlstream->writeTextElement("#layer", rastsettings[i][4]);
  459. this->xmlstream->writeTextElement("gcode", rastsettings[i][5]);
  460. this->xmlstream->writeTextElement("rgb", rastsettings[i][6]);
  461. this->xmlstream->writeEndElement(); // lasermaterialsetting
  462. this->xmlstream->writeEndElement(); // end setting#i
  463. this->xmlstream->writeStartElement(QString("CutSettingNumber%1").arg(i));
  464. this->xmlstream->writeTextElement("name", cutsettings[i][0]);
  465. this->xmlstream->writeTextElement("feed", cutsettings[i][1]);
  466. this->xmlstream->writeTextElement("power", cutsettings[i][2]);
  467. this->xmlstream->writeTextElement("depth/layer", cutsettings[i][3]);
  468. this->xmlstream->writeTextElement("#layer", cutsettings[i][4]);
  469. this->xmlstream->writeTextElement("gcode value", cutsettings[i][5]);
  470. this->xmlstream->writeTextElement("rgb", cutsettings[i][6]);
  471. this->xmlstream->writeEndElement(); // lasermaterialsetting
  472. this->xmlstream->writeEndElement(); // end setting#i
  473. this->xmlstream->writeEndDocument();
  474. }
  475. result=output.readAll();
  476. output.close();
  477. }
  478. return result;
  479. }