"Fossies" - the Fresh Open Source Software Archive

Member "mathmod-branches-r508-trunk/ui_modules/drawingoptions.cpp" (8 Mar 2021, 197869 Bytes) of package /linux/misc/mathmod-11.0-source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "drawingoptions.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 10.1_vs_11.0.

    1 /***************************************************************************
    2  *   Copyright (C) 2021 by Abderrahman Taha                                *
    3  *                                                                         *
    4  *                                                                         *
    5  *   This program is free software; you can redistribute it and/or modify  *
    6  *   it under the terms of the GNU General Public License as published by  *
    7  *   the Free Software Foundation; either version 2 of the License, or     *
    8  *   (at your option) any later version.                                   *
    9  *                                                                         *
   10  *   This program is distributed in the hope that it will be useful,       *
   11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
   13  *   GNU General Public License for more details.                          *
   14  *                                                                         *
   15  *   You should have received a copy of the GNU General Public License     *
   16  *   along with this program; if not, write to the                         *
   17  *   Free Software Foundation, Inc.,                                       *
   18  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
   19  ***************************************************************************/
   20 #include "drawingoptions.h"
   21 #include <qmessagebox.h>
   22 
   23 static int IndexcurrentComponent = -1;
   24 static int indexcurrentSet = 0;
   25 static int CurrentFormulaType = -1; // 0:Pariso; 1:Parametric; 2:Isosurface
   26 static QTreeWidgetItem *MyselectionItemReference;
   27 static QStringList qlstPos, qlstStep, qlstmin, qlstmax, qlstnames;
   28 
   29 // Error messages returned by ErrorMsg():
   30 static const char *ScriptErrorMessage[] =
   31 {
   32     "SCRIPT_NO_ERROR",      // 0
   33     "MAXGRID_OUT_OF_RANGE", // 1
   34     "MAXPT_OUT_OF_RANGE",   // 2
   35     "MAXTRI_OUT_OF_RANGE",  // 3
   36     "FXYZ_OUT_OF_RANGE",    // 4
   37     "FX_OUT_OF_RANGE",
   38     "XMAX_NBCOMPONENT_MISMATCH",                // 5
   39     "YMAX_NBCOMPONENT_MISMATCH",                // 6
   40     "ZMAX_NBCOMPONENT_MISMATCH",                // 7
   41     "XMIN_NBCOMPONENT_MISMATCH",                // 8
   42     "YMIN_NBCOMPONENT_MISMATCH",                // 9
   43     "ZMIN_NBCOMPONENT_MISMATCH",                // 10
   44     "FY_FX_MISMATCH",                           // 11
   45     "FZ_FX_MISMATCH",                           // 12
   46     "FW_FX_MISMATCH",                           // 13
   47     "UMAX_NBCOMPONENT_MISMATCH",                // 14
   48     "VMAX_NBCOMPONENT_MISMATCH",                // 15
   49     "WMAX_NBCOMPONENT_MISMATCH",                // 16
   50     "UMIN_NBCOMPONENT_MISMATCH",                // 17
   51     "VMIN_NBCOMPONENT_MISMATCH",                // 18
   52     "WMIN_NBCOMPONENT_MISMATCH",                // 19
   53     "GRID_NBCOMPONENT_MISMATCH",                // 20
   54     "COMPONENT_NBCOMPONENT_MISMATCH",           // 21
   55     "CND_NBCOMPONENT_MISMATCH",                 // 22
   56     "NBSLIDERS_OUT_OF_RANGE",                   // 23
   57     "NBSLIDERSVALUES_OUT_OF_RANGE",             // 24
   58     "VERTEX_TAB_MEM_OVERFLOW",                  // 25
   59     "TRIANGLES_TAB_MEM_OVERFLOW",               // 26
   60     "MINPOLY_TAB_MEM_OVERFLOW",                 // 27
   61     "POLY_TAB_MEM_OVERFLOW",                    // 28
   62     "CND_TAB_MEM_OVERFLOW",                     // 29
   63     "CND_POL_MEM_OVERFLOW",                     // 30
   64     "DEFINED_PARAM_GRID_VERTEX_TAB_OVERFLOW",   // 31
   65     "DEFINED_PARAM_GRID_TRIANGLE_TAB_OVERFLOW", // 32
   66     "GRID_SUPERIOR_TO_GRIDMAX",                 // 33
   67     "Vect_DIMENSION_ERROR",                     // 34
   68     "Not enough memory available to complete this operation", // 35
   69     "EMPTY_MANDATORY_FIELD"                     // 36
   70 };
   71 
   72 void DrawingOptions::ErrorMsg() const
   73 {
   74     QMessageBox msgBox;
   75     if (scriptErrorType != SCRIPT_NO_ERROR)
   76     {
   77         statusBar()->showMessage(ScriptErrorMessage[scriptErrorType]);
   78         msgBox.setText(ScriptErrorMessage[scriptErrorType]);
   79         msgBox.exec();
   80     }
   81 }
   82 
   83 void DrawingOptions::MemoryErrorMsg(int err) const
   84 {
   85     QMessageBox msgBox;
   86     if (err != SCRIPT_NO_ERROR)
   87     {
   88         msgBox.setText(ScriptErrorMessage[err]);
   89         msgBox.exec();
   90     }
   91 }
   92 
   93 void DrawingOptions::editorwin()
   94 {
   95     editor *editorwindow = new editor();
   96     editorwindow->show();
   97 }
   98 
   99 void DrawingOptions::colorsoptions()
  100 {
  101     ColorsOptions *colorwindow = new ColorsOptions();
  102     connect(colorwindow->ui.color_2, SIGNAL(activated(int)), this,SLOT(oncolor_2activated(int)));
  103     connect(colorwindow->ui.red_2, SIGNAL(valueChanged(int)), this,SLOT(onred_2valueChanged(int)));
  104     connect(colorwindow->ui.green_2, SIGNAL(valueChanged(int)), this,SLOT(ongreen_2valueChanged(int)));
  105     connect(colorwindow->ui.blue_2, SIGNAL(valueChanged(int)), this,SLOT(onblue_2valueChanged(int)));
  106     colorwindow->show();
  107 }
  108 
  109 void DrawingOptions::videoplay()
  110 {
  111     QImage buf = MathmodRef->Copyscreenshot();
  112     screenimage *player = new screenimage(buf);
  113     player->connectcontrols();
  114     player->show();
  115 }
  116 
  117 DrawingOptions::~DrawingOptions()
  118 {
  119     delete[] SliderArray;
  120 }
  121 
  122 DrawingOptions::DrawingOptions(QWidget *parent) : QMainWindow(parent)
  123 {
  124     ui.setupUi(this);
  125     IndexcurrentComponent = -1;
  126     IsolistItemRef = nullptr;
  127     select.selectedoptions.showall = false;
  128     select.selectedoptions.sensitive = false;
  129     select.selectedoptions.AND = true;
  130     select.selectedoptions.parsefunctions = true;
  131     select.selectedoptions.parsenames = true;
  132     select.selectedoptions.parsecmpnames = true;
  133     connect(sliderconf.ui.SaveButton, SIGNAL(clicked()), this,SLOT(update_slider_param()));
  134     connect(sliderconf.ui.ParametersComboBox, SIGNAL(activated(int)), this,SLOT(update_infos_param(int)));
  135     connect(addnewparam.ui.SaveButton, SIGNAL(clicked()), this,SLOT(add_new_param()));
  136     connect(&select, SIGNAL(UpdateSignal()), this, SLOT(SearchListModels()));
  137     statusBar()->addPermanentWidget(ui.Progressbarwidget, 1);
  138     SaveSlidersRef();
  139     BuildAllVect();
  140     ui.ObjectClasseCurrent->hide();
  141     ui.ObjectClasseCurrent->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
  142 }
  143 
  144 void DrawingOptions::SaveSlidersRef(int nb)
  145 {
  146     SliderArray = new SliderStruct[nb];
  147 
  148     SliderArray[0].SliderScrollBar = ui.C1ScrollBar;
  149     SliderArray[0].SliderLabel = ui.C1label;
  150     SliderArray[0].SliderLabelMax = ui.C1labelMax;
  151     SliderArray[0].SliderLabelMin = ui.C1labelMin;
  152     SliderArray[0].SliderGroupeBox = ui.groupBox_9;
  153 
  154     SliderArray[1].SliderScrollBar = ui.C2ScrollBar;
  155     SliderArray[1].SliderLabel = ui.C2label;
  156     SliderArray[1].SliderLabelMax = ui.C2labelMax;
  157     SliderArray[1].SliderLabelMin = ui.C2labelMin;
  158     SliderArray[1].SliderGroupeBox = ui.groupBox_10;
  159 
  160     SliderArray[2].SliderScrollBar = ui.C3ScrollBar;
  161     SliderArray[2].SliderLabel = ui.C3label;
  162     SliderArray[2].SliderLabelMax = ui.C3labelMax;
  163     SliderArray[2].SliderLabelMin = ui.C3labelMin;
  164     SliderArray[2].SliderGroupeBox = ui.groupBox_11;
  165 
  166     SliderArray[3].SliderScrollBar = ui.C4ScrollBar;
  167     SliderArray[3].SliderLabel = ui.C4label;
  168     SliderArray[3].SliderLabelMax = ui.C4labelMax;
  169     SliderArray[3].SliderLabelMin = ui.C4labelMin;
  170     SliderArray[3].SliderGroupeBox = ui.groupBox_12;
  171 
  172     SliderArray[4].SliderScrollBar = ui.C5ScrollBar;
  173     SliderArray[4].SliderLabel = ui.C5label;
  174     SliderArray[4].SliderLabelMax = ui.C5labelMax;
  175     SliderArray[4].SliderLabelMin = ui.C5labelMin;
  176     SliderArray[4].SliderGroupeBox = ui.groupBox_13;
  177 
  178     SliderArray[5].SliderScrollBar = ui.C6ScrollBar;
  179     SliderArray[5].SliderLabel = ui.C6label;
  180     SliderArray[5].SliderLabelMax = ui.C6labelMax;
  181     SliderArray[5].SliderLabelMin = ui.C6labelMin;
  182     SliderArray[5].SliderGroupeBox = ui.groupBox_14;
  183 
  184     SliderArray[6].SliderScrollBar = ui.C7ScrollBar;
  185     SliderArray[6].SliderLabel = ui.C7label;
  186     SliderArray[6].SliderLabelMax = ui.C7labelMax;
  187     SliderArray[6].SliderLabelMin = ui.C7labelMin;
  188     SliderArray[6].SliderGroupeBox = ui.groupBox_15;
  189 
  190     SliderArray[7].SliderScrollBar = ui.C8ScrollBar;
  191     SliderArray[7].SliderLabel = ui.C8label;
  192     SliderArray[7].SliderLabelMax = ui.C8labelMax;
  193     SliderArray[7].SliderLabelMin = ui.C8labelMin;
  194     SliderArray[7].SliderGroupeBox = ui.groupBox_16;
  195 
  196     SliderArray[8].SliderScrollBar = ui.C9ScrollBar;
  197     SliderArray[8].SliderLabel = ui.C9label;
  198     SliderArray[8].SliderLabelMax = ui.C9labelMax;
  199     SliderArray[8].SliderLabelMin = ui.C9labelMin;
  200     SliderArray[8].SliderGroupeBox = ui.groupBox_17;
  201 
  202     SliderArray[9].SliderScrollBar = ui.C10ScrollBar;
  203     SliderArray[9].SliderLabel = ui.C10label;
  204     SliderArray[9].SliderLabelMax = ui.C10labelMax;
  205     SliderArray[9].SliderLabelMin = ui.C10labelMin;
  206     SliderArray[9].SliderGroupeBox = ui.groupBox_18;
  207 
  208     SliderArray[10].SliderScrollBar = ui.C11ScrollBar;
  209     SliderArray[10].SliderLabel = ui.C11label;
  210     SliderArray[10].SliderLabelMax = ui.C11labelMax;
  211     SliderArray[10].SliderLabelMin = ui.C11labelMin;
  212     SliderArray[10].SliderGroupeBox = ui.groupBox_19;
  213 
  214     SliderArray[11].SliderScrollBar = ui.C12ScrollBar;
  215     SliderArray[11].SliderLabel = ui.C12label;
  216     SliderArray[11].SliderLabelMax = ui.C12labelMax;
  217     SliderArray[11].SliderLabelMin = ui.C12labelMin;
  218     SliderArray[11].SliderGroupeBox = ui.groupBox_20;
  219 
  220     SliderArray[12].SliderScrollBar = ui.C13ScrollBar;
  221     SliderArray[12].SliderLabel = ui.C13label;
  222     SliderArray[12].SliderLabelMax = ui.C13labelMax;
  223     SliderArray[12].SliderLabelMin = ui.C13labelMin;
  224     SliderArray[12].SliderGroupeBox = ui.groupBox_21;
  225 
  226     SliderArray[13].SliderScrollBar = ui.C14ScrollBar;
  227     SliderArray[13].SliderLabel = ui.C14label;
  228     SliderArray[13].SliderLabelMax = ui.C14labelMax;
  229     SliderArray[13].SliderLabelMin = ui.C14labelMin;
  230     SliderArray[13].SliderGroupeBox = ui.groupBox_22;
  231 
  232     SliderArray[14].SliderScrollBar = ui.C15ScrollBar;
  233     SliderArray[14].SliderLabel = ui.C15label;
  234     SliderArray[14].SliderLabelMax = ui.C15labelMax;
  235     SliderArray[14].SliderLabelMin = ui.C15labelMin;
  236     SliderArray[14].SliderGroupeBox = ui.groupBox_23;
  237 
  238     SliderArray[15].SliderScrollBar = ui.C16ScrollBar;
  239     SliderArray[15].SliderLabel = ui.C16label;
  240     SliderArray[15].SliderLabelMax = ui.C16labelMax;
  241     SliderArray[15].SliderLabelMin = ui.C16labelMin;
  242     SliderArray[15].SliderGroupeBox = ui.groupBox_24;
  243 
  244     SliderArray[16].SliderScrollBar = ui.C17ScrollBar;
  245     SliderArray[16].SliderLabel = ui.C17label;
  246     SliderArray[16].SliderLabelMax = ui.C17labelMax;
  247     SliderArray[16].SliderLabelMin = ui.C17labelMin;
  248     SliderArray[16].SliderGroupeBox = ui.groupBox_25;
  249 
  250     SliderArray[17].SliderScrollBar = ui.C18ScrollBar;
  251     SliderArray[17].SliderLabel = ui.C18label;
  252     SliderArray[17].SliderLabelMax = ui.C18labelMax;
  253     SliderArray[17].SliderLabelMin = ui.C18labelMin;
  254     SliderArray[17].SliderGroupeBox = ui.groupBox_26;
  255 
  256     SliderArray[18].SliderScrollBar = ui.C19ScrollBar;
  257     SliderArray[18].SliderLabel = ui.C19label;
  258     SliderArray[18].SliderLabelMax = ui.C19labelMax;
  259     SliderArray[18].SliderLabelMin = ui.C19labelMin;
  260     SliderArray[18].SliderGroupeBox = ui.groupBox_27;
  261 
  262     SliderArray[19].SliderScrollBar = ui.C20ScrollBar;
  263     SliderArray[19].SliderLabel = ui.C20label;
  264     SliderArray[19].SliderLabelMax = ui.C20labelMax;
  265     SliderArray[19].SliderLabelMin = ui.C20labelMin;
  266     SliderArray[19].SliderGroupeBox = ui.groupBox_28;
  267 }
  268 
  269 void DrawingOptions::on_xyzg_valueChanged(int value)
  270 {
  271     ui.Isogroupbox->setTitle("Grid/MaxGrid = (" +
  272                              QString::number(ui.xyzg->value()) + " / " +
  273                              QString::number(Parameters->IsoMaxGrid) + ")");
  274     if (!MathmodRef->IsoObjet->isRunning())
  275     {
  276         (MathmodRef->RootObjet.CurrentJsonObject["ParIso"].isArray()) ?
  277         MathmodRef->xyzg_valueChanged(value, PARISO_TYPE) : MathmodRef->xyzg_valueChanged(value, ISO_TYPE);
  278     }
  279     else
  280     {
  281         ui.ChangeGrid->blockSignals(true);
  282         ui.ChangeGrid->setChecked(false);
  283         ui.ChangeGrid->blockSignals(false);
  284         MathmodRef->xyzactivated = -1;
  285     }
  286 }
  287 
  288 void DrawingOptions::on_ChangeGrid_clicked()
  289 {
  290     (MathmodRef->RootObjet.CurrentJsonObject["ParIso"].isArray()) ?
  291     MathmodRef->slot_checkBox73_clicked(PARISO_TYPE) : MathmodRef->slot_checkBox73_clicked(ISO_TYPE);
  292 }
  293 
  294 void DrawingOptions::AddParObjectToTree(QTreeWidgetItem *paramlistItem,
  295                                         TreeStruct &currentstruct)
  296 {
  297     if (!currentstruct.name.empty())
  298         paramlistItem->setText(0, currentstruct.name[0]);
  299     QColor greenColor = QColor(0, 255, 0, 50);
  300     paramlistItem->setBackground(0, greenColor);
  301 
  302     if (currentstruct.Component.size() > 0)
  303     {
  304         QTreeWidgetItem *cmpitem = new QTreeWidgetItem(paramlistItem);
  305         cmpitem->setText(0, "Components (" +QString::number(currentstruct.Component.size()) +"):");
  306 
  307         for (int j = 0; j < currentstruct.Component.size(); j++)
  308         {
  309             QTreeWidgetItem *cmpitem2 = new QTreeWidgetItem(cmpitem);
  310             cmpitem2->setText(0, currentstruct.Component.at(j));
  311             QTreeWidgetItem *cmpitem3 = new QTreeWidgetItem(cmpitem2);
  312             cmpitem3->setText(0, "fx(u,v,t) = " + currentstruct.fx.at(j));
  313             QTreeWidgetItem *cmpitem4 = new QTreeWidgetItem(cmpitem2);
  314             cmpitem4->setText(0, "fy(u,v,t) = " + currentstruct.fy.at(j));
  315             QTreeWidgetItem *cmpitem5 = new QTreeWidgetItem(cmpitem2);
  316             cmpitem5->setText(0, "fz(u,v,t) = " + currentstruct.fz.at(j));
  317             if (MathmodRef->RootObjet.CurrentJsonObject["Param4D"].isObject())
  318             {
  319                 QTreeWidgetItem *cmpitem8 = new QTreeWidgetItem(cmpitem2);
  320                 cmpitem8->setText(0, "fw(u,v,t) = " + currentstruct.fw.at(j));
  321             }
  322             QTreeWidgetItem *cmpitem6 = new QTreeWidgetItem(cmpitem2);
  323             cmpitem6->setText(0, "U = [" + currentstruct.umin.at(j) + ", " +currentstruct.umax.at(j) + "]");
  324             QTreeWidgetItem *cmpitem7 = new QTreeWidgetItem(cmpitem2);
  325             cmpitem7->setText(0, "V = [" + currentstruct.vmin.at(j) + ", " +currentstruct.vmax.at(j) + "]");
  326             // Grid resolution:
  327             if (currentstruct.Grid.size() > 0 &&(2 * j + 1) < currentstruct.Grid.size() &&
  328                     !MathmodRef->RootObjet.CurrentJsonObject["Param4D"].isObject())
  329             {
  330                 QTreeWidgetItem *cmpitem7 = new QTreeWidgetItem(cmpitem2);
  331                 cmpitem7->setText(0, "Grid = (" + currentstruct.Grid.at(2 * j) + " , " +currentstruct.Grid.at(2 * j + 1) + ")");
  332             }
  333         }
  334         // Add Global parameters:
  335         AddParametersToTree(paramlistItem, currentstruct);
  336     }
  337 }
  338 
  339 void DrawingOptions::AddIsoObjectToTree(QTreeWidgetItem *IsolistItem, TreeStruct &currentstruct)
  340 {
  341     if (!currentstruct.name.empty())
  342         IsolistItem->setText(0, currentstruct.name[0]);
  343     QColor greenColor = QColor(0, 255, 0, 50);
  344     IsolistItem->setBackground(0, greenColor);
  345     if (currentstruct.Component.size() > 0)
  346     {
  347         QTreeWidgetItem *cmpitem = new QTreeWidgetItem(IsolistItem);
  348         cmpitem->setText(0, "Components (" +
  349                          QString::number(currentstruct.Component.size()) +
  350                          "):");
  351         for (int j = 0; j < currentstruct.Component.size(); j++)
  352         {
  353             QTreeWidgetItem *cmpitem2 = new QTreeWidgetItem(cmpitem);
  354             cmpitem2->setText(0, currentstruct.Component.at(j));
  355             QTreeWidgetItem *cmpitem3 = new QTreeWidgetItem(cmpitem2);
  356             cmpitem3->setText(0, "f(x,y,z) = " + currentstruct.fxyz.at(j));
  357             QTreeWidgetItem *cmpitem4 = new QTreeWidgetItem(cmpitem2);
  358             cmpitem4->setText(0, "X = [" + currentstruct.xmin.at(j) + ", " +currentstruct.xmax.at(j) + "]");
  359             QTreeWidgetItem *cmpitem5 = new QTreeWidgetItem(cmpitem2);
  360             cmpitem5->setText(0, "Y = [" + currentstruct.ymin.at(j) + ", " +currentstruct.ymax.at(j) + "]");
  361             QTreeWidgetItem *cmpitem6 = new QTreeWidgetItem(cmpitem2);
  362             cmpitem6->setText(0, "Z = [" + currentstruct.zmin.at(j) + ", " +currentstruct.zmax.at(j) + "]");
  363             // Grid resolution:
  364             if (currentstruct.Grid.size() > 0 && j < currentstruct.Grid.size())
  365             {
  366                 QTreeWidgetItem *cmpitem7 = new QTreeWidgetItem(cmpitem2);
  367                 cmpitem7->setText(0, "Grid = " + currentstruct.Grid.at(j));
  368             }
  369         }
  370         // Add Global parameters:
  371         AddParametersToTree(IsolistItem, currentstruct);
  372     }
  373 }
  374 
  375 void DrawingOptions::AddParametersToTree(QTreeWidgetItem *parameterslistItem,
  376         TreeStruct &currentstruct)
  377 {
  378     QTreeWidgetItem *parameteritem = new QTreeWidgetItem(parameterslistItem);
  379     parameteritem->setText(0, "Parameters:");
  380     int size = 0;
  381 
  382     if ((size = currentstruct.Const.size()) > 0)
  383     {
  384         QTreeWidgetItem *cstitem = new QTreeWidgetItem(parameteritem);
  385         cstitem->setText(0, "Constantes:");
  386         for (int j = 0; j < size; j++)
  387         {
  388             QTreeWidgetItem *cstitem2 = new QTreeWidgetItem(cstitem);
  389             cstitem2->setText(0, currentstruct.Const.at(j));
  390         }
  391     }
  392     if ((size = currentstruct.Funct.size()) > 0)
  393     {
  394         QTreeWidgetItem *fctitem = new QTreeWidgetItem(parameteritem);
  395         fctitem->setText(0, "Functions:");
  396         for (int j = 0; j < size; j++)
  397         {
  398             QTreeWidgetItem *fctitem2 = new QTreeWidgetItem(fctitem);
  399             fctitem2->setText(0, currentstruct.Funct.at(j));
  400         }
  401     }
  402 }
  403 
  404 void DrawingOptions::AddObjectToMySelectionTree()
  405 {
  406     if (MathmodRef->RootObjet.CurrentJsonObject["Iso3D"].isObject())
  407     {
  408         QTreeWidgetItem *isolistItem =
  409             new QTreeWidgetItem(MyselectionItemReference);
  410         AddIsoObjectToTree(isolistItem, MathmodRef->RootObjet.CurrentTreestruct);
  411     }
  412     else if (MathmodRef->RootObjet.CurrentJsonObject["Param3D"].isObject() ||
  413              MathmodRef->RootObjet.CurrentJsonObject["Param4D"].isObject())
  414     {
  415         QTreeWidgetItem *paramlistItem =
  416             new QTreeWidgetItem(MyselectionItemReference);
  417         AddParObjectToTree(paramlistItem, MathmodRef->RootObjet.CurrentTreestruct);
  418     }
  419 }
  420 
  421 void DrawingOptions::UpdateTreeObject()
  422 {
  423     // Update Object Tree
  424     if (MathmodRef->RootObjet.CurrentJsonObject["ParIso"].isArray()) // isoObject
  425     {
  426         ui.ObjectClasseCurrent->model()->removeRows(
  427             0, ui.ObjectClasseCurrent->model()->rowCount());
  428         for (uint i = 0; i < MathmodRef->RootObjet.CurrentParisoTreestruct.size();
  429                 i++)
  430         {
  431             QTreeWidgetItem *parisochild = new QTreeWidgetItem(ui.ObjectClasseCurrent);
  432             if (MathmodRef->RootObjet.CurrentParisoTreestruct[i].type == ISO_TYPE)
  433                 AddIsoObjectToTree(parisochild,MathmodRef->RootObjet.CurrentParisoTreestruct[i]);
  434             else
  435                 AddParObjectToTree(parisochild,MathmodRef->RootObjet.CurrentParisoTreestruct[i]);
  436         }
  437     }
  438     else
  439     {
  440         if (MathmodRef->RootObjet.CurrentJsonObject["Iso3D"].isObject()) // isoObject
  441         {
  442             ui.ObjectClasseCurrent->model()->removeRows(0, ui.ObjectClasseCurrent->model()->rowCount());
  443             QTreeWidgetItem *IsolistItem = new QTreeWidgetItem(ui.ObjectClasseCurrent);
  444             AddIsoObjectToTree(IsolistItem, MathmodRef->RootObjet.CurrentTreestruct);
  445         }
  446         else if (MathmodRef->RootObjet.CurrentJsonObject["Param3D"].isObject() ||
  447                  MathmodRef->RootObjet.CurrentJsonObject["Param4D"].isObject())
  448         {
  449             ui.ObjectClasseCurrent->model()->removeRows(0, ui.ObjectClasseCurrent->model()->rowCount());
  450             QTreeWidgetItem *paramlistItem =new QTreeWidgetItem(ui.ObjectClasseCurrent);
  451             AddParObjectToTree(paramlistItem,MathmodRef->RootObjet.CurrentTreestruct);
  452         }
  453     }
  454 }
  455 
  456 void DrawingOptions::UpdatePar4DModelDetailsPage(TreeStruct &currentstruct)
  457 {
  458     ui.ParamComponent_2->clear();
  459     if (!currentstruct.name.empty())
  460         ui.groupBox->setTitle(currentstruct.name.at(0));
  461     ui.ParamComponent_2->insertItems(0, currentstruct.Component);
  462     ui.stackedProperties->setCurrentIndex(3);
  463     UpdateDescription(0, PAR_4D_TYPE, currentstruct);
  464 }
  465 
  466 void DrawingOptions::UpdatePar3DModelDetailsPage(TreeStruct &currentstruct)
  467 {
  468     ui.ParamComponent->clear();
  469     if (!currentstruct.name.empty())
  470         ui.groupBox->setTitle(currentstruct.name.at(0));
  471     ui.ParamComponent->insertItems(0, currentstruct.Component);
  472     ui.stackedProperties->setCurrentIndex(2);
  473     ui.ShowParComp->setChecked(true);
  474     ui.ShowParComp->setText("Show");
  475     UpdateDescription(0, PAR_TYPE, currentstruct);
  476 }
  477 
  478 void DrawingOptions::UpdateIsoModelDetailsPage(TreeStruct &currentstruct)
  479 {
  480     ui.stackedProperties->setCurrentIndex(1);
  481     if (!currentstruct.name.empty())
  482         ui.groupBox->setTitle(currentstruct.name.at(0));
  483     ui.IsoComponent->clear();
  484     ui.IsoComponent->insertItems(0, currentstruct.Component);
  485     ui.ShowIsoComp->setChecked(true);
  486     ui.ShowIsoComp->setText("Show");
  487     UpdateDescription(0, ISO_TYPE, currentstruct);
  488 }
  489 
  490 void DrawingOptions::UpdateScriptEditorAndTreeObject()
  491 {
  492     // Update the current Tree Object:
  493     if (ShowCurrentObjectTree)
  494         UpdateTreeObject();
  495     // Update the "Script Edit" page
  496     ui.ParamEdit->setText(MathmodRef->RootObjet.CurrentTreestruct.text);
  497     // Update the "Model Details" page
  498     if (MathmodRef->RootObjet.CurrentJsonObject["ParIso"].isArray())
  499     {
  500         ui.parisocomboBox->clear();
  501         if (MathmodRef->RootObjet.CurrentParisoTreestruct.size() > 0)
  502         {
  503             for (uint i = 0; i < MathmodRef->RootObjet.CurrentParisoTreestruct.size();i++)
  504                 ui.parisocomboBox->insertItem(i, MathmodRef->RootObjet.CurrentParisoTreestruct[i].name[0]);
  505             if (MathmodRef->RootObjet.CurrentParisoTreestruct[0].fxyz.size() != 0)
  506                 UpdateIsoModelDetailsPage(MathmodRef->RootObjet.CurrentParisoTreestruct[0]);
  507             else if (MathmodRef->RootObjet.CurrentParisoTreestruct[0].fw.size() != 0)
  508                 UpdatePar4DModelDetailsPage(MathmodRef->RootObjet.CurrentParisoTreestruct[0]);
  509             else if (MathmodRef->RootObjet.CurrentParisoTreestruct[0].fx.size() != 0)
  510                 UpdatePar3DModelDetailsPage(MathmodRef->RootObjet.CurrentParisoTreestruct[0]);
  511         }
  512     }
  513     else if (MathmodRef->RootObjet.CurrentJsonObject["Iso3D"].isObject())
  514         UpdateIsoModelDetailsPage(MathmodRef->RootObjet.CurrentTreestruct);
  515     else if (MathmodRef->RootObjet.CurrentJsonObject["Param3D"].isObject())
  516         UpdatePar3DModelDetailsPage(MathmodRef->RootObjet.CurrentTreestruct);
  517     else if (MathmodRef->RootObjet.CurrentJsonObject["Param4D"].isObject())
  518         UpdatePar4DModelDetailsPage(MathmodRef->RootObjet.CurrentTreestruct);
  519     else
  520         ui.stackedProperties->setCurrentIndex(0);
  521 }
  522 
  523 void DrawingOptions::HideSliders()
  524 {
  525     ui.groupBox_9->hide();
  526     ui.groupBox_10->hide();
  527     ui.groupBox_11->hide();
  528     ui.groupBox_12->hide();
  529     ui.groupBox_13->hide();
  530     ui.groupBox_14->hide();
  531     ui.groupBox_15->hide();
  532     ui.groupBox_16->hide();
  533     ui.groupBox_17->hide();
  534     ui.groupBox_18->hide();
  535     ui.groupBox_19->hide();
  536     ui.groupBox_20->hide();
  537     ui.groupBox_21->hide();
  538     ui.groupBox_22->hide();
  539     ui.groupBox_23->hide();
  540     ui.groupBox_24->hide();
  541     ui.groupBox_25->hide();
  542     ui.groupBox_26->hide();
  543     ui.groupBox_27->hide();
  544     ui.groupBox_28->hide();
  545     ui.PredefinedSets->clear();
  546     ui.PredefinedSets->addItem("Predefined Sets");
  547     ui.ParametersList->clear();
  548     ui.ParametersList->addItem("Parameters List");
  549     sliderconf.ui.ParametersComboBox->clear();
  550     sliderconf.ui.ParametersComboBox->addItem("Parameters List");
  551 }
  552 
  553 void DrawingOptions::ObjArrayToString(QJsonArray &lst, QString &str)
  554 {
  555     str = "";
  556     for (int j = 0; j < lst.size() - 1; j++)
  557         str += lst[j].toString() + ";";
  558     if (lst.size() >= 1)
  559         str += lst[lst.size() - 1].toString();
  560     str.replace("\n", "");
  561     str.replace("\t", "");
  562     str.replace(" ", "");
  563 }
  564 
  565 void DrawingOptions::ShowSliders(const QJsonObject &Jobj)
  566 {
  567     QString result;
  568     QJsonArray lst;
  569     QJsonObject QObj;
  570     if (Jobj["Sliders"].isObject())
  571     {
  572         // Hide all sliders
  573         HideSliders();
  574         QObj = Jobj["Sliders"].toObject();
  575         // Min
  576         lst = QObj["Min"].toArray();
  577         ObjArrayToString(lst, result);
  578         qlstmin = result.split(";", QString::SkipEmptyParts);
  579         // Max
  580         lst = QObj["Max"].toArray();
  581         ObjArrayToString(lst, result);
  582         qlstmax = result.split(";", QString::SkipEmptyParts);
  583         // Position
  584         lst = QObj["Position"].toArray();
  585         ObjArrayToString(lst, result);
  586         qlstPos = result.split(";", QString::SkipEmptyParts);
  587         for (int i = 0; i < qlstPos.size(); ++i)
  588         {
  589             MathmodRef->IsoObjet->masterthread->SliderValues.push_back(
  590                 qlstPos.at(i).toDouble());
  591             MathmodRef->ParObjet->masterthread->SliderValues.push_back(
  592                 qlstPos.at(i).toDouble());
  593         }
  594         // Name
  595         lst = QObj["Name"].toArray();
  596         ObjArrayToString(lst, result);
  597         qlstnames = result.split(";", QString::SkipEmptyParts);
  598         for (int i = 0; i < qlstnames.size(); ++i)
  599         {
  600             MathmodRef->IsoObjet->masterthread->SliderNames.push_back(
  601                 qlstnames.at(i).toStdString());
  602             MathmodRef->ParObjet->masterthread->SliderNames.push_back(
  603                 qlstnames.at(i).toStdString());
  604         }
  605         MathmodRef->IsoObjet->masterthread->Nb_Sliders =
  606             uint(qlstnames.size());
  607         MathmodRef->ParObjet->masterthread->Nb_Sliders =
  608             uint(qlstnames.size());
  609         ui.ParametersList->clear();
  610         ui.ParametersList->addItem("Parameters List  (" +
  611                                    QString::number(qlstnames.size()) + ")");
  612         ui.ParametersList->addItems(qlstnames);
  613         sliderconf.ui.ParametersComboBox->clear();
  614         sliderconf.ui.ParametersComboBox->addItem(
  615             "Parameters List  (" + QString::number(qlstnames.size()) + ")");
  616         sliderconf.ui.ParametersComboBox->addItems(qlstnames);
  617         // Step
  618         lst = QObj["Step"].toArray();
  619         ObjArrayToString(lst, result);
  620         qlstStep = result.split(";", QString::SkipEmptyParts);
  621         QStringList qlist;
  622         if (qlstPos.size() >= qlstnames.size())
  623         {
  624             ui.PredefinedSets->clear();
  625             int NbSets = (qlstPos.size() == 0 || qlstnames.size() == 0)
  626                          ? 0
  627                          : qlstPos.size() / qlstnames.size();
  628             qlist += "Predefined Sets (" + QString::number(NbSets) + ")";
  629             if (QObj["SetNames"].isArray() &&
  630                     (lst = QObj["SetNames"].toArray()).size())
  631             {
  632                 ObjArrayToString(lst, result);
  633                 qlist += result.split(";", QString::SkipEmptyParts);
  634             }
  635             else
  636             {
  637                 for (int i = 1; i < NbSets + 1; i++)
  638                 {
  639                     qlist += "Set_" + QString::number(i);
  640                 }
  641             }
  642             ui.PredefinedSets->addItems(qlist);
  643         }
  644         for (int sl = 0; sl < 20; sl++)
  645         {
  646             if (qlstnames.size() >= (sl + 1))
  647             {
  648                 (SliderArray[sl].SliderScrollBar)->blockSignals(true);
  649                 (SliderArray[sl].SliderScrollBar)->setMaximum(qlstmax.at(sl).toInt());
  650                 (SliderArray[sl].SliderScrollBar)->setMinimum(qlstmin.at(sl).toInt());
  651                 (SliderArray[sl].SliderScrollBar)
  652                 ->setSingleStep(qlstStep.at(sl).toInt());
  653                 (SliderArray[sl].SliderScrollBar)->setPageStep(qlstStep.at(sl).toInt());
  654                 (SliderArray[sl].SliderScrollBar)
  655                 ->setSliderPosition(qlstPos.at(sl).toInt());
  656                 (SliderArray[sl].SliderLabel)
  657                 ->setText(qlstnames.at(sl) + " = " + qlstPos.at(sl) + "(" +
  658                           qlstStep.at(sl) + ")");
  659                 (SliderArray[sl].SliderLabelMin)->setText(qlstmin.at(sl));
  660                 (SliderArray[sl].SliderLabelMax)->setText(qlstmax.at(sl));
  661                 (SliderArray[sl].SliderScrollBar)->blockSignals(false);
  662                 (SliderArray[sl].SliderGroupeBox)->show();
  663             }
  664         }
  665     }
  666     else
  667     {
  668         MathmodRef->IsoObjet->masterthread->Nb_Sliders = 0;
  669         MathmodRef->ParObjet->masterthread->Nb_Sliders = 0;
  670         HideSliders();
  671     }
  672 }
  673 
  674 void DrawingOptions::DrawJsonModel(const QJsonObject &Jobj, int textureIndex,
  675                                    bool Inspect)
  676 {
  677     if (!MathmodRef->ParObjet->isRunning() &&
  678             !MathmodRef->IsoObjet->isRunning())
  679     {
  680         if (Inspect & !VerifiedJsonModel(Jobj, Inspect))
  681             return;
  682         ShowJsonModel(Jobj, textureIndex);
  683         UpdateScriptEditorAndTreeObject();
  684     }
  685 }
  686 
  687 QString DrawingOptions::MandatoryParFieldToQString(const MandatoryParField &idx)
  688 {
  689     QString arg = "";
  690     switch (idx)
  691     {
  692     case PAR_FX:
  693         arg = "Fx";
  694         break;
  695     case PAR_FY:
  696         arg = "Fy";
  697         break;
  698     case PAR_FZ:
  699         arg = "Fz";
  700         break;
  701     case PAR_FW:
  702         arg = "Fw";
  703         break;
  704     case PAR_UMAX:
  705         arg = "Umax";
  706         break;
  707     case PAR_UMIN:
  708         arg = "Umin";
  709         break;
  710     case PAR_VMAX:
  711         arg = "Vmax";
  712         break;
  713     case PAR_VMIN:
  714         arg = "Vmin";
  715         break;
  716     case PAR_NAME:
  717         arg = "Name";
  718         break;
  719     case PAR_COMP:
  720         arg = "Component";
  721         break;
  722     }
  723     return(arg);
  724 }
  725 
  726 QString DrawingOptions::MandatoryIsoFieldToQString(const MandatoryIsoField &idx)
  727 {
  728     QString arg = "";
  729     switch (idx)
  730     {
  731     case ISO_FXYZ:
  732         arg = "Fxyz";
  733         break;
  734     case ISO_XMAX:
  735         arg = "Xmax";
  736         break;
  737     case ISO_YMAX:
  738         arg = "Ymax";
  739         break;
  740     case ISO_ZMAX:
  741         arg = "Zmax";
  742         break;
  743     case ISO_XMIN:
  744         arg = "Xmin";
  745         break;
  746     case ISO_YMIN:
  747         arg = "Ymin";
  748         break;
  749     case ISO_ZMIN:
  750         arg = "Zmin";
  751         break;
  752     case ISO_NAME:
  753         arg = "Name";
  754         break;
  755     case ISO_COMP:
  756         arg = "Component";
  757         break;
  758     }
  759     return(arg);
  760 }
  761 
  762 bool DrawingOptions::VerifyIsoFieldEmptySpace(const QJsonObject &QObj, const MandatoryIsoField &idx)
  763 {
  764     QString arg = MandatoryIsoFieldToQString(idx);
  765     for(int i=0; i<(QObj[arg].toArray()).size(); i++)
  766     {
  767         if((QObj[arg].toArray())[i].toString().replace(" ","") == "")
  768         {
  769             return false;
  770         }
  771     }
  772     return true;
  773 }
  774 
  775 bool DrawingOptions::VerifyParFieldEmptySpace(const QJsonObject &QObj, const MandatoryParField &idx)
  776 {
  777     QString arg = MandatoryParFieldToQString(idx);
  778     for(int i=0; i<(QObj[arg].toArray()).size(); i++)
  779     {
  780         if((QObj[arg].toArray())[i].toString().replace(" ","") == "")
  781             return false;
  782     }
  783     return true;
  784 }
  785 
  786 bool DrawingOptions::VerifyParEmptySpace(const QJsonObject& QObj)
  787 {
  788     for (std::vector<MandatoryParField>::const_iterator it =
  789                 MandParFields.begin();
  790             it != MandParFields.end(); ++it)
  791     {
  792         MandatoryParField Opt = *it;
  793         if(!VerifyParFieldEmptySpace(QObj, Opt))
  794             return false;
  795     }
  796     return true;
  797 }
  798 
  799 bool DrawingOptions::VerifyIsoEmptySpace(const QJsonObject& QObj)
  800 {
  801     for (std::vector<MandatoryIsoField>::const_iterator it =
  802                 MandIsoFields.begin();
  803             it != MandIsoFields.end(); ++it)
  804     {
  805         MandatoryIsoField Opt = *it;
  806         if(!VerifyIsoFieldEmptySpace(QObj, Opt))
  807             return false;
  808     }
  809     return true;
  810 }
  811 
  812 bool DrawingOptions::VerifiedIsoJsonModel(const QJsonObject &QObj)
  813 {
  814     QJsonArray lst;
  815     int NbFxyz;
  816     if (!VerifyIsoEmptySpace(QObj))
  817     {
  818         scriptErrorType = EMPTY_MANDATORY_FIELD;
  819         ErrorMsg();
  820         return false;
  821     }
  822     // Fxyz
  823     NbFxyz = (QObj["Fxyz"].toArray()).size();
  824     if ((QObj["Xmax"].toArray()).size() != NbFxyz)
  825     {
  826         scriptErrorType = XMAX_NBCOMPONENT_MISMATCH;
  827         ErrorMsg();
  828         return false;
  829     }
  830     if ((QObj["Ymax"].toArray()).size() != NbFxyz)
  831     {
  832         scriptErrorType = YMAX_NBCOMPONENT_MISMATCH;
  833         ErrorMsg();
  834         return false;
  835     }
  836     if ((QObj["Zmax"].toArray()).size() != NbFxyz)
  837     {
  838         scriptErrorType = ZMAX_NBCOMPONENT_MISMATCH;
  839         ErrorMsg();
  840         return false;
  841     }
  842     if ((QObj["Xmin"].toArray()).size() != NbFxyz)
  843     {
  844         scriptErrorType = XMIN_NBCOMPONENT_MISMATCH;
  845         ErrorMsg();
  846         return false;
  847     }
  848     if ((QObj["Ymin"].toArray()).size() != NbFxyz)
  849     {
  850         scriptErrorType = YMIN_NBCOMPONENT_MISMATCH;
  851         ErrorMsg();
  852         return false;
  853     }
  854     if ((QObj["Zmin"].toArray()).size() != NbFxyz)
  855     {
  856         scriptErrorType = ZMIN_NBCOMPONENT_MISMATCH;
  857         ErrorMsg();
  858         return false;
  859     }
  860     if ((QObj["Component"].toArray()).size() != NbFxyz)
  861     {
  862         scriptErrorType = COMPONENT_NBCOMPONENT_MISMATCH;
  863         ErrorMsg();
  864         return false;
  865     }
  866     if (((lst = QObj["Grid"].toArray()).size() > 0) && (lst.size() != NbFxyz))
  867     {
  868         scriptErrorType = GRID_NBCOMPONENT_MISMATCH;
  869         ErrorMsg();
  870         return false;
  871     }
  872     // variables
  873     if (((lst = QObj["Vect"].toArray()).size() > 1))
  874     {
  875         scriptErrorType = VECT_DIMENSION_ERROR;
  876         ErrorMsg();
  877         return false;
  878     }
  879     if (lst.size() > 0)
  880     {
  881         for (int i = 0; i < lst.size(); i++)
  882             if ((lst[i].toString()).toUInt() >= uint(Parameters->IsoMaxGrid))
  883             {
  884                 scriptErrorType = GRID_SUPERIOR_TO_GRIDMAX;
  885                 ErrorMsg();
  886                 return false;
  887             }
  888     }
  889     if (((QObj["Cnd"].toArray()).size() > 0) &&
  890             ((QObj["Cnd"].toArray()).size() != NbFxyz))
  891     {
  892         scriptErrorType = CND_NBCOMPONENT_MISMATCH;
  893         ErrorMsg();
  894         return false;
  895     }
  896     return true;
  897 }
  898 
  899 bool DrawingOptions::VerifiedParJsonModel(const QJsonObject &QObj)
  900 {
  901     QJsonArray lst;
  902     int NbFx;
  903     if (!VerifyParEmptySpace(QObj))
  904     {
  905         scriptErrorType = EMPTY_MANDATORY_FIELD;
  906         ErrorMsg();
  907         return false;
  908     }
  909     // Fx
  910     NbFx = (QObj["Fx"].toArray()).size();
  911     // Fy
  912     if ((QObj["Fy"].toArray()).size() != NbFx)
  913     {
  914         scriptErrorType = FY_FX_MISMATCH;
  915         ErrorMsg();
  916         return false;
  917     }
  918     // Fz
  919     if ((QObj["Fz"].toArray()).size() != NbFx)
  920     {
  921         scriptErrorType = FZ_FX_MISMATCH;
  922         ErrorMsg();
  923         return false;
  924     }
  925     if (((QObj["Fw"].toArray()).size() != 0) &&
  926             ((QObj["Fw"].toArray()).size() != NbFx))
  927     {
  928         scriptErrorType = FW_FX_MISMATCH;
  929         ErrorMsg();
  930         return false;
  931     }
  932     if ((QObj["Umax"].toArray()).size() != NbFx)
  933     {
  934         scriptErrorType = UMAX_NBCOMPONENT_MISMATCH;
  935         ErrorMsg();
  936         return false;
  937     }
  938     if ((QObj["Vmax"].toArray()).size() != NbFx)
  939     {
  940         scriptErrorType = VMAX_NBCOMPONENT_MISMATCH;
  941         ErrorMsg();
  942         return false;
  943     }
  944     if (((QObj["Wmax"].toArray()).size() > 0) &&
  945             ((QObj["Wmax"].toArray()).size() != NbFx))
  946     {
  947         scriptErrorType = WMAX_NBCOMPONENT_MISMATCH;
  948         ErrorMsg();
  949         return false;
  950     }
  951     if ((QObj["Umin"].toArray()).size() != NbFx)
  952     {
  953         scriptErrorType = UMIN_NBCOMPONENT_MISMATCH;
  954         ErrorMsg();
  955         return false;
  956     }
  957     if ((QObj["Vmin"].toArray()).size() != NbFx)
  958     {
  959         scriptErrorType = VMIN_NBCOMPONENT_MISMATCH;
  960         ErrorMsg();
  961         return false;
  962     }
  963     if (((QObj["Wmin"].toArray()).size() > 0) &&
  964             ((QObj["Wmin"].toArray()).size() != NbFx))
  965     {
  966         scriptErrorType = WMIN_NBCOMPONENT_MISMATCH;
  967         ErrorMsg();
  968         return false;
  969     }
  970     if ((QObj["Component"].toArray()).size() != NbFx)
  971     {
  972         scriptErrorType = COMPONENT_NBCOMPONENT_MISMATCH;
  973         ErrorMsg();
  974         return false;
  975     }
  976     // Start Grid field processing
  977     QString result = "";
  978     if ((lst = QObj["Grid"].toArray()).size() > 0 && (lst.size() != 2 * NbFx))
  979     {
  980         scriptErrorType = GRID_NBCOMPONENT_MISMATCH;
  981         ErrorMsg();
  982         return false;
  983     }
  984     if (((lst = QObj["Vect"].toArray()).size() > 1))
  985     {
  986         scriptErrorType = VECT_DIMENSION_ERROR;
  987         ErrorMsg();
  988         return false;
  989     }
  990     if (((QObj["Cnd"].toArray()).size() > 0) &&
  991             ((QObj["Cnd"].toArray()).size() != NbFx))
  992     {
  993         scriptErrorType = CND_NBCOMPONENT_MISMATCH;
  994         ErrorMsg();
  995         return false;
  996     }
  997     return true;
  998 }
  999 
 1000 bool DrawingOptions::VerifiedJsonModel(const QJsonObject &Jobj, bool Inspect)
 1001 {
 1002     QJsonArray lst;
 1003     QJsonObject QObj;
 1004     bool verif = false;
 1005     if (!Inspect)
 1006         return true;
 1007     if (Jobj["Iso3D"].isObject())
 1008     {
 1009         QObj = Jobj["Iso3D"].toObject();
 1010         verif = VerifiedIsoJsonModel(QObj);
 1011         if (verif)
 1012         {
 1013             MathmodRef->LocalScene.componentsinfos.pariso = false;
 1014             MathmodRef->LocalScene.componentsinfos.ParisoNbComponents =1;
 1015             MathmodRef->LocalScene.componentsinfos.ParisoCurrentComponentIndex = 0;
 1016         }
 1017         return (verif);
 1018     }
 1019     if (Jobj["Param3D"].isObject())
 1020     {
 1021         QObj = Jobj["Param3D"].toObject();
 1022         MathmodRef->LocalScene.componentsinfos.ParisoNbComponents = 1;
 1023         verif = VerifiedParJsonModel(QObj);
 1024         if (verif)
 1025         {
 1026             MathmodRef->LocalScene.componentsinfos.pariso = false;
 1027             MathmodRef->LocalScene.componentsinfos.ParisoNbComponents = 1;
 1028             MathmodRef->LocalScene.componentsinfos.ParisoCurrentComponentIndex = 0;
 1029         }
 1030         return (verif);
 1031     }
 1032     if (Jobj["ParIso"].isArray())
 1033     {
 1034         QJsonArray listeObj = Jobj["ParIso"].toArray();
 1035         QJsonArray listeIsoObj;
 1036         QJsonArray listeParObj;
 1037         for (int i = 0; i < listeObj.size(); i++)
 1038             if ((listeObj[i].toObject())["Iso3D"].isObject())
 1039                 listeIsoObj.append(listeObj[i].toObject()["Iso3D"].toObject());
 1040             else
 1041                 listeParObj.append(listeObj[i].toObject()["Param3D"].toObject());
 1042         MathmodRef->LocalScene.componentsinfos.pariso = true;
 1043         MathmodRef->LocalScene.componentsinfos.ParisoNbComponents = listeIsoObj.size() + listeParObj.size();
 1044         MathmodRef->LocalScene.componentsinfos.ParisoCurrentComponentIndex = 0;
 1045         for (int i = 0; i < listeIsoObj.size(); i++)
 1046             if (!VerifiedIsoJsonModel(listeIsoObj[i].toObject()))
 1047                 return (false);
 1048         for (int i = 0; i < listeParObj.size(); i++)
 1049             if (!VerifiedParJsonModel(listeParObj[i].toObject()))
 1050                 return (false);
 1051     }
 1052     return true;
 1053 }
 1054 
 1055 void DrawingOptions::LoadTexture(const QJsonObject &QObj,
 1056                                  const ModelType &opt)
 1057 {
 1058     QString noise1 = QObj["Noise"].toString();
 1059     QJsonArray lst = QObj["Colors"].toArray();
 1060     noise1.replace("\n", "");
 1061     noise1.replace("\t", "");
 1062     noise1.replace(" ", "");
 1063     QString result;
 1064     ObjArrayToString(lst, result);
 1065     if (opt == ISO_TYPE)
 1066     {
 1067         MathmodRef->IsoObjet->masterthread->Rgbt = result.toStdString();
 1068         MathmodRef->IsoObjet->masterthread->Noise = noise1.toStdString();
 1069         MathmodRef->IsoObjet->masterthread->RgbtSize = uint(lst.size());
 1070     }
 1071     else if (opt == PAR_TYPE || opt == PAR_4D_TYPE)
 1072     {
 1073         MathmodRef->ParObjet->masterthread->Rgbt = result.toStdString();
 1074         MathmodRef->ParObjet->masterthread->Noise = noise1.toStdString();
 1075         MathmodRef->ParObjet->masterthread->RgbtSize = uint(lst.size());
 1076     }
 1077     MathmodRef->RootObjet.CurrentTreestruct.Noise = noise1;
 1078     MathmodRef->RootObjet.CurrentTreestruct.RGBT = result.split(";", QString::SkipEmptyParts);
 1079 }
 1080 
 1081 void DrawingOptions::LoadPigment(const QJsonObject &QObj,
 1082                                  const ModelType &opt)
 1083 {
 1084     QString noise = "";
 1085     QJsonArray tmp;
 1086     QString strtmp = QObj["Gradient"].toString();
 1087     noise = QObj["Noise"].toString();
 1088     QJsonArray lst = QObj["Colors"].toArray();
 1089     QString result = "";
 1090     int VRgbtSize = 0;
 1091     for (int j = 0; j < lst.size(); j++)
 1092     {
 1093         tmp = (lst[j].toObject())["Color"].toObject()["Vrgba"].toArray();
 1094         for (int k = 0; k < tmp.count(); k++)
 1095         {
 1096             result += tmp[k].toString() + ";";
 1097             VRgbtSize++;
 1098         }
 1099     }
 1100     strtmp.replace("\n", "");
 1101     strtmp.replace("\t", "");
 1102     strtmp.replace(" ", "");
 1103     noise.replace("\n", "");
 1104     noise.replace("\t", "");
 1105     noise.replace(" ", "");
 1106     result.replace("\n", "");
 1107     result.replace("\t", "");
 1108     result.replace(" ", "");
 1109     if (opt == ISO_TYPE)
 1110     {
 1111         MathmodRef->IsoObjet->masterthread->Gradient = strtmp.toStdString();
 1112         MathmodRef->IsoObjet->masterthread->VRgbt = result.toStdString();
 1113         MathmodRef->IsoObjet->masterthread->Noise = noise.toStdString();
 1114         MathmodRef->IsoObjet->masterthread->VRgbtSize = uint(VRgbtSize);
 1115     }
 1116     else if (opt == PAR_TYPE || opt == PAR_4D_TYPE)
 1117     {
 1118         MathmodRef->ParObjet->masterthread->Gradient = strtmp.toStdString();
 1119         MathmodRef->ParObjet->masterthread->VRgbt = result.toStdString();
 1120         MathmodRef->ParObjet->masterthread->Noise = noise.toStdString();
 1121         MathmodRef->ParObjet->masterthread->VRgbtSize = uint(VRgbtSize);
 1122     }
 1123     MathmodRef->RootObjet.CurrentTreestruct.Noise = noise;
 1124     MathmodRef->RootObjet.CurrentTreestruct.VRGBT =
 1125         result.split(";", QString::SkipEmptyParts);
 1126 }
 1127 
 1128 void DrawingOptions::ShowJsonModel(const QJsonObject &Jobj, int textureIndex)
 1129 {
 1130     QString result;
 1131     QJsonArray lst;
 1132     QJsonObject QObj, QIso, QPar;
 1133     QJsonObject QTextureObj, QPigmentObj;
 1134     bool loadtext, loadpigm;
 1135     QJsonDocument document;
 1136     if (textureIndex != -1)
 1137     {
 1138         if (textureIndex < 1000)
 1139             QTextureObj = MathmodRef->collection.JTextures[textureIndex]
 1140                           .toObject()["Texture"]
 1141                           .toObject();
 1142         else
 1143             QPigmentObj = MathmodRef->collection.JPigments[textureIndex - 1000]
 1144                           .toObject()["Pigment"]
 1145                           .toObject();
 1146     }
 1147     else
 1148     {
 1149         if (Jobj["Texture"].isObject())
 1150             QTextureObj = Jobj["Texture"].toObject();
 1151 
 1152         if (Jobj["Pigment"].isObject())
 1153             QPigmentObj = Jobj["Pigment"].toObject();
 1154     }
 1155 
 1156     ShowSliders(Jobj);
 1157     updateCurrentTreestruct();
 1158     MathmodRef->LocalScene.componentsinfos.ParisoCondition.clear();
 1159     if (Jobj["ParIso"].isArray())
 1160     {
 1161         QJsonArray listeObj = Jobj["ParIso"].toArray();
 1162         QJsonArray listeIsoObj;
 1163         QJsonArray listeParObj;
 1164         for (int i = 0; i < listeObj.size(); i++)
 1165             if ((listeObj[i].toObject())["Iso3D"].isObject())
 1166                 listeIsoObj.append(listeObj[i].toObject());
 1167             else
 1168                 listeParObj.append(listeObj[i].toObject());
 1169         // Right now, we only support pariso object with 1 Iso3D and 1 Param3D objects.
 1170         if (listeParObj.size() > 0)
 1171             QPar = listeParObj[0].toObject();
 1172         if (listeIsoObj.size() > 0)
 1173             QIso = listeIsoObj[0].toObject();
 1174 
 1175         loadtext = loadpigm = false;
 1176         if (QPar["Texture"].isObject())
 1177             QTextureObj = QPar["Texture"].toObject();
 1178         if (QPar["Pigment"].isObject())
 1179             QPigmentObj = QPar["Pigment"].toObject();
 1180         // Colors
 1181         loadtext = MathmodRef->ParObjet->masterthread->rgbtnotnull =
 1182                        (QPar["Texture"].isObject() ||
 1183                         ((textureIndex < 1000) && (textureIndex != -1)));
 1184         // Pigment
 1185         loadpigm = MathmodRef->ParObjet->masterthread->vrgbtnotnull =
 1186                        (QPar["Pigment"].isObject() ||
 1187                         ((textureIndex != -1) && (textureIndex > 999)));
 1188         LoadMandatoryAndOptionnalFields(QPar["Param3D"].toObject(), PAR_TYPE,
 1189                                         loadtext, QTextureObj, loadpigm,
 1190                                         QPigmentObj);
 1191         // Save this Current Parametric Tree struct
 1192         MathmodRef->RootObjet.CurrentParisoTreestruct.push_back(
 1193             MathmodRef->RootObjet.CurrentTreestruct);
 1194 
 1195         loadtext = loadpigm = false;
 1196         if (QIso["Texture"].isObject())
 1197             QTextureObj = QIso["Texture"].toObject();
 1198         if (QIso["Pigment"].isObject())
 1199             QPigmentObj = QIso["Pigment"].toObject();
 1200         // Colors
 1201         loadtext = MathmodRef->IsoObjet->masterthread->rgbtnotnull =
 1202                        (QIso["Texture"].isObject() ||
 1203                         ((textureIndex < 1000) && (textureIndex != -1)));
 1204         // Pigment
 1205         loadpigm = MathmodRef->IsoObjet->masterthread->vrgbtnotnull =
 1206                        (QIso["Pigment"].isObject() ||
 1207                         ((textureIndex != -1) && (textureIndex > 999)));
 1208         LoadMandatoryAndOptionnalFields(QIso["Iso3D"].toObject(), ISO_TYPE,
 1209                                         loadtext, QTextureObj, loadpigm,
 1210                                         QPigmentObj);
 1211         // Save this Current Isosurface Tree struct
 1212         MathmodRef->RootObjet.CurrentParisoTreestruct.push_back(
 1213             MathmodRef->RootObjet.CurrentTreestruct);
 1214 
 1215         document.setObject(Jobj);
 1216         MathmodRef->RootObjet.CurrentTreestruct.text = QString(document.toJson());
 1217 
 1218         // Update the current pariso struct
 1219         MathmodRef->RootObjet.CurrentJsonObject = Jobj;
 1220         CurrentFormulaType = 2;
 1221         /// process the new surface
 1222         if (textureIndex == -1)
 1223         {
 1224             MathmodRef->LocalScene.componentsinfos.pariso = true;
 1225             MathmodRef->ParisoObjectProcess();
 1226         }
 1227 
 1228         ui.parisogroupbox->show();
 1229     }
 1230     else
 1231     {
 1232         ui.parisogroupbox->hide();
 1233         MathmodRef->LocalScene.componentsinfos.pariso = false;
 1234         if (Jobj["Iso3D"].isObject())
 1235         {
 1236             QObj = Jobj["Iso3D"].toObject();
 1237 
 1238             // Colors
 1239             loadtext = MathmodRef->IsoObjet->masterthread->rgbtnotnull =
 1240                            (Jobj["Texture"].isObject() ||
 1241                             ((textureIndex < 1000) && (textureIndex != -1)));
 1242 
 1243             // Pigment
 1244             loadpigm = MathmodRef->IsoObjet->masterthread->vrgbtnotnull =
 1245                            (Jobj["Pigment"].isObject() ||
 1246                             ((textureIndex != -1) && (textureIndex > 999)));
 1247 
 1248             LoadMandatoryAndOptionnalFields(QObj, ISO_TYPE, loadtext, QTextureObj,
 1249                                             loadpigm, QPigmentObj);
 1250 
 1251             QJsonObject Jobjtmp = Jobj;
 1252             // Some keys cleaning..
 1253             Jobjtmp.remove("ParIso");
 1254             Jobjtmp.remove("Param3D");
 1255             Jobjtmp.remove("Param4D");
 1256             document.setObject(Jobjtmp);
 1257             MathmodRef->RootObjet.CurrentTreestruct.text = QString(document.toJson());
 1258 
 1259             // Update the current parametric struct
 1260             MathmodRef->RootObjet.CurrentJsonObject = Jobjtmp;
 1261             CurrentFormulaType = 2;
 1262             /// process the new surface
 1263             if (textureIndex == -1)
 1264             {
 1265                 if (MathmodRef->RootObjet.CurrentTreestruct.fxyz.count() > 0)
 1266                     MathmodRef->ProcessNewIsoSurface();
 1267             }
 1268             else
 1269             {
 1270                 int result = MathmodRef->ParseIso();
 1271                 if (result == -1)
 1272                     return;
 1273                 textureIndex < 1000
 1274                 ? MathmodRef->CalculateTexturePoints(1)
 1275                 : MathmodRef->CalculatePigmentPoints(1);
 1276                 MathmodRef->LocalScene.componentsinfos.Interleave=true;
 1277                 MathmodRef->update();
 1278             }
 1279         }
 1280         else if (Jobj["Param3D"].isObject())
 1281         {
 1282             QObj = Jobj["Param3D"].toObject();
 1283             // Colors
 1284             loadtext = MathmodRef->ParObjet->masterthread->rgbtnotnull =
 1285                            (Jobj["Texture"].isObject() ||
 1286                             ((textureIndex < 1000) && (textureIndex != -1)));
 1287 
 1288             // Pigment
 1289             loadpigm = MathmodRef->ParObjet->masterthread->vrgbtnotnull =
 1290                            (Jobj["Pigment"].isObject() ||
 1291                             ((textureIndex != -1) && (textureIndex > 999)));
 1292 
 1293             LoadMandatoryAndOptionnalFields(QObj, PAR_TYPE, loadtext, QTextureObj,
 1294                                             loadpigm, QPigmentObj);
 1295 
 1296             QJsonObject Jobjtmp = Jobj;
 1297             // Some keys cleaning..
 1298             Jobjtmp.remove("ParIso");
 1299             Jobjtmp.remove("Iso3D");
 1300             Jobjtmp.remove("Param4D");
 1301 
 1302             QJsonDocument document;
 1303             document.setObject(Jobjtmp);
 1304             MathmodRef->RootObjet.CurrentTreestruct.text = QString(document.toJson());
 1305 
 1306             MathmodRef->RootObjet.CurrentJsonObject = Jobjtmp;
 1307             CurrentFormulaType = 1;
 1308             /// process the new surface
 1309             if (textureIndex == -1)
 1310             {
 1311                 MathmodRef->ParametricSurfaceProcess(1);
 1312             }
 1313             else
 1314             {
 1315                 int result = MathmodRef->ParsePar();
 1316                 if (result == -1)
 1317                     return;
 1318                 textureIndex < 1000
 1319                 ? MathmodRef->CalculateTexturePoints(0)
 1320                 : MathmodRef->CalculatePigmentPoints(0);
 1321                 MathmodRef->LocalScene.componentsinfos.Interleave=true;
 1322                 MathmodRef->update();
 1323             }
 1324         }
 1325 
 1326         else if (Jobj["Param4D"].isObject())
 1327         {
 1328             QObj = Jobj["Param4D"].toObject();
 1329 
 1330             // Colors
 1331             loadtext = MathmodRef->ParObjet->masterthread->rgbtnotnull =
 1332                            (Jobj["Texture"].isObject() ||
 1333                             ((textureIndex < 1000) && (textureIndex != -1)));
 1334 
 1335             // Pigment
 1336             loadpigm = MathmodRef->ParObjet->masterthread->vrgbtnotnull =
 1337                            (Jobj["Pigment"].isObject() ||
 1338                             ((textureIndex != -1) && (textureIndex > 1000)));
 1339 
 1340             LoadMandatoryAndOptionnalFields(QObj, PAR_4D_TYPE, loadtext, QTextureObj,
 1341                                             loadpigm, QPigmentObj);
 1342 
 1343             QJsonObject Jobjtmp = Jobj;
 1344             // Some keys cleaning..
 1345             Jobjtmp.remove("Iso3D");
 1346             Jobjtmp.remove("Param3D");
 1347 
 1348             QJsonDocument document;
 1349             document.setObject(Jobjtmp);
 1350             MathmodRef->RootObjet.CurrentTreestruct.text = QString(document.toJson());
 1351 
 1352             MathmodRef->RootObjet.CurrentJsonObject = Jobjtmp;
 1353             CurrentFormulaType = 3;
 1354 
 1355             /// process the new surface
 1356             if (textureIndex == -1)
 1357             {
 1358                 MathmodRef->ParametricSurfaceProcess(3);
 1359             }
 1360             else
 1361             {
 1362                 int result = MathmodRef->ParsePar();
 1363                 if (result == -1)
 1364                     return;
 1365                 textureIndex < 1000
 1366                 ? MathmodRef->CalculateTexturePoints(0)
 1367                 : MathmodRef->CalculatePigmentPoints(0);
 1368                 MathmodRef->LocalScene.componentsinfos.Interleave=true;
 1369                 MathmodRef->update();
 1370             }
 1371         }
 1372     }
 1373 }
 1374 
 1375 void DrawingOptions::updateCurrentTreestruct()
 1376 {
 1377     // Initialize the current Object struct
 1378     MathmodRef->RootObjet.CurrentTreestruct
 1379     .fw = MathmodRef->RootObjet.CurrentTreestruct
 1380     .fx = MathmodRef->RootObjet.CurrentTreestruct
 1381     .fy = MathmodRef->RootObjet.CurrentTreestruct.fz =
 1382     MathmodRef->RootObjet.CurrentTreestruct
 1383     .Cnd = MathmodRef->RootObjet.CurrentTreestruct
 1384     .RGBT = MathmodRef->RootObjet.CurrentTreestruct.Const =
 1385     MathmodRef->RootObjet.CurrentTreestruct
 1386     .Funct = MathmodRef->RootObjet.CurrentTreestruct.VRGBT =
 1387     MathmodRef->RootObjet.CurrentTreestruct
 1388     .Gradient = MathmodRef->RootObjet.CurrentTreestruct.fxyz =
 1389     MathmodRef->RootObjet.CurrentTreestruct
 1390     .umin = MathmodRef->RootObjet.CurrentTreestruct.umax =
 1391     MathmodRef->RootObjet.CurrentTreestruct
 1392     .vmin = MathmodRef->RootObjet.CurrentTreestruct.vmax =
 1393     MathmodRef->RootObjet.CurrentTreestruct
 1394     .xmin = MathmodRef->RootObjet.CurrentTreestruct
 1395     .xmax = MathmodRef->RootObjet
 1396     .CurrentTreestruct.ymin =
 1397     MathmodRef->RootObjet.CurrentTreestruct.ymax =
 1398     MathmodRef->RootObjet.CurrentTreestruct.zmin = MathmodRef->RootObjet
 1399     .CurrentTreestruct.zmax = MathmodRef->RootObjet.CurrentTreestruct.tmin = MathmodRef->RootObjet
 1400     .CurrentTreestruct.tmax = MathmodRef->RootObjet
 1401     .CurrentTreestruct.name = MathmodRef->RootObjet
 1402     .CurrentTreestruct.Component = MathmodRef->RootObjet
 1403     .CurrentTreestruct.Grid = QStringList();
 1404     MathmodRef->RootObjet.CurrentTreestruct.Noise =
 1405         MathmodRef->RootObjet.CurrentTreestruct.text = "";
 1406     MathmodRef->RootObjet.CurrentTreestruct.type = UNDEFINED_TYPE;
 1407     // Initialize the current JSON Object
 1408     MathmodRef->RootObjet.CurrentJsonObject = QJsonObject();
 1409     // Initialize the Current Pariso Trees truct
 1410     MathmodRef->RootObjet.CurrentParisoTreestruct.clear();
 1411 }
 1412 
 1413 
 1414 void DrawingOptions::MandatoryParFieldprocess(const QJsonObject &QObj,
 1415         const MandatoryParField &idx,
 1416         const ModelType &mod)
 1417 {
 1418     QString result, arg = MandatoryParFieldToQString(idx);
 1419     QJsonArray lst;
 1420 
 1421     lst = QObj[arg].toArray();
 1422     ObjArrayToString(lst, result);
 1423     switch (idx)
 1424     {
 1425     case PAR_FX:
 1426         MathmodRef->ParObjet->masterthread->expression_X =
 1427             result.toStdString();
 1428         MathmodRef->ParObjet->masterthread->componentsNumber =
 1429             uint(lst.size());
 1430         MathmodRef->RootObjet.CurrentTreestruct.fx =
 1431             result.split(";", QString::SkipEmptyParts);
 1432         break;
 1433     case PAR_FY:
 1434         MathmodRef->ParObjet->masterthread->expression_Y =
 1435             result.toStdString();
 1436         MathmodRef->ParObjet->masterthread->expression_YSize =
 1437             lst.size();
 1438         MathmodRef->RootObjet.CurrentTreestruct.fy =
 1439             result.split(";", QString::SkipEmptyParts);
 1440         break;
 1441     case PAR_FZ:
 1442         MathmodRef->ParObjet->masterthread->expression_Z =
 1443             result.toStdString();
 1444         MathmodRef->ParObjet->masterthread->expression_ZSize =
 1445             lst.size();
 1446         MathmodRef->RootObjet.CurrentTreestruct.fz =
 1447             result.split(";", QString::SkipEmptyParts);
 1448         break;
 1449     case PAR_FW:
 1450         if (mod == PAR_4D_TYPE)
 1451         {
 1452             MathmodRef->ParObjet->masterthread->expression_W =
 1453                 result.toStdString();
 1454             MathmodRef->RootObjet.CurrentTreestruct.fw =
 1455                 result.split(";", QString::SkipEmptyParts);
 1456         }
 1457         break;
 1458     case PAR_UMIN:
 1459         MathmodRef->ParObjet->masterthread->inf_u =
 1460             result.toStdString();
 1461         MathmodRef->RootObjet.CurrentTreestruct.umin =
 1462             result.split(";", QString::SkipEmptyParts);
 1463         break;
 1464     case PAR_UMAX:
 1465         MathmodRef->ParObjet->masterthread->sup_u =
 1466             result.toStdString();
 1467         MathmodRef->RootObjet.CurrentTreestruct.umax =
 1468             result.split(";", QString::SkipEmptyParts);
 1469         break;
 1470     case PAR_VMAX:
 1471         MathmodRef->ParObjet->masterthread->sup_v =
 1472             result.toStdString();
 1473         MathmodRef->RootObjet.CurrentTreestruct.vmax =
 1474             result.split(";", QString::SkipEmptyParts);
 1475         break;
 1476     case PAR_VMIN:
 1477         MathmodRef->ParObjet->masterthread->inf_v =
 1478             result.toStdString();
 1479         MathmodRef->RootObjet.CurrentTreestruct.vmin =
 1480             result.split(";", QString::SkipEmptyParts);
 1481         break;
 1482     case PAR_COMP:
 1483         MathmodRef->RootObjet.CurrentTreestruct.Component =
 1484             result.split(";", QString::SkipEmptyParts);
 1485         break;
 1486     case PAR_NAME:
 1487         MathmodRef->RootObjet.CurrentTreestruct.name =
 1488             result.split(";", QString::SkipEmptyParts);
 1489         break;
 1490     }
 1491 }
 1492 
 1493 
 1494 void DrawingOptions::MandatoryIsoFieldprocess(const QJsonObject &QObj,
 1495         const MandatoryIsoField &idx)
 1496 {
 1497     QString result, arg = MandatoryIsoFieldToQString(idx);
 1498     QJsonArray lst;
 1499 
 1500     lst = QObj[arg].toArray();
 1501     ObjArrayToString(lst, result);
 1502     switch (idx)
 1503     {
 1504     case ISO_FXYZ:
 1505         MathmodRef->IsoObjet->masterthread->ImplicitFunction =
 1506             result.toStdString();
 1507         MathmodRef->IsoObjet->masterthread->componentsNumber =
 1508             uint(lst.size());
 1509         MathmodRef->RootObjet.CurrentTreestruct.fxyz =
 1510             result.split(";", QString::SkipEmptyParts);
 1511         break;
 1512     case ISO_XMAX:
 1513         MathmodRef->IsoObjet->masterthread->XlimitSup =
 1514             result.toStdString();
 1515         MathmodRef->RootObjet.CurrentTreestruct.xmax =
 1516             result.split(";", QString::SkipEmptyParts);
 1517         break;
 1518     case ISO_YMAX:
 1519         MathmodRef->IsoObjet->masterthread->YlimitSup =
 1520             result.toStdString();
 1521         MathmodRef->RootObjet.CurrentTreestruct.ymax =
 1522             result.split(";", QString::SkipEmptyParts);
 1523         break;
 1524     case ISO_ZMAX:
 1525         MathmodRef->IsoObjet->masterthread->ZlimitSup =
 1526             result.toStdString();
 1527         MathmodRef->RootObjet.CurrentTreestruct.zmax =
 1528             result.split(";", QString::SkipEmptyParts);
 1529         break;
 1530     case ISO_XMIN:
 1531         MathmodRef->IsoObjet->masterthread->XlimitInf =
 1532             result.toStdString();
 1533         MathmodRef->RootObjet.CurrentTreestruct.xmin =
 1534             result.split(";", QString::SkipEmptyParts);
 1535         break;
 1536     case ISO_YMIN:
 1537         MathmodRef->IsoObjet->masterthread->YlimitInf =
 1538             result.toStdString();
 1539         MathmodRef->RootObjet.CurrentTreestruct.ymin =
 1540             result.split(";", QString::SkipEmptyParts);
 1541         break;
 1542     case ISO_ZMIN:
 1543         MathmodRef->IsoObjet->masterthread->ZlimitInf =
 1544             result.toStdString();
 1545         MathmodRef->RootObjet.CurrentTreestruct.zmin =
 1546             result.split(";", QString::SkipEmptyParts);
 1547         break;
 1548     case ISO_COMP:
 1549         MathmodRef->RootObjet.CurrentTreestruct.Component =
 1550             result.split(";", QString::SkipEmptyParts);
 1551         break;
 1552     case ISO_NAME:
 1553         MathmodRef->RootObjet.CurrentTreestruct.name =
 1554             result.split(";", QString::SkipEmptyParts);
 1555         break;
 1556     }
 1557 }
 1558 
 1559 void DrawingOptions::OptionalIsoScriptFieldprocess(
 1560     const QJsonObject &QObj, OptionnalIsoScriptFIELD idx)
 1561 {
 1562     QString result, arg = "";
 1563     QJsonArray lst;
 1564     bool argnotnull = false;
 1565     switch (idx)
 1566     {
 1567     case ISO_VECT:
 1568         arg = "Vect";
 1569         argnotnull = MathmodRef->IsoObjet->masterthread->vectnotnull =
 1570                          QObj[arg].isArray();
 1571         break;
 1572     case ISO_GRID:
 1573         arg = "Grid";
 1574         argnotnull = MathmodRef->IsoObjet->masterthread->gridnotnull =
 1575                          QObj[arg].isArray();
 1576         break;
 1577     case ISO_CND:
 1578         arg = "Cnd";
 1579         argnotnull = MathmodRef->IsoObjet->masterthread->cndnotnull =
 1580                          QObj[arg].isArray();
 1581         break;
 1582     case ISO_CONST:
 1583         arg = "Const";
 1584         argnotnull = MathmodRef->IsoObjet->masterthread->constnotnull =
 1585                          QObj[arg].isArray();
 1586         break;
 1587     case ISO_FUNCT:
 1588         arg = "Funct";
 1589         argnotnull = MathmodRef->IsoObjet->masterthread->functnotnull =
 1590                          QObj[arg].isArray();
 1591         break;
 1592     }
 1593     if (argnotnull)
 1594     {
 1595         lst = QObj[arg].toArray();
 1596         ObjArrayToString(lst, result);
 1597     }
 1598     switch (idx)
 1599     {
 1600     case ISO_VECT:
 1601         if (argnotnull)
 1602         {
 1603             MathmodRef->IsoObjet->masterthread->vect.clear();
 1604             for (int j = 0; j < lst.size(); j++)
 1605                 MathmodRef->IsoObjet->masterthread->vect.push_back(
 1606                     (lst[j].toString()).toUInt());
 1607             MathmodRef->IsoObjet->masterthread->Vect =
 1608                 result.toStdString();
 1609             MathmodRef->RootObjet.CurrentTreestruct.Vect =
 1610                 result.split(";", QString::SkipEmptyParts);
 1611         }
 1612         else
 1613         {
 1614             MathmodRef->IsoObjet->masterthread->Vect = "";
 1615         }
 1616         break;
 1617     case ISO_GRID:
 1618         if (argnotnull)
 1619         {
 1620             MathmodRef->IsoObjet->masterthread->grid.clear();
 1621             for (int j = 0; j < lst.size(); j++)
 1622                 MathmodRef->IsoObjet->masterthread->grid.push_back(
 1623                     (lst[j].toString()).toUInt());
 1624             MathmodRef->IsoObjet->masterthread->Grid =
 1625                 result.toStdString();
 1626             MathmodRef->RootObjet.CurrentTreestruct.Grid =
 1627                 result.split(";", QString::SkipEmptyParts);
 1628         }
 1629         else
 1630         {
 1631             MathmodRef->IsoObjet->masterthread->Grid = "";
 1632         }
 1633         break;
 1634     case ISO_CND:
 1635         if (argnotnull)
 1636         {
 1637             MathmodRef->IsoObjet->masterthread->Condition = result.toStdString();
 1638             for(int i=0; i<lst.size(); i++)
 1639                 MathmodRef->LocalScene.componentsinfos.ParisoCondition.push_back((lst[i].toString()).replace(" ", "")=="");
 1640             MathmodRef->RootObjet.CurrentTreestruct.Cnd = result.split(";");
 1641         }
 1642         else
 1643         {
 1644             for(int i=0; i<lst.size(); i++)
 1645                 MathmodRef->LocalScene.componentsinfos.ParisoCondition.push_back(false);
 1646             MathmodRef->IsoObjet->masterthread->Condition = "";
 1647         }
 1648         break;
 1649     case ISO_FUNCT:
 1650         if (argnotnull)
 1651         {
 1652             MathmodRef->IsoObjet->masterthread->Funct = result.toStdString();
 1653             MathmodRef->IsoObjet->masterthread->FunctSize = uint(lst.size());
 1654             MathmodRef->RootObjet.CurrentTreestruct.Funct = result.split(";", QString::SkipEmptyParts);
 1655         }
 1656         else
 1657         {
 1658             MathmodRef->IsoObjet->masterthread->Funct = "";
 1659             MathmodRef->IsoObjet->masterthread->FunctSize = 0;
 1660         }
 1661         break;
 1662     case ISO_CONST:
 1663         if (argnotnull)
 1664         {
 1665             MathmodRef->IsoObjet->masterthread->Const =
 1666                 result.toStdString();
 1667             MathmodRef->IsoObjet->masterthread->ConstSize =
 1668                 uint(lst.size());
 1669             MathmodRef->RootObjet.CurrentTreestruct.Const =
 1670                 result.split(";", QString::SkipEmptyParts);
 1671         }
 1672         else
 1673         {
 1674             MathmodRef->IsoObjet->masterthread->Const = "";
 1675             MathmodRef->IsoObjet->masterthread->ConstSize = 0;
 1676         }
 1677         break;
 1678     }
 1679 }
 1680 
 1681 void DrawingOptions::OptionalParScriptFieldprocess(
 1682     const QJsonObject &QObj, OptionnalParScriptFIELD idx)
 1683 {
 1684     QString result, arg = "";
 1685     QJsonArray lst;
 1686     bool argnotnull = false;
 1687     switch (idx)
 1688     {
 1689     case PAR_VECT:
 1690         arg = "Vect";
 1691         argnotnull = MathmodRef->ParObjet->masterthread->vectnotnull =
 1692                          QObj[arg].isArray();
 1693         break;
 1694     case PAR_GRID:
 1695         arg = "Grid";
 1696         argnotnull = MathmodRef->ParObjet->masterthread->gridnotnull =
 1697                          QObj[arg].isArray();
 1698         break;
 1699     case PAR_CONST:
 1700         arg = "Const";
 1701         argnotnull = MathmodRef->ParObjet->masterthread->constnotnull =
 1702                          QObj[arg].isArray();
 1703         break;
 1704     case PAR_FUNCT:
 1705         arg = "Funct";
 1706         argnotnull = MathmodRef->ParObjet->masterthread->functnotnull =
 1707                          QObj[arg].isArray();
 1708         break;
 1709     case PAR_CND:
 1710         arg = "Cnd";
 1711         argnotnull = MathmodRef->ParObjet->masterthread->cndnotnull =
 1712                          QObj[arg].isArray();
 1713         break;
 1714     }
 1715     if (argnotnull)
 1716     {
 1717         lst = QObj[arg].toArray();
 1718         ObjArrayToString(lst, result);
 1719     }
 1720     switch (idx)
 1721     {
 1722     case PAR_VECT:
 1723         if (argnotnull)
 1724         {
 1725             MathmodRef->ParObjet->masterthread->vect.clear();
 1726             for (int j = 0; j < lst.size(); j++)
 1727                 MathmodRef->ParObjet->masterthread->vect.push_back(
 1728                     (lst[j].toString()).toUInt());
 1729             MathmodRef->ParObjet->masterthread->Vect =
 1730                 result.toStdString();
 1731             MathmodRef->RootObjet.CurrentTreestruct.Vect =
 1732                 result.split(";", QString::SkipEmptyParts);
 1733         }
 1734         else
 1735         {
 1736             MathmodRef->ParObjet->masterthread->Vect = "";
 1737         }
 1738         break;
 1739     case PAR_GRID:
 1740         if (argnotnull)
 1741         {
 1742             MathmodRef->ParObjet->masterthread->grid.clear();
 1743             for (int j = 0; j < lst.size(); j++)
 1744                 MathmodRef->ParObjet->masterthread->grid.push_back(
 1745                     (lst[j].toString()).toUInt());
 1746             MathmodRef->ParObjet->masterthread->Grid =
 1747                 result.toStdString();
 1748             MathmodRef->RootObjet.CurrentTreestruct.Grid =
 1749                 result.split(";", QString::SkipEmptyParts);
 1750         }
 1751         else
 1752         {
 1753             MathmodRef->ParObjet->masterthread->Grid = "";
 1754         }
 1755         break;
 1756     case PAR_CND:
 1757         if (argnotnull)
 1758         {
 1759             MathmodRef->ParObjet->masterthread->expression_CND = result.toStdString();
 1760             for(int i=0; i<lst.size(); i++)
 1761                 MathmodRef->LocalScene.componentsinfos.ParisoCondition.push_back((lst[i].toString()).replace(" ", "") == "");
 1762             MathmodRef->RootObjet.CurrentTreestruct.Cnd = result.split(";");
 1763         }
 1764         else
 1765         {
 1766             for(int i=0; i<lst.size(); i++)
 1767                 MathmodRef->LocalScene.componentsinfos.ParisoCondition.push_back(false);
 1768             MathmodRef->ParObjet->masterthread->expression_CND = "";
 1769         }
 1770         break;
 1771     case PAR_CONST:
 1772         if (argnotnull)
 1773         {
 1774             MathmodRef->ParObjet->masterthread->Const = result.toStdString();
 1775             MathmodRef->ParObjet->masterthread->ConstSize = uint(lst.size());
 1776             MathmodRef->RootObjet.CurrentTreestruct.Const = result.split(";", QString::SkipEmptyParts);
 1777         }
 1778         else
 1779         {
 1780             MathmodRef->ParObjet->masterthread->Const = "";
 1781             MathmodRef->ParObjet->masterthread->ConstSize = 0;
 1782         }
 1783         break;
 1784     case PAR_FUNCT:
 1785         if (argnotnull)
 1786         {
 1787             MathmodRef->ParObjet->masterthread->Funct =
 1788                 result.toStdString();
 1789             MathmodRef->ParObjet->masterthread->FunctSize =
 1790                 uint(lst.size());
 1791             MathmodRef->RootObjet.CurrentTreestruct.Funct =
 1792                 result.split(";", QString::SkipEmptyParts);
 1793         }
 1794         else
 1795         {
 1796             MathmodRef->ParObjet->masterthread->Funct = "";
 1797             MathmodRef->ParObjet->masterthread->FunctSize = 0;
 1798         }
 1799         break;
 1800     }
 1801 }
 1802 
 1803 void DrawingOptions::BuildAllVect()
 1804 {
 1805     const OptionnalIsoScriptFIELD optiso[] = {ISO_GRID, ISO_VECT, ISO_CND, ISO_CONST, ISO_FUNCT};
 1806     OptIsoFields = std::vector<OptionnalIsoScriptFIELD>(
 1807                        optiso, optiso + sizeof(optiso) / sizeof(OptionnalIsoScriptFIELD));
 1808 
 1809     const OptionnalParScriptFIELD optpar[] = {PAR_GRID, PAR_VECT,PAR_CND, PAR_CONST,
 1810                                               PAR_FUNCT
 1811                                              };
 1812     OptParFields = std::vector<OptionnalParScriptFIELD>(
 1813                        optpar, optpar + sizeof(optpar) / sizeof(OptionnalParScriptFIELD));
 1814     const MandatoryIsoField maniso[] = {ISO_FXYZ, ISO_XMIN, ISO_XMAX,
 1815                                         ISO_YMIN, ISO_YMAX, ISO_ZMIN,
 1816                                         ISO_ZMAX, ISO_COMP, ISO_NAME
 1817                                        };
 1818     MandIsoFields = std::vector<MandatoryIsoField>(
 1819                         maniso, maniso + sizeof(maniso) / sizeof(MandatoryIsoField));
 1820     const MandatoryParField manpar[] = {PAR_FX,   PAR_FY,   PAR_FZ,   PAR_FW,
 1821                                         PAR_UMIN, PAR_UMAX, PAR_VMIN, PAR_VMAX,
 1822                                         PAR_COMP, PAR_NAME
 1823                                        };
 1824     MandParFields = std::vector<MandatoryParField>(
 1825                         manpar, manpar + sizeof(manpar) / sizeof(MandatoryParField));
 1826 }
 1827 
 1828 int DrawingOptions::JSON_choice_activated(const QString &arg1)
 1829 {
 1830     QString result;
 1831     QJsonArray array = JSONMathModels["MathModels"].toArray();
 1832     QJsonArray lst;
 1833     QJsonObject QObj, QObj1;
 1834     QJsonObject QTextureObj, QPigmentObj;
 1835     bool loadtext, loadpigm;
 1836     QMessageBox msgBox;
 1837     updateCurrentTreestruct();
 1838     MathmodRef->LocalScene.componentsinfos.ParisoCondition.clear();
 1839     for (int i = 0; i < array.size(); i++)
 1840     {
 1841         if ((QObj1 = array[i].toObject())["ParIso"].isArray() &&
 1842                 (QObj1)["Name"].toString() == arg1)
 1843         {
 1844             if (!VerifiedJsonModel((array[i].toObject())))
 1845                 return (0);
 1846             ShowSliders(array[i].toObject());
 1847             QJsonArray listeObj = QObj1["ParIso"].toArray();
 1848             QJsonArray listeIsoObj;
 1849             QJsonArray listeParObj;
 1850             QJsonObject QPar, QIso;
 1851             for (int i = 0; i < listeObj.size(); i++)
 1852                 if ((listeObj[i].toObject())["Iso3D"].isObject())
 1853                     listeIsoObj.append(listeObj[i].toObject());
 1854                 else
 1855                     listeParObj.append(listeObj[i].toObject());
 1856             // Right now, we only support pariso object with 1 Iso3D and 1 Param3D objects.
 1857             if (listeParObj.size() > 0)
 1858                 QPar = listeParObj[0].toObject();
 1859             if (listeIsoObj.size() > 0)
 1860                 QIso = listeIsoObj[0].toObject();
 1861             loadtext = loadpigm = false;
 1862             if (QPar["Texture"].isObject())
 1863                 QTextureObj = QPar["Texture"].toObject();
 1864             if (QPar["Pigment"].isObject())
 1865                 QPigmentObj = QPar["Pigment"].toObject();
 1866             // Colors
 1867             loadtext = MathmodRef->ParObjet->masterthread->rgbtnotnull =
 1868                            (QPar["Texture"].isObject());
 1869             // Pigment
 1870             loadpigm = MathmodRef->ParObjet->masterthread->vrgbtnotnull =
 1871                            (QPar["Pigment"].isObject());
 1872             LoadMandatoryAndOptionnalFields(QPar["Param3D"].toObject(), PAR_TYPE,
 1873                                             loadtext, QTextureObj, loadpigm,
 1874                                             QPigmentObj);
 1875             // Save this Current Parametric Tree struct
 1876             MathmodRef->RootObjet.CurrentParisoTreestruct.push_back(
 1877                 MathmodRef->RootObjet.CurrentTreestruct);
 1878             loadtext = loadpigm = false;
 1879             if (QIso["Texture"].isObject())
 1880                 QTextureObj = QIso["Texture"].toObject();
 1881             if (QIso["Pigment"].isObject())
 1882                 QPigmentObj = QIso["Pigment"].toObject();
 1883             // Colors
 1884             loadtext = MathmodRef->IsoObjet->masterthread->rgbtnotnull =
 1885                            (QIso["Texture"].isObject());
 1886             // Pigment
 1887             loadpigm = MathmodRef->IsoObjet->masterthread->vrgbtnotnull =
 1888                            (QIso["Pigment"].isObject());
 1889             LoadMandatoryAndOptionnalFields(QIso["Iso3D"].toObject(), ISO_TYPE,
 1890                                             loadtext, QTextureObj, loadpigm,
 1891                                             QPigmentObj);
 1892             // Save this Current Isosurface Tree struct
 1893             MathmodRef->RootObjet.CurrentParisoTreestruct.push_back(
 1894                 MathmodRef->RootObjet.CurrentTreestruct);
 1895             QJsonDocument document;
 1896             document.setObject(QObj1);
 1897             MathmodRef->RootObjet.CurrentTreestruct.text = QString(document.toJson());
 1898             // Update the current pariso struct
 1899             MathmodRef->RootObjet.CurrentJsonObject = QObj1;
 1900             CurrentFormulaType = 2;
 1901             /// process the new surface
 1902             MathmodRef->LocalScene.componentsinfos.ParisoCurrentComponentIndex = 0;
 1903             MathmodRef->LocalScene.componentsinfos.ParisoNbComponents =2;
 1904             MathmodRef->LocalScene.componentsinfos.pariso = true;
 1905             MathmodRef->ParisoObjectProcess();
 1906             ui.parisogroupbox->show();
 1907             return (1);
 1908         }
 1909         else
 1910         {
 1911             MathmodRef->LocalScene.componentsinfos.pariso = false;
 1912             MathmodRef->LocalScene.componentsinfos.ParisoNbComponents = 1;
 1913             MathmodRef->LocalScene.componentsinfos.ParisoCurrentComponentIndex = 0;
 1914             ui.parisogroupbox->hide();
 1915             if ((QObj1 = array[i].toObject())["Iso3D"].isObject() &&
 1916                     (QObj = (array[i].toObject())["Iso3D"].toObject())["Name"]
 1917                     .toArray()[0]
 1918                     .toString() == arg1)
 1919             {
 1920                 if (!VerifiedJsonModel((array[i].toObject())))
 1921                     return (0);
 1922                 ShowSliders(array[i].toObject());
 1923                 // Colors
 1924                 if ((loadtext = MathmodRef->IsoObjet->masterthread->rgbtnotnull = QObj1["Texture"].isObject()))
 1925                     QTextureObj = QObj1["Texture"].toObject();
 1926                 // Pigment
 1927                 if ((loadpigm = MathmodRef->IsoObjet->masterthread->vrgbtnotnull = QObj1["Pigment"].isObject()))
 1928                     QPigmentObj = QObj1["Pigment"].toObject();
 1929                 LoadMandatoryAndOptionnalFields(QObj, ISO_TYPE, loadtext, QTextureObj,
 1930                                                 loadpigm, QPigmentObj);
 1931                 QJsonDocument document;
 1932                 document.setObject(array[i].toObject());
 1933                 MathmodRef->RootObjet.CurrentTreestruct.text =
 1934                     QString(document.toJson());
 1935                 // Update the current parametric struct
 1936                 // MathmodRef->RootObjet.CurrentIsoStruct =
 1937                 // MathmodRef->RootObjet.IsoTable[indextable];
 1938                 MathmodRef->RootObjet.CurrentJsonObject = array[i].toObject();
 1939                 CurrentFormulaType = 2;
 1940                 /// process the new surface
 1941                 MathmodRef->ProcessNewIsoSurface();
 1942                 return (2);
 1943             }
 1944             else if ((array[i].toObject())["Param3D"].isObject() &&
 1945                      (QObj = (array[i].toObject())["Param3D"].toObject())["Name"]
 1946                      .toArray()[0]
 1947                      .toString() == arg1)
 1948             {
 1949                 if (!VerifiedJsonModel((array[i].toObject())))
 1950                     return (0);
 1951                 ShowSliders(array[i].toObject());
 1952                 // Colors
 1953                 if ((loadtext =
 1954                             MathmodRef->ParObjet->masterthread->rgbtnotnull =
 1955                                 QObj1["Texture"].isObject()))
 1956                     QTextureObj = QObj1["Texture"].toObject();
 1957                 // Pigment
 1958                 if ((loadpigm =
 1959                             MathmodRef->ParObjet->masterthread->vrgbtnotnull =
 1960                                 QObj1["Pigment"].isObject()))
 1961                     QPigmentObj = QObj1["Pigment"].toObject();
 1962                 LoadMandatoryAndOptionnalFields(QObj, PAR_TYPE, loadtext, QTextureObj,
 1963                                                 loadpigm, QPigmentObj);
 1964                 QJsonDocument document;
 1965                 document.setObject(array[i].toObject());
 1966                 MathmodRef->RootObjet.CurrentTreestruct.text =
 1967                     QString(document.toJson());
 1968 
 1969                 MathmodRef->RootObjet.CurrentJsonObject = array[i].toObject();
 1970                 CurrentFormulaType = 1;
 1971                 /// process the new surface
 1972                 MathmodRef->ParametricSurfaceProcess(1);
 1973                 return (1);
 1974             }
 1975             else if ((array[i].toObject())["Param4D"].isObject() &&
 1976                      (QObj = (array[i].toObject())["Param4D"].toObject())["Name"]
 1977                      .toArray()[0]
 1978                      .toString() == arg1)
 1979             {
 1980                 if (!VerifiedJsonModel((array[i].toObject())))
 1981                     return (0);
 1982                 ShowSliders(array[i].toObject());
 1983                 // Colors
 1984                 if ((loadtext =
 1985                             MathmodRef->ParObjet->masterthread->rgbtnotnull =
 1986                                 QObj1["Texture"].isObject()))
 1987                     QTextureObj = QObj1["Texture"].toObject();
 1988                 // Pigment
 1989                 if ((loadpigm =
 1990                             MathmodRef->ParObjet->masterthread->vrgbtnotnull =
 1991                                 QObj1["Pigment"].isObject()))
 1992                     QPigmentObj = QObj1["Pigment"].toObject();
 1993                 LoadMandatoryAndOptionnalFields(QObj, PAR_4D_TYPE, loadtext,
 1994                                                 QTextureObj, loadpigm, QPigmentObj);
 1995                 QJsonDocument document;
 1996                 document.setObject(array[i].toObject());
 1997                 MathmodRef->RootObjet.CurrentTreestruct.text =
 1998                     QString(document.toJson());
 1999                 MathmodRef->RootObjet.CurrentJsonObject = array[i].toObject();
 2000                 CurrentFormulaType = 3;
 2001                 /// process the new surface
 2002                 MathmodRef->ParametricSurfaceProcess(3);
 2003                 return (3);
 2004             }
 2005         }
 2006     }
 2007     return (0);
 2008 }
 2009 
 2010 void DrawingOptions::LoadMandatoryAndOptionnalFields(
 2011     const QJsonObject &qobj, const ModelType &mod, bool loadtext,
 2012     const QJsonObject &QTextureObj, bool loadpigm,
 2013     const QJsonObject &QPigmentObj)
 2014 {
 2015     // We First deactivate the pariso flag
 2016     MathmodRef->LocalScene.componentsinfos.pariso = false;
 2017     MathmodRef->RootObjet.CurrentTreestruct.type = mod;
 2018     switch (mod)
 2019     {
 2020     case PAR_TYPE:
 2021         for (std::vector<MandatoryParField>::const_iterator it =
 2022                     MandParFields.begin();
 2023                 it != MandParFields.end(); ++it)
 2024         {
 2025             MandatoryParField Opt = *it;
 2026             MandatoryParFieldprocess(qobj, Opt);
 2027         }
 2028 
 2029         for (std::vector<OptionnalParScriptFIELD>::const_iterator it =
 2030                     OptParFields.begin();
 2031                 it != OptParFields.end(); ++it)
 2032         {
 2033             OptionnalParScriptFIELD Opt = *it;
 2034             OptionalParScriptFieldprocess(qobj, Opt);
 2035         }
 2036         break;
 2037     case PAR_4D_TYPE:
 2038         for (std::vector<MandatoryParField>::const_iterator it =
 2039                     MandParFields.begin();
 2040                 it != MandParFields.end(); ++it)
 2041         {
 2042             MandatoryParField Opt = *it;
 2043             MandatoryParFieldprocess(qobj, Opt, PAR_4D_TYPE);
 2044         }
 2045 
 2046         for (std::vector<OptionnalParScriptFIELD>::const_iterator it =
 2047                     OptParFields.begin();
 2048                 it != OptParFields.end(); ++it)
 2049         {
 2050             OptionnalParScriptFIELD Opt = *it;
 2051             OptionalParScriptFieldprocess(qobj, Opt);
 2052         }
 2053         break;
 2054     case ISO_TYPE:
 2055         for (std::vector<MandatoryIsoField>::const_iterator it =
 2056                     MandIsoFields.begin();
 2057                 it != MandIsoFields.end(); ++it)
 2058         {
 2059             MandatoryIsoField Opt = *it;
 2060             MandatoryIsoFieldprocess(qobj, Opt);
 2061         }
 2062 
 2063         for (std::vector<OptionnalIsoScriptFIELD>::const_iterator it =
 2064                     OptIsoFields.begin();
 2065                 it != OptIsoFields.end(); ++it)
 2066         {
 2067             OptionnalIsoScriptFIELD Opt = *it;
 2068             OptionalIsoScriptFieldprocess(qobj, Opt);
 2069         }
 2070         break;
 2071     case PARISO_TYPE:
 2072         break;
 2073     case UNDEFINED_TYPE:
 2074         break;
 2075     }
 2076     // Colors
 2077     if (loadtext)
 2078     {
 2079         LoadTexture(QTextureObj, mod);
 2080     }
 2081     // Pigment
 2082     if (loadpigm)
 2083     {
 2084         LoadPigment(QPigmentObj, mod);
 2085     }
 2086 }
 2087 
 2088 int DrawingOptions::on_choice_activated(const QString &arg)
 2089 {
 2090     // Draw here
 2091     int Result = JSON_choice_activated(arg);
 2092     if (Result != 0)
 2093     {
 2094         UpdateScriptEditorAndTreeObject();
 2095     }
 2096 
 2097     return Result;
 2098 }
 2099 
 2100 void DrawingOptions::Run_JsonObject_activeted()
 2101 {
 2102     QJsonParseError err;
 2103     QString sortie;
 2104     QString script =
 2105         ui.ParamEdit->toPlainText()
 2106         .trimmed()
 2107         .replace("\n", "")
 2108         .replace("\t", "")
 2109         .replace("DOTSYMBOL", Parameters->dotsymbol.toStdString().c_str());
 2110     QJsonDocument doc = QJsonDocument::fromJson(script.toUtf8(), &err);
 2111     if (err.error)
 2112     {
 2113         ShowErrorMessage(err, script);
 2114         return;
 2115     }
 2116 
 2117     // Draw here
 2118     DrawJsonModel(doc.object());
 2119 }
 2120 
 2121 void DrawingOptions::slot_comboBox18_3_activated(const QString &arg1)
 2122 {
 2123     if (arg1 == "Triangles")
 2124     {
 2125         MathmodRef->slot_triangles_clicked();
 2126         return;
 2127     }
 2128     if (arg1 == "Normales")
 2129     {
 2130         MathmodRef->draw_norm_clicked();
 2131         return;
 2132     }
 2133     if (arg1 == "Infos")
 2134     {
 2135         MathmodRef->iso_infos();
 2136         return;
 2137     }
 2138     if (arg1 == "Fill")
 2139     {
 2140         MathmodRef->fill();
 2141         return;
 2142     }
 2143     if (arg1 == "Mesh")
 2144     {
 2145         MathmodRef->Mesh();
 2146         return;
 2147     }
 2148 }
 2149 
 2150 void DrawingOptions::slot_checkBox_clicked()
 2151 {
 2152     MathmodRef->slot_uv_clicked();
 2153 }
 2154 
 2155 void DrawingOptions::LoadNewFileModels(bool upd)
 2156 {
 2157     QString mathmodcollection;
 2158 
 2159     mathmodcollection = QFileDialog::getOpenFileName(
 2160                             nullptr, tr("Load Json Script"), "", tr("Json (*.js)"));
 2161     if (upd)
 2162     {
 2163         ui.ObjectClasse->clear();
 2164         for (int i = 0; i < MathmodRef->RootObjet.MyJsonObjectSelection.count();
 2165                 i++)
 2166             MathmodRef->RootObjet.MyJsonObjectSelection.removeAt(i);
 2167         MathmodRef->RootObjet.NbIsoStruct = MathmodRef->RootObjet.NbParamStruct = 0;
 2168         MathmodRef->collection.JPar.clear();
 2169         MathmodRef->collection.JIso.clear();
 2170     }
 2171     MathmodRef->RootObjet.ReadJsonFile(mathmodcollection, JSONMathModels);
 2172     QJsonArray array = JSONMathModels["MathModels"].toArray();
 2173     QStringList lst;
 2174     QString a;
 2175     QJsonObject jsobj;
 2176 
 2177     for (int i = 0; i < array.size(); i++)
 2178     {
 2179         if ((array[i].toObject())["Iso3D"].isObject())
 2180         {
 2181             jiso newjiso;
 2182             jsobj = (array[i].toObject())["Iso3D"].toObject();
 2183             newjiso.read(jsobj);
 2184             MathmodRef->collection.JIso.append(newjiso);
 2185             a = (jsobj)["Name"].toArray()[0].toString();
 2186             lst.append(a);
 2187         }
 2188         else if ((array[i].toObject())["Param3D"].isObject())
 2189         {
 2190             jpar newjpar;
 2191             jsobj = ((array[i].toObject())["Param3D"].toObject());
 2192             newjpar.read(jsobj);
 2193             MathmodRef->collection.JPar.append(newjpar);
 2194             a = (jsobj)["Name"].toArray()[0].toString();
 2195             lst.append(a);
 2196         }
 2197         else if ((array[i].toObject())["Param4D"].isObject())
 2198         {
 2199             jpar newjpar;
 2200             jsobj = ((array[i].toObject())["Param4D"].toObject());
 2201             newjpar.read(jsobj);
 2202             MathmodRef->collection.JPar.append(newjpar);
 2203             a = (jsobj)["Name"].toArray()[0].toString();
 2204             lst.append(a);
 2205         }
 2206     }
 2207     lst.insert(0, "Examples (" + QString::number(lst.count()) + ")");
 2208     // Load the script containing isosurface and parametric formulas:
 2209     ui.choice->clear();
 2210     ui.choice->insertItems(0, lst);
 2211     AddListModels(upd);
 2212 }
 2213 
 2214 void DrawingOptions::LoadK3DSurfScript(QString filename, int type)
 2215 {
 2216     int current = 0, currentfunction = 0, separator = 0;
 2217     QString name, line, IsoFct, Xfct, Yfct, Zfct, xlimit, ylimit, zlimit, ulimit,
 2218             vlimit, xmin, xmax, ymin, ymax, zmin, zmax, umin, umax, vmin, vmax,
 2219             condition, Au, Bu, Cu, Duv, Euv, Fuv, comments, fctcomts;
 2220     int EquationsNumber = 0;
 2221     QString JsonString = "";
 2222     int FctType = -1;
 2223     filename = QFileDialog::getOpenFileName(
 2224                    nullptr, QObject::tr("Open K3DSurf script File"), "",
 2225                    QObject::tr("K3DS (*.k3ds)"));
 2226     QFile file(filename);
 2227     if (type == 1)
 2228     {
 2229         if (file.open(QIODevice::ReadOnly | QIODevice::Text))
 2230         {
 2231             QTextStream stream(&file);
 2232             while (!stream.atEnd())
 2233             {
 2234                 line = (stream.readLine()).trimmed(); // line of text excluding '\n'
 2235                 if (line.contains("F():"))
 2236                 {
 2237                     currentfunction = 1;
 2238                     FctType = 0;
 2239                 }
 2240                 else if (line.contains("[x]:"))
 2241                     currentfunction = 2;
 2242                 else if (line.contains("[y]:"))
 2243                     currentfunction = 3;
 2244                 else if (line.contains("[z]:"))
 2245                     currentfunction = 4;
 2246 
 2247                 else if (line.contains("X():"))
 2248                 {
 2249                     currentfunction = 21;
 2250                     FctType = 1;
 2251                 }
 2252                 else if (line.contains("Y():"))
 2253                     currentfunction = 22;
 2254                 else if (line.contains("Z():"))
 2255                     currentfunction = 23;
 2256                 else if (line.contains("[u]:"))
 2257                     currentfunction = 24;
 2258                 else if (line.contains("[v]:"))
 2259                     currentfunction = 25;
 2260 
 2261                 else if (line.contains("Cnd:"))
 2262                     currentfunction = 5;
 2263                 else if (line.contains("A[u]:"))
 2264                     currentfunction = 6;
 2265                 else if (line.contains("B[u]:"))
 2266                     currentfunction = 7;
 2267                 else if (line.contains("C[u]:"))
 2268                     currentfunction = 8;
 2269                 else if (line.contains("D[u,v]:"))
 2270                     currentfunction = 9;
 2271                 else if (line.contains("E[u,v]:"))
 2272                     currentfunction = 10;
 2273                 else if (line.contains("F[u,v]:"))
 2274                     currentfunction = 11;
 2275                 else if (line.contains("#"))
 2276                     currentfunction = 12;
 2277                 else if (line.contains("/*"))
 2278                     currentfunction = 13;
 2279                 else if (line.contains("*/"))
 2280                     currentfunction = 14;
 2281                 else if (line.contains("Name:"))
 2282                     currentfunction = 15;
 2283                 else if (line.contains(";"))
 2284                     currentfunction = 16;
 2285                 else
 2286                     currentfunction = 18;
 2287                 switch (currentfunction)
 2288                 {
 2289                 case 1:
 2290                     IsoFct += line.remove(0, 4);
 2291                     current = 1;
 2292                     break;
 2293 
 2294                 case 21:
 2295                     Xfct += line.replace("X():", "");
 2296                     current = 21;
 2297                     break;
 2298                 case 22:
 2299                     Yfct += line.replace("Y():", "");
 2300                     current = 22;
 2301                     break;
 2302                 case 23:
 2303                     Zfct += line.replace("Z():", "");
 2304                     current = 23;
 2305                     break;
 2306                 case 24:
 2307                     ulimit += line.replace("[u]:", "");
 2308                     current = 24;
 2309                     break;
 2310                 case 25:
 2311                     vlimit += line.replace("[v]:", "");
 2312                     current = 25;
 2313                     break;
 2314 
 2315                 case 2:
 2316                     xlimit = line.remove(0, 4);
 2317                     current = 2;
 2318                     break;
 2319                 case 3:
 2320                     ylimit = line.remove(0, 4);
 2321                     current = 3;
 2322                     break;
 2323                 case 4:
 2324                     zlimit = line.remove(0, 4);
 2325                     current = 4;
 2326                     break;
 2327                 case 5:
 2328                     condition = line.remove(0, 4);
 2329                     current = 5;
 2330                     break;
 2331                 case 6:
 2332                     Au = line.remove(0, 5);
 2333                     current = 6;
 2334                     break;
 2335                 case 7:
 2336                     Bu = line.remove(0, 5);
 2337                     current = 7;
 2338                     break;
 2339                 case 8:
 2340                     Cu = line.remove(0, 5);
 2341                     current = 8;
 2342                     break;
 2343                 case 9:
 2344                     Duv = line.remove(0, 7);
 2345                     current = 9;
 2346                     break;
 2347                 case 10:
 2348                     Euv = line.remove(0, 7);
 2349                     current = 10;
 2350                     break;
 2351                 case 11:
 2352                     Fuv = line.remove(0, 7);
 2353                     current = 11;
 2354                     break;
 2355                 case 12:
 2356                     comments += line.replace("#", "");
 2357                     current = 12;
 2358                     break;
 2359                 case 13:
 2360                     comments += line.replace("/*", "").replace("*/", "");
 2361                     current = 13;
 2362                     break;
 2363                 case 14:
 2364                     comments += line.replace("*/", "");
 2365                     current = 14;
 2366                     break;
 2367                 case 15:
 2368                     name = line.remove(0, 5);
 2369                     current = 15;
 2370                     break;
 2371                 case 16:
 2372                     // Save the equation:
 2373                     name = name.trimmed();
 2374                     if (FctType == 0)
 2375                     {
 2376                         EquationsNumber++;
 2377                         if (name == "")
 2378                             name = "_" + QString::number(EquationsNumber);
 2379                         xlimit = xlimit.trimmed();
 2380                         separator = xlimit.indexOf(",");
 2381                         xmin = xlimit.left(separator);
 2382                         xmax = xlimit.remove(xmin + ",");
 2383                         ylimit = ylimit.trimmed();
 2384                         separator = ylimit.indexOf(",");
 2385                         ymin = ylimit.left(separator);
 2386                         ymax = ylimit.remove(ymin + ",");
 2387                         zlimit = zlimit.trimmed();
 2388                         separator = zlimit.indexOf(",");
 2389                         zmin = zlimit.left(separator);
 2390                         zmax = zlimit.remove(zmin + ",");
 2391                         if (JsonString != "")
 2392                             JsonString += ",";
 2393                         JsonString += "{\"Iso3D\": {  \
 2394                          \"Description \": [ \"" +
 2395                                       comments + "\"], ";
 2396                         JsonString += "\"Name\": [\"" + name + "\"], ";
 2397                         JsonString += "\"Component\": [\"" + name + "\"], ";
 2398                         JsonString += "\"Fxyz\": [\"" + IsoFct.trimmed() + "\"], ";
 2399                         JsonString += "\"Cnd\": [\"" + condition + "\"], ";
 2400                         JsonString += "\"Xmin\": [\"" + xmin + "\"], ";
 2401                         JsonString += "\"Xmax\": [\"" + xmax + "\"], ";
 2402                         JsonString += "\"Ymin\": [\"" + ymin + "\"], ";
 2403                         JsonString += "\"Ymax\": [\"" + ymax + "\"], ";
 2404                         JsonString += "\"Zmin\": [\"" + zmin + "\"], ";
 2405                         JsonString += "\"Zmax\": [\"" + zmax + "\"] ";
 2406                         JsonString += "}}";
 2407                     }
 2408 
 2409                     else if (FctType == 1)
 2410                     {
 2411                         EquationsNumber++;
 2412                         if (name == "")
 2413                             name = "_" + QString::number(EquationsNumber);
 2414 
 2415                         ulimit = ulimit.trimmed();
 2416                         separator = ulimit.indexOf(",");
 2417                         umin = ulimit.left(separator);
 2418                         umax = ulimit.remove(umin + ",");
 2419                         vlimit = vlimit.trimmed();
 2420                         separator = vlimit.indexOf(",");
 2421                         vmin = vlimit.left(separator);
 2422                         vmax = vlimit.remove(vmin + ",");
 2423                         if (JsonString != "")
 2424                             JsonString += ",";
 2425                         JsonString += "{\"Param3D\": {  \
 2426                          \"Description \": [ \"" +
 2427                                       comments + "\"],";
 2428                         JsonString += "\"Name\": [\"" + name + "\"],";
 2429                         JsonString += "\"Component\": [\"" + name + "\"],";
 2430                         JsonString += "\"Fx\": [\"" + Xfct.trimmed() + "\"],";
 2431                         JsonString += "\"Fy\": [\"" + Yfct.trimmed() + "\"],";
 2432                         JsonString += "\"Fz\": [\"" + Zfct.trimmed() + "\"],";
 2433                         JsonString += "\"Cnd\": [\"" + condition + "\"],";
 2434                         JsonString += "\"Umin\": [\"" + umin + "\"],";
 2435                         JsonString += "\"Umax\": [\"" + umax + "\"],";
 2436                         JsonString += "\"Vmin\": [\"" + vmin + "\"],";
 2437                         JsonString += "\"Vmax\": [\"" + vmax + "\"]";
 2438                         JsonString += "}}";
 2439                     }
 2440                     current = 16;
 2441                     // Init all Parameters fo new formula:
 2442                     IsoFct = Xfct = Yfct = Zfct = name = comments = condition = "";
 2443                     umin = umax = vmin = vmax = xmin = xmax = ymin = ymax = zmin = zmax = "";
 2444                     ulimit = vlimit = xlimit = ylimit = zlimit = "";
 2445                     FctType = -1;
 2446                     break;
 2447                 case 18:
 2448                     if (current == 1)
 2449                         IsoFct += line;
 2450                     else if (current == 2)
 2451                         xlimit += line;
 2452                     else if (current == 3)
 2453                         ylimit += line;
 2454                     else if (current == 4)
 2455                         zlimit += line;
 2456                     else if (current == 21)
 2457                         Xfct += line;
 2458                     else if (current == 22)
 2459                         Yfct += line;
 2460                     else if (current == 23)
 2461                         Zfct += line;
 2462                     else if (current == 24)
 2463                         ulimit += line;
 2464                     else if (current == 25)
 2465                         vlimit += line;
 2466                     else if (current == 5)
 2467                         condition += line;
 2468                     else if (current == 6)
 2469                         Au += line;
 2470                     else if (current == 7)
 2471                         Bu += line;
 2472                     else if (current == 8)
 2473                         Cu += line;
 2474                     else if (current == 9)
 2475                         Duv += line;
 2476                     else if (current == 10)
 2477                         Euv += line;
 2478                     else if (current == 11)
 2479                         Fuv += line;
 2480                     else if (current == 12)
 2481                         comments += line;
 2482                     else if (current == 13)
 2483                         comments += line;
 2484                     else if (current == 14)
 2485                         comments += line;
 2486                     else if (current == 15)
 2487                         name += line;
 2488                     break;
 2489                 }
 2490             }
 2491             file.close();
 2492             JsonString = " { \"MathModels\": [ " + JsonString + "]}";
 2493             QFile f(filename.replace(".k3ds", ".js"));
 2494             if (f.exists())
 2495                 f.remove();
 2496             if (!f.open(QIODevice::ReadWrite | QIODevice::Text))
 2497             {
 2498                 statusBar()->showMessage(tr("Could not write to %1").arg(filename),2000);
 2499                 return;
 2500             }
 2501             QTextStream t(&f);
 2502             t << JsonString;
 2503             f.close();
 2504         }
 2505     }
 2506 }
 2507 
 2508 QTreeWidgetItem *DrawingOptions::ChildItemTreeProperty(QTreeWidgetItem *item,
 2509         QString proprty)
 2510 {
 2511     int childcount = item->childCount();
 2512     for (int j = 0; j < childcount; j++)
 2513     {
 2514         if ((item->child(j))->text(0).contains(proprty))
 2515             return item->child(j);
 2516     }
 2517     return nullptr;
 2518 }
 2519 
 2520 void DrawingOptions::ParseItemTree(QTreeWidgetItem *item, QList<bool> &list, bool viewall)
 2521 {
 2522     int childcount = item->childCount();
 2523     bool sel = false;
 2524     bool result;
 2525     for (int j = 0; j < childcount; j++)
 2526     {
 2527         item->child(j)->setForeground(0, QColor(255, 255, 255, 255));
 2528         if (!viewall)
 2529         {
 2530             result = false;
 2531             for (int k = 1; k < select.selectedoptions.selectedwords.count(); k++)
 2532             {
 2533                 sel = (item->child(j))
 2534                       ->text(0)
 2535                       .contains(select.selectedoptions.selectedwords[k],
 2536                                 (select.selectedoptions.sensitive
 2537                                  ? Qt::CaseSensitive
 2538                                  : Qt::CaseInsensitive));
 2539                 result = result || sel;
 2540                 list[k - 1] = (list.at(k - 1) || sel);
 2541             }
 2542             if (result)
 2543                 item->child(j)->setForeground(0, QColor(255, 0, 0, 255));
 2544         }
 2545     }
 2546 }
 2547 
 2548 void DrawingOptions::SearchListModels()
 2549 {
 2550     QTreeWidgetItem *Toplevel;
 2551     QTreeWidgetItem *Childlevel = nullptr;
 2552     QTreeWidgetItem *SubChildlevel;
 2553     int topcount = ui.ObjectClasse->topLevelItemCount();
 2554     int childcount;
 2555     bool sel1 = false;
 2556     int searchresult = 0;
 2557     // init boolean lists:
 2558     for (int i = 0; i < select.selectedoptions.selectedwords.count() - 1; i++)
 2559     {
 2560         select.selectedoptions.namelist.append(false);
 2561         select.selectedoptions.functlist.append(false);
 2562         select.selectedoptions.cmpnamelist.append(false);
 2563         select.selectedoptions.complist.append(false);
 2564     }
 2565     for (int i = 0; i < topcount; ++i)
 2566     {
 2567         Toplevel = ui.ObjectClasse->topLevelItem(i);
 2568         childcount = Toplevel->childCount();
 2569         searchresult = 0;
 2570         for (int j = 0; j < childcount; j++)
 2571         {
 2572             sel1 = true;
 2573             if (!select.selectedoptions.showall)
 2574             {
 2575                 // init boolean lists:
 2576                 for (int m = 0; m < select.selectedoptions.selectedwords.count() - 1;
 2577                         m++)
 2578                 {
 2579                     select.selectedoptions.namelist[m] = false;
 2580                     select.selectedoptions.functlist[m] = false;
 2581                     select.selectedoptions.cmpnamelist[m] = false;
 2582                     select.selectedoptions.complist[m] = false;
 2583                 }
 2584                 // Search in scripts names:
 2585                 if (select.selectedoptions.parsenames)
 2586                     for (int k = 1; k < select.selectedoptions.selectedwords.count();
 2587                             k++)
 2588                     {
 2589                         select.selectedoptions.namelist[k - 1] =
 2590                             (Toplevel->child(j))
 2591                             ->text(0)
 2592                             .contains(select.selectedoptions.selectedwords[k],
 2593                                       (select.selectedoptions.sensitive
 2594                                        ? Qt::CaseSensitive
 2595                                        : Qt::CaseInsensitive));
 2596                     }
 2597                 // continue searching in the functions list when needed:
 2598                 if (select.selectedoptions.parsefunctions &&
 2599                         (Childlevel = ChildItemTreeProperty(Toplevel->child(j),
 2600                                       "Parameters")) != nullptr)
 2601                     if ((SubChildlevel =
 2602                                 ChildItemTreeProperty(Childlevel, "Functions")) != nullptr)
 2603                     {
 2604                         ParseItemTree(SubChildlevel, select.selectedoptions.functlist);
 2605                     }
 2606                 // continue searching in the components names list when needed:
 2607                 if (select.selectedoptions.parsecmpnames &&
 2608                         (Childlevel = ChildItemTreeProperty(Toplevel->child(j),
 2609                                       "Components")) != nullptr)
 2610                 {
 2611                     ParseItemTree(Childlevel, select.selectedoptions.cmpnamelist);
 2612                     int ct = Childlevel->childCount();
 2613                     for (int m = 0; m < ct; m++)
 2614                         ParseItemTree(Childlevel->child(m),
 2615                                       select.selectedoptions.complist);
 2616                 }
 2617                 // now look in the search results
 2618                 if (select.selectedoptions.AND)
 2619                 {
 2620                     sel1 = true;
 2621                     for (int l = 0; l < select.selectedoptions.selectedwords.count() - 1;
 2622                             l++)
 2623                         sel1 = sel1 && (select.selectedoptions.namelist.at(l) ||
 2624                                         select.selectedoptions.functlist.at(l) ||
 2625                                         select.selectedoptions.cmpnamelist.at(l) ||
 2626                                         select.selectedoptions.complist.at(l));
 2627                 }
 2628                 else
 2629                 {
 2630                     sel1 = false;
 2631                     for (int l = 0; l < select.selectedoptions.selectedwords.count() - 1;
 2632                             l++)
 2633                         sel1 = sel1 || (select.selectedoptions.namelist.at(l) ||
 2634                                         select.selectedoptions.functlist.at(l) ||
 2635                                         select.selectedoptions.cmpnamelist.at(l) ||
 2636                                         select.selectedoptions.complist.at(l));
 2637                 }
 2638             }
 2639             else
 2640             {
 2641                 // Make sure the text color is white when showall is activated
 2642                 if ((Childlevel = ChildItemTreeProperty(Toplevel->child(j),
 2643                                                         "Parameters")) != nullptr)
 2644                     if ((SubChildlevel =
 2645                                 ChildItemTreeProperty(Childlevel, "Functions")) != nullptr)
 2646                     {
 2647                         ParseItemTree(SubChildlevel, select.selectedoptions.functlist,
 2648                                       true);
 2649                     }
 2650                 // Components names and their childs:
 2651                 if ((Childlevel = ChildItemTreeProperty(Toplevel->child(j),
 2652                                                         "Components")) != nullptr)
 2653                 {
 2654                     ParseItemTree(Childlevel, select.selectedoptions.cmpnamelist, true);
 2655                     int ct = Childlevel->childCount();
 2656                     for (int m = 0; m < ct; m++)
 2657                         ParseItemTree(Childlevel->child(m), select.selectedoptions.complist, true);
 2658                 }
 2659             }
 2660             // Now count and show only scripts with appropiate search results:
 2661             if (sel1)
 2662                 searchresult++;
 2663             (Toplevel->child(j))->setHidden(!sel1);
 2664             if (Toplevel->text(0).contains("IsoSurfaces"))
 2665                 Toplevel->setText(0, "IsoSurfaces (" + QString::number(searchresult) +
 2666                                   ")");
 2667             else if (Toplevel->text(0).contains("Parametric"))
 2668                 Toplevel->setText(0,
 2669                                   "Parametric (" + QString::number(searchresult) + ")");
 2670             else
 2671                 Toplevel->setText(0, "My Selection (" + QString::number(searchresult) +
 2672                                   ")");
 2673         }
 2674     }
 2675     // Clear boolean lists:
 2676     select.selectedoptions.namelist.clear();
 2677     select.selectedoptions.functlist.clear();
 2678     select.selectedoptions.cmpnamelist.clear();
 2679     select.selectedoptions.complist.clear();
 2680 }
 2681 
 2682 void DrawingOptions::AddListModels(bool update)
 2683 {
 2684     if (!update)
 2685     {
 2686         QMenu *contextMenu = new QMenu(ui.ObjectClasse);
 2687         ui.ObjectClasse->setContextMenuPolicy(Qt::ActionsContextMenu);
 2688         QAction *addElement =
 2689             new QAction("Add Current Model to MySelection", contextMenu);
 2690         QAction *deleteElement =
 2691             new QAction("Erase selected row from MySelection", contextMenu);
 2692         QAction *separator = new QAction(ui.ObjectClasse);
 2693         separator->setSeparator(true);
 2694         ui.ObjectClasse->addAction(addElement);
 2695         ui.ObjectClasse->addAction(separator);
 2696         ui.ObjectClasse->addAction(deleteElement);
 2697         connect(addElement, SIGNAL(triggered()), this,
 2698                 SLOT(slot_pushButton_2_clicked()));
 2699         connect(deleteElement, SIGNAL(triggered()), this,
 2700                 SLOT(slot_unselect_clicked()));
 2701     }
 2702     QColor greenColor = QColor(0, 255, 0, 50);
 2703     // Parametric:
 2704     QTreeWidgetItem *ParlistItem = new QTreeWidgetItem(ui.ObjectClasse);
 2705     QString Text = "Parametric (" +
 2706                    QString::number(MathmodRef->collection.JPar.count()) + ")";
 2707     ParlistItem->setBackground(0, greenColor);
 2708     ParlistItem->setText(0, Text);
 2709     for (int i = 0; i < MathmodRef->collection.JPar.count(); ++i)
 2710     {
 2711         QTreeWidgetItem *nameitem = new QTreeWidgetItem(ParlistItem);
 2712         nameitem->setText(0, MathmodRef->collection.JPar[i].Name[0]);
 2713         if (MathmodRef->collection.JPar[i].Component.count() > 0)
 2714         {
 2715             QTreeWidgetItem *cmpitem = new QTreeWidgetItem(nameitem);
 2716             cmpitem->setText(0, "Components");
 2717             for (int j = 0; j < MathmodRef->collection.JPar[i].Component.count();
 2718                     j++)
 2719             {
 2720                 QTreeWidgetItem *cmpitem2 = new QTreeWidgetItem(cmpitem);
 2721                 cmpitem2->setText(0, MathmodRef->collection.JPar[i].Component.at(j));
 2722                 QTreeWidgetItem *cmpitem3 = new QTreeWidgetItem(cmpitem2);
 2723                 cmpitem3->setText(0, "X(u,v) = " +
 2724                                   MathmodRef->collection.JPar[i].Fx.at(j));
 2725                 QTreeWidgetItem *cmpitem4 = new QTreeWidgetItem(cmpitem2);
 2726                 cmpitem4->setText(0, "Y(u,v) = " +
 2727                                   MathmodRef->collection.JPar[i].Fy.at(j));
 2728                 QTreeWidgetItem *cmpitem5 = new QTreeWidgetItem(cmpitem2);
 2729                 cmpitem5->setText(0, "Z(u,v) = " +
 2730                                   MathmodRef->collection.JPar[i].Fz.at(j));
 2731                 QTreeWidgetItem *cmpitem6 = new QTreeWidgetItem(cmpitem2);
 2732                 cmpitem6->setText(
 2733                     0, "U = [" + MathmodRef->collection.JPar[i].Umin.at(j) + ", " +
 2734                     MathmodRef->collection.JPar[i].Umax.at(j) + "]");
 2735                 QTreeWidgetItem *cmpitem7 = new QTreeWidgetItem(cmpitem2);
 2736                 cmpitem7->setText(
 2737                     0, "V = [" + MathmodRef->collection.JPar[i].Vmin.at(j) + ", " +
 2738                     MathmodRef->collection.JPar[i].Vmax.at(j) + "]");
 2739                 // Grid resolution:
 2740                 if (MathmodRef->collection.JPar[i].Grid.size() > 0 &&
 2741                         2 * j + 1 < MathmodRef->collection.JPar[i].Grid.size())
 2742                 {
 2743                     QTreeWidgetItem *cmpitem8 = new QTreeWidgetItem(cmpitem2);
 2744                     cmpitem8->setText(
 2745                         0, "Grid = (" + MathmodRef->collection.JPar[i].Grid.at(2 * j) +
 2746                         " , " + MathmodRef->collection.JPar[i].Grid.at(2 * j + 1) +
 2747                         ")");
 2748                 }
 2749             }
 2750         }
 2751         // Add Global parameters:
 2752         if (MathmodRef->collection.JPar[i].Csts.count() ||
 2753                 MathmodRef->collection.JPar[i].Funct.count())
 2754         {
 2755             QTreeWidgetItem *parameteritem = new QTreeWidgetItem(nameitem);
 2756             parameteritem->setText(0, "Parameters:");
 2757             if (MathmodRef->collection.JPar[i].Csts.count() > 0)
 2758             {
 2759                 QTreeWidgetItem *cstitem = new QTreeWidgetItem(parameteritem);
 2760                 cstitem->setText(0, "Constantes:");
 2761                 for (int j = 0; j < MathmodRef->collection.JPar[i].Csts.count(); j++)
 2762                 {
 2763                     QTreeWidgetItem *cstitem2 = new QTreeWidgetItem(cstitem);
 2764                     cstitem2->setText(0, MathmodRef->collection.JPar[i].Csts.at(j));
 2765                 }
 2766             }
 2767             if (MathmodRef->collection.JPar[i].Funct.count() > 0)
 2768             {
 2769                 QTreeWidgetItem *fctitem = new QTreeWidgetItem(parameteritem);
 2770                 fctitem->setText(0, "Functions:");
 2771                 for (int j = 0; j < MathmodRef->collection.JPar[i].Funct.count(); j++)
 2772                 {
 2773                     QTreeWidgetItem *fctitem2 = new QTreeWidgetItem(fctitem);
 2774                     fctitem2->setText(0, MathmodRef->collection.JPar[i].Funct.at(j));
 2775                 }
 2776             }
 2777         }
 2778     }
 2779     ParlistItem->sortChildren(0, Qt::AscendingOrder);
 2780     // Iso:
 2781     QTreeWidgetItem *IsolistItem = IsolistItemRef =
 2782                                        new QTreeWidgetItem(ui.ObjectClasse);
 2783     Text = "IsoSurfaces (" +
 2784            QString::number(MathmodRef->collection.JIso.count()) + ")";
 2785     IsolistItem->setBackground(0, greenColor);
 2786     IsolistItem->setText(0, Text);
 2787     for (int i = 0; i < MathmodRef->collection.JIso.count(); ++i)
 2788     {
 2789         QTreeWidgetItem *nameitem = new QTreeWidgetItem(IsolistItem);
 2790         nameitem->setText(0, MathmodRef->collection.JIso[i].Name[0]);
 2791         if (MathmodRef->collection.JIso[i].Component.count() > 0)
 2792         {
 2793             QTreeWidgetItem *cmpitem = new QTreeWidgetItem(nameitem);
 2794             cmpitem->setText(0, "Components");
 2795             for (int j = 0; j < MathmodRef->collection.JIso[i].Component.count();
 2796                     j++)
 2797             {
 2798                 QTreeWidgetItem *cmpitem2 = new QTreeWidgetItem(cmpitem);
 2799                 cmpitem2->setText(0, MathmodRef->collection.JIso[i].Component.at(j));
 2800                 QTreeWidgetItem *cmpitem3 = new QTreeWidgetItem(cmpitem2);
 2801                 cmpitem3->setText(0, "F(x,y,z) = " +
 2802                                   MathmodRef->collection.JIso[i].Fxyz.at(j));
 2803                 QTreeWidgetItem *cmpitem6 = new QTreeWidgetItem(cmpitem2);
 2804                 cmpitem6->setText(
 2805                     0, "X = [" + MathmodRef->collection.JIso[i].Xmin.at(j) + ", " +
 2806                     MathmodRef->collection.JIso[i].Xmax.at(j) + "]");
 2807                 QTreeWidgetItem *cmpitem7 = new QTreeWidgetItem(cmpitem2);
 2808                 cmpitem7->setText(
 2809                     0, "Y = [" + MathmodRef->collection.JIso[i].Ymin.at(j) + ", " +
 2810                     MathmodRef->collection.JIso[i].Ymax.at(j) + "]");
 2811                 QTreeWidgetItem *cmpitem8 = new QTreeWidgetItem(cmpitem2);
 2812                 cmpitem8->setText(
 2813                     0, "Z = [" + MathmodRef->collection.JIso[i].Zmin.at(j) + ", " +
 2814                     MathmodRef->collection.JIso[i].Zmax.at(j) + "]");
 2815                 // Grid resolution:
 2816                 if (MathmodRef->collection.JIso[i].Grid.size() > 0 &&
 2817                         j < MathmodRef->collection.JIso[i].Grid.size())
 2818                 {
 2819                     QTreeWidgetItem *cmpitem9 = new QTreeWidgetItem(cmpitem2);
 2820                     cmpitem9->setText(0, "Grid = " +
 2821                                       MathmodRef->collection.JIso[i].Grid.at(j));
 2822                 }
 2823             }
 2824         }
 2825         // Add Global parameters:
 2826         if (MathmodRef->collection.JIso[i].Csts.count() ||
 2827                 MathmodRef->collection.JIso[i].Funct.count())
 2828         {
 2829             QTreeWidgetItem *parameteritem = new QTreeWidgetItem(nameitem);
 2830             parameteritem->setText(0, "Parameters:");
 2831             if (MathmodRef->collection.JIso[i].Csts.count() > 0)
 2832             {
 2833                 QTreeWidgetItem *cstitem = new QTreeWidgetItem(parameteritem);
 2834                 cstitem->setText(0, "Constantes:");
 2835                 for (int j = 0; j < MathmodRef->collection.JIso[i].Csts.count(); j++)
 2836                 {
 2837                     QTreeWidgetItem *cstitem2 = new QTreeWidgetItem(cstitem);
 2838                     cstitem2->setText(0, MathmodRef->collection.JIso[i].Csts.at(j));
 2839                 }
 2840             }
 2841             if (MathmodRef->collection.JIso[i].Funct.count() > 0)
 2842             {
 2843                 QTreeWidgetItem *fctitem = new QTreeWidgetItem(parameteritem);
 2844                 fctitem->setText(0, "Functions:");
 2845                 for (int j = 0; j < MathmodRef->collection.JIso[i].Funct.count(); j++)
 2846                 {
 2847                     QTreeWidgetItem *fctitem2 = new QTreeWidgetItem(fctitem);
 2848                     fctitem2->setText(0, MathmodRef->collection.JIso[i].Funct.at(j));
 2849                 }
 2850             }
 2851         }
 2852     }
 2853     IsolistItemRef->sortChildren(0, Qt::AscendingOrder);
 2854     // Parametric:
 2855     QTreeWidgetItem *ParisolistItem = new QTreeWidgetItem(ui.ObjectClasse);
 2856     Text = "Pariso (" +
 2857                    QString::number(MathmodRef->collection.JParIso.count()) + ")";
 2858     ParisolistItem->setBackground(0, greenColor);
 2859     ParisolistItem->setText(0, Text);
 2860     for (int i = 0; i < MathmodRef->collection.JParIso.count(); ++i)
 2861     {
 2862         QTreeWidgetItem *nameitem = new QTreeWidgetItem(ParisolistItem);
 2863         nameitem->setText(0, MathmodRef->collection.JParIso[i].Name);
 2864 
 2865     }
 2866     ParisolistItem->sortChildren(0, Qt::AscendingOrder);
 2867     // My Selection:
 2868     // Isosurfaces:
 2869     QTreeWidgetItem *MyselectionItem = new QTreeWidgetItem(ui.ObjectClasse);
 2870     MyselectionItemReference = MyselectionItem;
 2871     MyselectionItem->setBackground(0, greenColor);
 2872     MyselectionItem->setText(0, "My Selection");
 2873     return;
 2874 }
 2875 
 2876 void DrawingOptions::on_pushButton_clicked()
 2877 {
 2878     static int checked = 1;
 2879     checked *= -1;
 2880     (checked == -1) ? ui.ObjectClasse->hide() : ui.ObjectClasse->show();
 2881 }
 2882 
 2883 void DrawingOptions::on_action_Exit_triggered()
 2884 {
 2885     MathmodRef->LabelInfos.close();
 2886     MathmodRef->close();
 2887     this->close();
 2888 }
 2889 
 2890 void DrawingOptions::on_actionTriangles_triggered()
 2891 {
 2892     MathmodRef->slot_triangles_clicked();
 2893 }
 2894 
 2895 void DrawingOptions::on_actionInfos_triggered()
 2896 {
 2897     MathmodRef->iso_infos();
 2898 }
 2899 
 2900 void DrawingOptions::on_actionFill_triggered()
 2901 {
 2902     MathmodRef->fill();
 2903 }
 2904 
 2905 void DrawingOptions::on_ObjectClasse_clicked(const QModelIndex &index)
 2906 {
 2907     if (!MathmodRef->IsoObjet->isRunning() &&
 2908             !MathmodRef->ParObjet->isRunning())
 2909     {
 2910         on_InitTButton_clicked();
 2911         // int result;
 2912         QString tst;
 2913         MathmodRef->LocalScene.IndexCurrentFormula = -1;
 2914         if (index.data().isValid())
 2915         {
 2916             QVariant data = index.data();
 2917             QString s = data.toString();
 2918             QModelIndex parent = index.parent();
 2919             if (parent.data().isValid())
 2920             {
 2921                 QString prt = parent.data().toString();
 2922                 if (prt != "My Selection")
 2923                 {
 2924                     on_choice_activated(s);
 2925                 }
 2926                 else
 2927                 {
 2928                     for (int i = 0;
 2929                             i < MathmodRef->RootObjet.MyJsonObjectSelection.size(); i++)
 2930                         if ((MathmodRef->RootObjet.MyJsonObjectSelection[i].toObject()["Iso3D"].isObject()))
 2931                         {
 2932                             if (s == (tst = (MathmodRef->RootObjet.MyJsonObjectSelection[i].toObject()["Iso3D"]).toObject()["Name"].toArray()[0].toString()))
 2933                             {
 2934                                 // Draw here
 2935 
 2936                                 DrawJsonModel(MathmodRef->RootObjet.MyJsonObjectSelection.at(i).toObject());
 2937                                 return;
 2938                             }
 2939                         }
 2940                         else if ((MathmodRef->RootObjet.MyJsonObjectSelection[i].toObject()["Param3D"].isObject()))
 2941                         {
 2942                             if (s == (tst = (MathmodRef->RootObjet.MyJsonObjectSelection[i].toObject()["Param3D"]).toObject()["Name"].toArray()[0].toString()))
 2943                             {
 2944                                 // Draw here
 2945                                 DrawJsonModel(MathmodRef->RootObjet.MyJsonObjectSelection.at(i).toObject());
 2946                                 return;
 2947                             }
 2948                         }
 2949                         else if ((MathmodRef->RootObjet.MyJsonObjectSelection[i].toObject()["Param4D"].isObject()))
 2950                         {
 2951                             if (s == (tst = (MathmodRef->RootObjet.MyJsonObjectSelection[i].toObject()["Param4D"]).toObject()["Name"].toArray()[0].toString()))
 2952                             {
 2953                                 // Draw here
 2954                                 DrawJsonModel(MathmodRef->RootObjet.MyJsonObjectSelection.at(i).toObject());
 2955                                 return;
 2956                             }
 2957                         }
 2958                 }
 2959             }
 2960         }
 2961         return;
 2962     }
 2963 }
 2964 
 2965 void DrawingOptions::slot_pushButton_2_clicked()
 2966 {
 2967     MathmodRef->RootObjet.MyJsonObjectSelection.append(MathmodRef->RootObjet.CurrentJsonObject);
 2968     AddObjectToMySelectionTree();
 2969 }
 2970 
 2971 void DrawingOptions::slot_unselect_clicked()
 2972 {
 2973     int index =
 2974         MyselectionItemReference->indexOfChild(ui.ObjectClasse->currentItem());
 2975     MathmodRef->RootObjet.MyJsonObjectSelection.removeAt(index);
 2976     MyselectionItemReference->removeChild(ui.ObjectClasse->currentItem());
 2977 }
 2978 
 2979 void DrawingOptions::slot_XYZscrollBar_valueChanged(int value)
 2980 {
 2981     MathmodRef->xyzg_valueChanged(value, ISO_TYPE);
 2982 }
 2983 
 2984 void DrawingOptions::UpdateDescription(int position, ModelType type, TreeStruct &currentstruct)
 2985 {
 2986     if (type == PAR_TYPE)
 2987     {
 2988         if (position > -1)
 2989         {
 2990             IndexcurrentComponent = position;
 2991             MathmodRef->LocalScene.IndexCurrentFormula == position
 2992             ? MathmodRef->LocalScene.IndexCurrentFormula = -1
 2993                     : MathmodRef->LocalScene.IndexCurrentFormula = position;
 2994             // currentFormula = sparent;
 2995             ui.paramNameEdit->setText(currentstruct.Component.at(position));
 2996             ui.XEdit->setText(currentstruct.fx.at(position));
 2997             ui.YEdit->setText(currentstruct.fy.at(position));
 2998             ui.ZEdit->setText(currentstruct.fz.at(position));
 2999             ui.umin->setText(currentstruct.umin.at(position));
 3000             ui.vmin->setText(currentstruct.vmin.at(position));
 3001             ui.umax->setText(currentstruct.umax.at(position));
 3002             ui.vmax->setText(currentstruct.vmax.at(position));
 3003             if (!currentstruct.Component.empty())
 3004                 ui.paramNameEdit->setText(currentstruct.Component.at(position));
 3005             else
 3006                 ui.paramNameEdit->setText("");
 3007             if (!currentstruct.Cnd.empty())
 3008             {
 3009                 ui.CndUpdateEdit_2->setText(currentstruct.Cnd.at(position));
 3010             }
 3011             else
 3012             {
 3013                 ui.CndUpdateEdit_2->setText("");
 3014             }
 3015             // Function:
 3016             if (!currentstruct.Funct.empty())
 3017             {
 3018                 ui.tableWidget_Fct_2->clearContents();
 3019                 ui.tableWidget_Fct_2->setRowCount(0);
 3020                 for (int i = 0; i < currentstruct.Funct.size(); i++)
 3021                 {
 3022                     ui.tableWidget_Fct_2->setRowCount(i + 1);
 3023                     ui.tableWidget_Fct_2->setItem(i, 0, new QTableWidgetItem(currentstruct.Funct.at(i)));
 3024                 }
 3025             }
 3026             else
 3027             {
 3028                 ui.tableWidget_Fct_2->clearContents();
 3029                 ui.tableWidget_Fct_2->setRowCount(0);
 3030             }
 3031             // Constantes:
 3032             if (!currentstruct.Const.empty())
 3033             {
 3034                 ui.tableWidget_Cst_2->clearContents();
 3035                 ui.tableWidget_Cst_2->setRowCount(0);
 3036                 for (int i = 0; i < currentstruct.Const.size(); i++)
 3037                 {
 3038                     ui.tableWidget_Cst_2->setRowCount(i + 1);
 3039                     ui.tableWidget_Cst_2->setItem(i, 0, new QTableWidgetItem(currentstruct.Const.at(i)));
 3040                 }
 3041             }
 3042             else
 3043             {
 3044                 ui.tableWidget_Cst_2->clearContents();
 3045                 ui.tableWidget_Cst_2->setRowCount(0);
 3046             }
 3047         }
 3048         ui.stackedProperties->setCurrentIndex(2);
 3049     }
 3050     if (type == PAR_4D_TYPE)
 3051     {
 3052         if (position > -1)
 3053         {
 3054             IndexcurrentComponent = position;
 3055             MathmodRef->LocalScene.IndexCurrentFormula == position
 3056             ? MathmodRef->LocalScene.IndexCurrentFormula = -1
 3057                     : MathmodRef->LocalScene.IndexCurrentFormula = position;
 3058             // currentFormula = sparent;
 3059             ui.paramNameEdit_2->setText(currentstruct.Component.at(position));
 3060             ui.XEdit_2->setText(currentstruct.fx.at(position));
 3061             ui.YEdit_2->setText(currentstruct.fy.at(position));
 3062             ui.ZEdit_2->setText(currentstruct.fz.at(position));
 3063             ui.WEdit_2->setText(currentstruct.fw.at(position));
 3064             ui.umin_2->setText(currentstruct.umin.at(position));
 3065             ui.vmin_2->setText(currentstruct.vmin.at(position));
 3066             ui.umax_2->setText(currentstruct.umax.at(position));
 3067             ui.vmax_2->setText(currentstruct.vmax.at(position));
 3068             if (!currentstruct.Component.empty())
 3069                 ui.paramNameEdit_2->setText(currentstruct.Component.at(position));
 3070             else
 3071                 ui.paramNameEdit_2->setText("");
 3072         }
 3073         ui.stackedProperties->setCurrentIndex(3);
 3074     }
 3075     if (type == ISO_TYPE)
 3076     {
 3077         if (position > -1)
 3078         {
 3079             IndexcurrentComponent = position;
 3080             MathmodRef->LocalScene.IndexCurrentFormula == position
 3081             ? MathmodRef->LocalScene.IndexCurrentFormula = -1
 3082                     : MathmodRef->LocalScene.IndexCurrentFormula = position;
 3083             ui.UpdateEdit->setText(currentstruct.fxyz.at(position));
 3084             ui.xmin->setText(currentstruct.xmin.at(position));
 3085             ui.ymin->setText(currentstruct.ymin.at(position));
 3086             ui.zmin->setText(currentstruct.zmin.at(position));
 3087             ui.xmax->setText(currentstruct.xmax.at(position));
 3088             ui.ymax->setText(currentstruct.ymax.at(position));
 3089             ui.zmax->setText(currentstruct.zmax.at(position));
 3090             if (!currentstruct.Component.empty())
 3091                 ui.isoNameEdit->setText(currentstruct.Component.at(position));
 3092             else
 3093                 ui.isoNameEdit->setText("");
 3094 
 3095             if (!currentstruct.Cnd.empty())
 3096             {
 3097                 position < currentstruct.Cnd.size()
 3098                 ? ui.CndUpdateEdit->setText(currentstruct.Cnd.at(position))
 3099                 : ui.CndUpdateEdit->setText(currentstruct.Cnd.at(0));
 3100             }
 3101             else
 3102             {
 3103                 ui.CndUpdateEdit->setText("");
 3104             }
 3105             // Function:
 3106             if (!currentstruct.Funct.empty())
 3107             {
 3108                 ui.tableWidget_Fct->clearContents();
 3109                 ui.tableWidget_Fct->setRowCount(0);
 3110                 for (int i = 0; i < currentstruct.Funct.size(); i++)
 3111                 {
 3112                     ui.tableWidget_Fct->setRowCount(i + 1);
 3113                     ui.tableWidget_Fct->setItem(i, 0, new QTableWidgetItem(currentstruct.Funct.at(i)));
 3114                 }
 3115             }
 3116             else
 3117             {
 3118                 ui.tableWidget_Fct->clearContents();
 3119                 ui.tableWidget_Fct->setRowCount(0);
 3120             }
 3121             // Constantes:
 3122             if (!currentstruct.Const.empty())
 3123             {
 3124                 ui.tableWidget_Cst->clearContents();
 3125                 ui.tableWidget_Cst->setRowCount(0);
 3126                 for (int i = 0; i < currentstruct.Const.size(); i++)
 3127                 {
 3128                     ui.tableWidget_Cst->setRowCount(i + 1);
 3129                     ui.tableWidget_Cst->setItem(i, 0, new QTableWidgetItem(currentstruct.Const.at(i)));
 3130                 }
 3131             }
 3132             else
 3133             {
 3134                 ui.tableWidget_Cst->clearContents();
 3135                 ui.tableWidget_Cst->setRowCount(0);
 3136             }
 3137         }
 3138         ui.stackedProperties->setCurrentIndex(1);
 3139     }
 3140 }
 3141 
 3142 void DrawingOptions::oncolor_2activated(int index)
 3143 {
 3144     MathmodRef->colorstype(index);
 3145 }
 3146 
 3147 void DrawingOptions::onred_2valueChanged(int value)
 3148 {
 3149     MathmodRef->red(value, IndexcurrentComponent);
 3150 }
 3151 
 3152 void DrawingOptions::ongreen_2valueChanged(int value)
 3153 {
 3154     MathmodRef->green(value, IndexcurrentComponent);
 3155 }
 3156 
 3157 void DrawingOptions::onblue_2valueChanged(int value)
 3158 {
 3159     MathmodRef->blue(value, IndexcurrentComponent);
 3160 }
 3161 
 3162 void DrawingOptions::on_red_ParIso_valueChanged(int value)
 3163 {
 3164     MathmodRef->red(value, IndexcurrentComponent);
 3165 }
 3166 
 3167 void DrawingOptions::on_green_ParIso_valueChanged(int value)
 3168 {
 3169     MathmodRef->green(value, IndexcurrentComponent);
 3170 }
 3171 
 3172 void DrawingOptions::on_blue_ParIso_valueChanged(int value)
 3173 {
 3174     MathmodRef->blue(value, IndexcurrentComponent);
 3175 }
 3176 
 3177 void DrawingOptions::removeat(int idx, QJsonObject& QObj, QString str)
 3178 {
 3179     QJsonArray array;
 3180     array = QObj[str].toArray();
 3181     array.removeAt(idx);
 3182     QObj[str] = array;
 3183 }
 3184 
 3185 void DrawingOptions::removeat2(int idx, QJsonObject& QObj, QString str)
 3186 {
 3187     if (QObj[str].isArray())
 3188     {
 3189         QJsonArray array;
 3190         array = QObj[str].toArray();
 3191         array.removeAt(idx);
 3192         QObj[str] = array;
 3193     }
 3194     else
 3195         QObj.remove(str);
 3196 }
 3197 
 3198 void DrawingOptions::appendall(QJsonObject& QObj, QString str, QTableWidget* table)
 3199 {
 3200     if (QObj[str].isArray() && table->rowCount() > 0)
 3201     {
 3202         QJsonArray array2;
 3203         for (int i = 0; i < table->rowCount(); i++)
 3204         {
 3205             if ((table->item(i, 0))->text() != "")
 3206                 array2.append((table->item(i, 0))->text());
 3207         }
 3208         QObj[str] = array2;
 3209     }
 3210     else
 3211         QObj.remove(str);
 3212 }
 3213 
 3214 void DrawingOptions::replaceat(int idx, QJsonObject& QObj, QString str, QTextEdit* text)
 3215 {
 3216     QJsonArray array;
 3217     array = QObj[str].toArray();
 3218     array.replace(idx, text->toPlainText());
 3219     QObj[str] = array;
 3220 }
 3221 
 3222 void DrawingOptions::insertat(int idx, QJsonObject& QObj, QString str, QTextEdit* text)
 3223 {
 3224     QJsonArray array;
 3225     array = QObj[str].toArray();
 3226     array.insert(idx, text->toPlainText());
 3227     QObj[str] = array;
 3228 }
 3229 
 3230 void DrawingOptions::appednew(QJsonObject& QObj, QString str, QTextEdit* text)
 3231 {
 3232     QJsonArray array;
 3233     array = QObj[str].toArray();
 3234     array.append(text->toPlainText());
 3235     QObj[str] = array;
 3236 }
 3237 
 3238 void DrawingOptions::on_updateJObject(QJsonObject &copyCurrentObject)
 3239 {
 3240     QJsonArray array;
 3241     if (copyCurrentObject["Iso3D"].isObject())
 3242     {
 3243         if (IndexcurrentComponent != -1)
 3244         {
 3245             QJsonObject copyCurrentObject2 = copyCurrentObject["Iso3D"].toObject();
 3246             // Cut the component at the index indexcurrentFormula :
 3247             if ((ui.isoNameEdit->toPlainText()).replace(" ", "") == "")
 3248             {
 3249                 for(uint ui=0; ui<MandatoryIsosurfaceFields.size(); ui++)
 3250                     removeat(IndexcurrentComponent, copyCurrentObject2, MandatoryIsosurfaceFields[ui]);
 3251 
 3252                 removeat2(IndexcurrentComponent, copyCurrentObject2, "Grid");
 3253                 removeat2(IndexcurrentComponent, copyCurrentObject2, "Cnd");
 3254                 appendall(copyCurrentObject2, "Funct", ui.tableWidget_Fct);
 3255                 appendall(copyCurrentObject2, "Const", ui.tableWidget_Cst);
 3256                 // Some keys cleaning..
 3257                 copyCurrentObject2.remove("Param3D");
 3258                 copyCurrentObject2.remove("Param4D");
 3259                 copyCurrentObject["Iso3D"] = copyCurrentObject2;
 3260             }
 3261             // Update the component at the index indexcurrentFormula;
 3262             else if ((copyCurrentObject["Iso3D"].toObject())["Component"].toArray().size() > 0 &&
 3263                      IndexcurrentComponent > -1 && IndexcurrentComponent <
 3264                      (copyCurrentObject["Iso3D"].toObject())["Component"].toArray().size() &&
 3265                      (((copyCurrentObject["Iso3D"].toObject())["Component"].toArray())[IndexcurrentComponent]).toString().replace(" ", "") ==
 3266                      (ui.isoNameEdit->toPlainText()).replace(" ", ""))
 3267             {
 3268                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Fxyz", ui.UpdateEdit);
 3269                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Xmin", ui.xmin);
 3270                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Xmax", ui.xmax);
 3271                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Ymin", ui.ymin);
 3272                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Ymax", ui.ymax);
 3273                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Zmin", ui.zmin);
 3274                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Zmax", ui.zmax);
 3275                 appendall(copyCurrentObject2, "Funct", ui.tableWidget_Fct);
 3276                 appendall(copyCurrentObject2, "Const", ui.tableWidget_Cst);
 3277 
 3278                 copyCurrentObject2.remove("Param3D");
 3279                 copyCurrentObject2.remove("Param4D");
 3280                 copyCurrentObject["Iso3D"] = copyCurrentObject2;
 3281             }
 3282             else
 3283             {
 3284                 // Add new component:
 3285                 if ((((copyCurrentObject["Iso3D"].toObject())["Component"].toArray())[IndexcurrentComponent]).toString().replace(" ", "") !=
 3286                         (ui.isoNameEdit->toPlainText()).replace(" ", ""))
 3287                 {
 3288                     appednew(copyCurrentObject2, "Component", ui.isoNameEdit);
 3289                     appednew(copyCurrentObject2, "Fxyz", ui.UpdateEdit);
 3290                     appednew(copyCurrentObject2, "Xmin", ui.xmin);
 3291                     appednew(copyCurrentObject2, "Xmax", ui.xmax);
 3292                     appednew(copyCurrentObject2, "Ymin", ui.ymin);
 3293                     appednew(copyCurrentObject2, "Ymax", ui.ymax);
 3294                     appednew(copyCurrentObject2, "Zmin", ui.zmin);
 3295                     appednew(copyCurrentObject2, "Zmax", ui.zmax);
 3296 
 3297                     if (copyCurrentObject2["Cnd"].isArray())
 3298                     {
 3299                         array = copyCurrentObject2["Cnd"].toArray();
 3300                         array.append(ui.CndUpdateEdit->toPlainText());
 3301                         copyCurrentObject2["Cnd"] = array;
 3302                     }
 3303                     else if (ui.CndUpdateEdit->toPlainText() != "")
 3304                     {
 3305                         array = copyCurrentObject2["Cnd"].toArray();
 3306                         for (int i = 0; i < copyCurrentObject2["Fxyz"].toArray().count();
 3307                                 i++)
 3308                             array.append(ui.CndUpdateEdit->toPlainText());
 3309                         copyCurrentObject2["Cnd"] = array;
 3310                     }
 3311                     else
 3312                         copyCurrentObject2.remove("Cnd");
 3313 
 3314                     if (copyCurrentObject2["Grid"].isArray())
 3315                     {
 3316                         array = copyCurrentObject2["Grid"].toArray();
 3317                         array.append(QString::number(ui.xyzg->value()));
 3318                         copyCurrentObject2["Grid"] = array;
 3319                     }
 3320                     else
 3321                         copyCurrentObject2.remove("Grid");
 3322                 }
 3323                 else
 3324                 {
 3325                     insertat(IndexcurrentComponent, copyCurrentObject2, "Fxyz", ui.UpdateEdit);
 3326                     insertat(IndexcurrentComponent, copyCurrentObject2, "Xmin", ui.xmin);
 3327                     insertat(IndexcurrentComponent, copyCurrentObject2, "Xmax", ui.xmax);
 3328                     insertat(IndexcurrentComponent, copyCurrentObject2, "Ymin", ui.ymin);
 3329                     insertat(IndexcurrentComponent, copyCurrentObject2, "Ymax", ui.ymax);
 3330                     insertat(IndexcurrentComponent, copyCurrentObject2, "Zmin", ui.zmin);
 3331                     insertat(IndexcurrentComponent, copyCurrentObject2, "Zmax", ui.zmax);
 3332 
 3333                     if (copyCurrentObject2["Cnd"].isArray())
 3334                     {
 3335                         array = copyCurrentObject2["Cnd"].toArray();
 3336                         array.insert(IndexcurrentComponent, ui.CndUpdateEdit->toPlainText());
 3337                         copyCurrentObject2["Cnd"] = array;
 3338                     }
 3339                     else if (ui.CndUpdateEdit->toPlainText() != "")
 3340                     {
 3341                         array = copyCurrentObject2["Cnd"].toArray();
 3342                         for (int i = 0; i < copyCurrentObject2["Fxyz"].toArray().count();
 3343                                 i++)
 3344                             array.append(ui.CndUpdateEdit->toPlainText());
 3345                         copyCurrentObject2["Cnd"] = array;
 3346                     }
 3347                     else
 3348                         copyCurrentObject2.remove("Cnd");
 3349                 }
 3350 
 3351                 appendall(copyCurrentObject2, "Funct", ui.tableWidget_Fct);
 3352                 appendall(copyCurrentObject2, "Const", ui.tableWidget_Cst);
 3353 
 3354                 copyCurrentObject["Iso3D"] = copyCurrentObject2;
 3355             }
 3356         }
 3357     }
 3358     else if (copyCurrentObject["Param3D"].isObject())
 3359     {
 3360         copyCurrentObject.remove("Iso3D");
 3361         QJsonObject copyCurrentObject2 = copyCurrentObject["Param3D"].toObject();
 3362         if (IndexcurrentComponent != -1)
 3363         {
 3364             if ((ui.paramNameEdit->toPlainText()).replace(" ", "") == "")
 3365             {
 3366                 for(uint ui=0; ui<MandatoryParmetric3DFields.size(); ui++)
 3367                     removeat(IndexcurrentComponent, copyCurrentObject2, MandatoryParmetric3DFields[ui]);
 3368                 removeat2(2*IndexcurrentComponent, copyCurrentObject2, "Grid");
 3369                 removeat2(2*IndexcurrentComponent, copyCurrentObject2, "Grid");
 3370                 removeat2(IndexcurrentComponent, copyCurrentObject2, "Cnd");
 3371                 appendall(copyCurrentObject2, "Funct", ui.tableWidget_Fct_2);
 3372                 appendall(copyCurrentObject2, "Const", ui.tableWidget_Cst_2);
 3373                 // Some keys cleaning..
 3374                 copyCurrentObject2.remove("Iso3D");
 3375                 copyCurrentObject2.remove("Param4D");
 3376                 copyCurrentObject["Param3D"] = copyCurrentObject2;
 3377             }
 3378             else if (((copyCurrentObject["Param3D"].toObject())["Component"].toArray()).count() > 0 &&
 3379                      IndexcurrentComponent > -1 && IndexcurrentComponent <
 3380                      ((copyCurrentObject["Param3D"].toObject())["Component"].toArray()).size() &&
 3381                      ((copyCurrentObject["Param3D"].toObject())["Component"].toArray())[IndexcurrentComponent].toString().replace(" ", "") ==
 3382                      (ui.paramNameEdit->toPlainText()).replace(" ", ""))
 3383             {
 3384                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Fx", ui.XEdit);
 3385                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Fy", ui.YEdit);
 3386                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Fz", ui.ZEdit);
 3387                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Umin", ui.umin);
 3388                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Umax", ui.umax);
 3389                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Vmin", ui.vmin);
 3390                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Vmax", ui.vmax);
 3391                 appendall(copyCurrentObject2, "Funct", ui.tableWidget_Fct_2);
 3392                 appendall(copyCurrentObject2, "Const", ui.tableWidget_Cst_2);
 3393                 if (copyCurrentObject2["Cnd"].isArray() &&
 3394                         copyCurrentObject2["Cnd"].toArray().count() > IndexcurrentComponent)
 3395                 {
 3396                     array = copyCurrentObject2["Cnd"].toArray();
 3397                     array.replace(IndexcurrentComponent, ui.CndUpdateEdit_2->toPlainText());
 3398                     copyCurrentObject2["Cnd"] = array;
 3399                 }
 3400                 else if (ui.CndUpdateEdit_2->toPlainText() != "")
 3401                 {
 3402                     array = copyCurrentObject2["Cnd"].toArray();
 3403                     for (int i = 0; i < copyCurrentObject2["Fx"].toArray().count(); i++)
 3404                         array.append(ui.CndUpdateEdit_2->toPlainText());
 3405                     copyCurrentObject2["Cnd"] = array;
 3406                 }
 3407                 else
 3408                     copyCurrentObject2.remove("Cnd");
 3409                 copyCurrentObject["Param3D"] = copyCurrentObject2;
 3410             }
 3411             else
 3412             {
 3413                 if (((copyCurrentObject["Param3D"].toObject())["Component"].toArray())[IndexcurrentComponent].toString().replace(" ", "") !=
 3414                         (ui.paramNameEdit->toPlainText()).replace(" ", ""))
 3415                 {
 3416                     appednew(copyCurrentObject2, "Component", ui.paramNameEdit);
 3417                     appednew(copyCurrentObject2, "Fx", ui.XEdit);
 3418                     appednew(copyCurrentObject2, "Fy", ui.YEdit);
 3419                     appednew(copyCurrentObject2, "Fz", ui.ZEdit);
 3420                     appednew(copyCurrentObject2, "Umin", ui.umin);
 3421                     appednew(copyCurrentObject2, "Umax", ui.umax);
 3422                     appednew(copyCurrentObject2, "Vmin", ui.vmin);
 3423                     appednew(copyCurrentObject2, "Vmax", ui.vmax);
 3424                     if (copyCurrentObject2["Grid"].isArray())
 3425                     {
 3426                         array = copyCurrentObject2["Grid"].toArray();
 3427                         int pos=2*IndexcurrentComponent;
 3428                         array.append((array.at(pos).toString()));
 3429                         array.append((array.at(pos+1).toString()));
 3430                         copyCurrentObject2["Grid"] = array;
 3431                     }
 3432                     else
 3433                         copyCurrentObject2.remove("Grid");
 3434 
 3435                     if (copyCurrentObject2["Cnd"].isArray())
 3436                     {
 3437                         array = copyCurrentObject2["Cnd"].toArray();
 3438                         array.append(ui.CndUpdateEdit_2->toPlainText());
 3439                         copyCurrentObject2["Cnd"] = array;
 3440                     }
 3441                     else if (ui.CndUpdateEdit_2->toPlainText() != "")
 3442                     {
 3443                         array = copyCurrentObject2["Cnd"].toArray();
 3444                         for (int i = 0; i < copyCurrentObject2["Fx"].toArray().count(); i++)
 3445                             array.append(ui.CndUpdateEdit_2->toPlainText());
 3446                         copyCurrentObject2["Cnd"] = array;
 3447                     }
 3448                     else
 3449                         copyCurrentObject2.remove("Cnd");
 3450                 }
 3451                 else
 3452                 {
 3453                     insertat(IndexcurrentComponent, copyCurrentObject2, "Fx", ui.XEdit);
 3454                     insertat(IndexcurrentComponent, copyCurrentObject2, "Fy", ui.YEdit);
 3455                     insertat(IndexcurrentComponent, copyCurrentObject2, "Fz", ui.ZEdit);
 3456                     insertat(IndexcurrentComponent, copyCurrentObject2, "Umin", ui.umin);
 3457                     insertat(IndexcurrentComponent, copyCurrentObject2, "Umax", ui.umax);
 3458                     insertat(IndexcurrentComponent, copyCurrentObject2, "Vmin", ui.vmin);
 3459                     insertat(IndexcurrentComponent, copyCurrentObject2, "Vmax", ui.vmax);
 3460                     array = copyCurrentObject2["Component"].toArray();
 3461                     array.insert(IndexcurrentComponent, ui.paramNameEdit->toPlainText());
 3462                     copyCurrentObject2["Component"] = array;
 3463                     if (copyCurrentObject2["Cnd"].isArray())
 3464                     {
 3465                         array = copyCurrentObject2["Cnd"].toArray();
 3466                         array.append(ui.CndUpdateEdit_2->toPlainText());
 3467                         copyCurrentObject2["Cnd"] = array;
 3468                     }
 3469                     else if (ui.CndUpdateEdit_2->toPlainText() != "")
 3470                     {
 3471                         array = copyCurrentObject2["Cnd"].toArray();
 3472                         for (int i = 0; i < copyCurrentObject2["Fx"].toArray().count(); i++)
 3473                             array.append(ui.CndUpdateEdit_2->toPlainText());
 3474                         copyCurrentObject2["Cnd"] = array;
 3475                     }
 3476                     else
 3477                         copyCurrentObject2.remove("Cnd");
 3478                 }
 3479                 appendall(copyCurrentObject2, "Funct", ui.tableWidget_Fct_2);
 3480                 appendall(copyCurrentObject2, "Const", ui.tableWidget_Cst_2);
 3481                 copyCurrentObject["Param3D"] = copyCurrentObject2;
 3482             }
 3483         }
 3484     }
 3485     else if (copyCurrentObject["Param4D"].isObject())
 3486     {
 3487         copyCurrentObject.remove("Iso3D");
 3488         copyCurrentObject.remove("Param3D");
 3489         QJsonObject copyCurrentObject2 = copyCurrentObject["Param4D"].toObject();
 3490         if (IndexcurrentComponent != -1)
 3491         {
 3492             if ((ui.paramNameEdit_2->toPlainText()).replace(" ", "") == "")
 3493             {
 3494                 for(uint ui=0; ui<MandatoryParmetric4DFields.size(); ui++)
 3495                     removeat(IndexcurrentComponent, copyCurrentObject2, MandatoryParmetric4DFields[ui]);
 3496                 removeat2(2*IndexcurrentComponent, copyCurrentObject2, "Grid");
 3497                 removeat2(2*IndexcurrentComponent, copyCurrentObject2, "Grid");
 3498                 copyCurrentObject["Param4D"] = copyCurrentObject2;
 3499             }
 3500             else if (((copyCurrentObject["Param4D"].toObject())["Component"].toArray()).count() > 0 &&
 3501                      IndexcurrentComponent > -1 && IndexcurrentComponent <((copyCurrentObject["Param4D"].toObject())["Component"].toArray()).size() &&
 3502                      ((copyCurrentObject["Param4D"].toObject())["Component"].toArray())[IndexcurrentComponent].toString().replace(" ", "") ==(ui.paramNameEdit_2->toPlainText()).replace(" ", ""))
 3503             {
 3504                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Fx", ui.XEdit_2);
 3505                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Fy", ui.YEdit_2);
 3506                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Fz", ui.ZEdit_2);
 3507                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Fw", ui.WEdit_2);
 3508                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Umin", ui.umin_2);
 3509                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Umax", ui.umax_2);
 3510                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Vmin", ui.vmin_2);
 3511                 replaceat(IndexcurrentComponent, copyCurrentObject2, "Vmax", ui.vmax_2);
 3512                 copyCurrentObject["Param4D"] = copyCurrentObject2;
 3513             }
 3514             else
 3515             {
 3516                 if (((copyCurrentObject["Param4D"].toObject())["Component"].toArray())[IndexcurrentComponent].toString().replace(" ", "") !=
 3517                         (ui.paramNameEdit_2->toPlainText()).replace(" ", ""))
 3518                 {
 3519                     appednew(copyCurrentObject2, "Component", ui.paramNameEdit_2);
 3520                     appednew(copyCurrentObject2, "Fx", ui.XEdit_2);
 3521                     appednew(copyCurrentObject2, "Fy", ui.YEdit_2);
 3522                     appednew(copyCurrentObject2, "Fz", ui.ZEdit_2);
 3523                     appednew(copyCurrentObject2, "Fw", ui.WEdit_2);
 3524                     appednew(copyCurrentObject2, "Umin", ui.umin_2);
 3525                     appednew(copyCurrentObject2, "Umax", ui.umax_2);
 3526                     appednew(copyCurrentObject2, "Vmin", ui.vmin_2);
 3527                     appednew(copyCurrentObject2, "Vmax", ui.vmax_2);
 3528                     if (copyCurrentObject2["Grid"].isArray())
 3529                     {
 3530                         array = copyCurrentObject2["Grid"].toArray();
 3531                         int pos=2*IndexcurrentComponent;
 3532                         array.append((array.at(pos).toString()));
 3533                         array.append((array.at(pos+1).toString()));
 3534                         copyCurrentObject2["Grid"] = array;
 3535                     }
 3536                     else
 3537                         copyCurrentObject2.remove("Grid");
 3538                     copyCurrentObject["Param4D"] = copyCurrentObject2;
 3539                 }
 3540                 else
 3541                 {
 3542                     insertat(IndexcurrentComponent, copyCurrentObject2, "Component", ui.paramNameEdit_2);
 3543                     insertat(IndexcurrentComponent, copyCurrentObject2, "Fx", ui.XEdit_2);
 3544                     insertat(IndexcurrentComponent, copyCurrentObject2, "Fy", ui.YEdit_2);
 3545                     insertat(IndexcurrentComponent, copyCurrentObject2, "Fz", ui.ZEdit_2);
 3546                     insertat(IndexcurrentComponent, copyCurrentObject2, "Fw", ui.WEdit_2);
 3547                     insertat(IndexcurrentComponent, copyCurrentObject2, "Umin", ui.umin_2);
 3548                     insertat(IndexcurrentComponent, copyCurrentObject2, "Umax", ui.umax_2);
 3549                     insertat(IndexcurrentComponent, copyCurrentObject2, "Vmin", ui.vmin_2);
 3550                     insertat(IndexcurrentComponent, copyCurrentObject2, "Vmax", ui.vmax_2);
 3551                     copyCurrentObject["Param4D"] = copyCurrentObject2;
 3552                 }
 3553             }
 3554         }
 3555     }
 3556 }
 3557 
 3558 void DrawingOptions::RunUpdatedJObject(QJsonObject &CurrentObject)
 3559 {
 3560     if (IndexcurrentComponent != -1)
 3561     {
 3562         if (CurrentObject["Iso3D"].isObject())
 3563         {
 3564             CurrentObject.remove("Param3D");
 3565             CurrentObject.remove("Param4D");
 3566             CurrentObject.remove("ParIso");
 3567             DrawJsonModel(CurrentObject);
 3568         }
 3569         else if (CurrentObject["Param3D"].isObject())
 3570         {
 3571             CurrentObject.remove("Iso3D");
 3572             CurrentObject.remove("Param4D");
 3573             CurrentObject.remove("ParIso");
 3574             DrawJsonModel(CurrentObject);
 3575         }
 3576         else if (CurrentObject["Param4D"].isObject())
 3577         {
 3578             CurrentObject.remove("Iso3D");
 3579             CurrentObject.remove("Param3D");
 3580             CurrentObject.remove("ParIso");
 3581             DrawJsonModel(CurrentObject);
 3582         }
 3583         else
 3584         {
 3585             CurrentObject.remove("Iso3D");
 3586             CurrentObject.remove("Param3D");
 3587             CurrentObject.remove("Param4D");
 3588             DrawJsonModel(CurrentObject);
 3589         }
 3590     }
 3591 }
 3592 
 3593 void DrawingOptions::on_updateButton_clicked()
 3594 {
 3595     QJsonObject CurrentObject = MathmodRef->RootObjet.CurrentJsonObject;
 3596     QJsonObject parisoComponent;
 3597     if (CurrentObject["ParIso"].isArray())
 3598     {
 3599         QJsonArray listeObj = CurrentObject["ParIso"].toArray();
 3600         QJsonArray listeIsoObj;
 3601         QJsonArray listeParObj;
 3602         for (int i = 0; i < listeObj.size(); i++)
 3603             if ((listeObj[i].toObject())["Iso3D"].isObject())
 3604                 listeIsoObj.append(listeObj[i].toObject());
 3605             else
 3606                 listeParObj.append(listeObj[i].toObject());
 3607         int page = ui.parisocomboBox->currentIndex();
 3608         if (page == 1) // Iso3D
 3609         {
 3610             parisoComponent = listeIsoObj[0].toObject();
 3611             on_updateJObject(parisoComponent);
 3612             QJsonArray newlisteObj;
 3613             newlisteObj.append(parisoComponent);
 3614             if (listeParObj.size() > 0)
 3615                 newlisteObj.append(listeParObj[0].toObject());
 3616             CurrentObject["ParIso"] = newlisteObj;
 3617             RunUpdatedJObject(CurrentObject);
 3618         }
 3619         else if (page == 0)   // Param3D
 3620         {
 3621             parisoComponent = listeParObj[0].toObject();
 3622             on_updateJObject(parisoComponent);
 3623             QJsonArray newlisteObj;
 3624             newlisteObj.append(parisoComponent);
 3625             if (listeIsoObj.size() > 0)
 3626                 newlisteObj.append(listeIsoObj[0].toObject());
 3627             CurrentObject["ParIso"] = newlisteObj;
 3628             RunUpdatedJObject(CurrentObject);
 3629         }
 3630     }
 3631     else
 3632     {
 3633         CurrentObject.remove("ParIso");
 3634         on_updateJObject(CurrentObject);
 3635         RunUpdatedJObject(CurrentObject);
 3636     }
 3637 }
 3638 
 3639 void DrawingOptions::on_updateParam_clicked()
 3640 {
 3641     on_updateButton_clicked();
 3642 }
 3643 
 3644 void DrawingOptions::on_actionPolygonWavefront_obj_triggered()
 3645 {
 3646     MathmodRef->SaveSceneAsObjPoly();
 3647 }
 3648 
 3649 void DrawingOptions::on_actionColorPolygonWavefront_obj_triggered()
 3650 {
 3651     MathmodRef->SaveSceneAsObjPoly(1);
 3652 }
 3653 
 3654 void DrawingOptions::on_linecolumn_2_valueChanged(int value)
 3655 {
 3656     ui.ParamgroupBox_2->setTitle("Grid(u,v)/MaxGrid = (" + QString::number(value) +
 3657                                  ", " + QString::number(value) +") / "+QString::number(Parameters->ParMaxGrid));
 3658     if (!MathmodRef->ParObjet->isRunning())
 3659     {
 3660         (MathmodRef->RootObjet.CurrentJsonObject["ParIso"].isArray()) ?
 3661         MathmodRef->linecolumn_valueChanged(value, PARISO_TYPE) : MathmodRef->linecolumn_valueChanged(value, PAR_TYPE);
 3662     }
 3663     else
 3664     {
 3665         ui.uv->blockSignals(true);
 3666         ui.uv->setChecked(false);
 3667         ui.uv->blockSignals(false);
 3668         MathmodRef->uvactivated = -1;
 3669     }
 3670 }
 3671 
 3672 void DrawingOptions::on_lineScrollBar_valueChanged(int value)
 3673 {
 3674     ui.ParamgroupBox_2->setTitle(
 3675         "Grid(u,v)/MaxGrid = (" + QString::number(value) + ", " +
 3676         QString::number(MathmodRef->ParObjet->Ugrid) +") / "+QString::number(Parameters->ParMaxGrid));
 3677     if (!MathmodRef->ParObjet->isRunning())
 3678     {
 3679         MathmodRef->line_valueChanged(value);
 3680     }
 3681     else
 3682     {
 3683         ui.uv->blockSignals(true);
 3684         ui.uv->setChecked(false);
 3685         ui.uv->blockSignals(false);
 3686         MathmodRef->uvactivated = -1;
 3687     }
 3688 }
 3689 
 3690 void DrawingOptions::on_coloneScrollBar_valueChanged(int value)
 3691 {
 3692     ui.ParamgroupBox_2->setTitle(
 3693         "Param Grid(u,v)/MaxGrid = (" +
 3694         QString::number(MathmodRef->ParObjet->Vgrid) + ", " +
 3695         QString::number(value) +") / "+QString::number(Parameters->ParMaxGrid));
 3696     if (!MathmodRef->ParObjet->isRunning())
 3697     {
 3698         MathmodRef->column_valueChanged(value);
 3699     }
 3700     else
 3701     {
 3702         ui.uv->blockSignals(true);
 3703         ui.uv->setChecked(false);
 3704         ui.uv->blockSignals(false);
 3705         MathmodRef->uvactivated = -1;
 3706     }
 3707 }
 3708 
 3709 void DrawingOptions::on_IsoComponent_activated(int index)
 3710 {
 3711     UpdateDescription(index, ISO_TYPE, MathmodRef->RootObjet.CurrentTreestruct);
 3712     updateShowIsoCmp(index);
 3713 }
 3714 void DrawingOptions::updateShowParComp(int index)
 3715 {
 3716     if(MathmodRef->LocalScene.componentsinfos.ShowParIsoCmp[index])
 3717     {
 3718         ui.ShowParComp->setChecked(true);
 3719         ui.ShowParComp->setText("Hide");
 3720     }
 3721     else
 3722     {
 3723         ui.ShowParComp->setChecked(false);
 3724         ui.ShowParComp->setText("Show");
 3725     }
 3726 }
 3727 void DrawingOptions::updateShowIsoCmp(int index)
 3728 {
 3729     uint idx=0;
 3730     if(!MathmodRef->LocalScene.componentsinfos.pariso)
 3731         idx = index;
 3732     else
 3733         idx = MathmodRef->LocalScene.componentsinfos.NbComponentsType[0]+index;
 3734     if(MathmodRef->LocalScene.componentsinfos.ShowParIsoCmp[idx])
 3735     {
 3736         ui.ShowIsoComp->setChecked(true);
 3737         ui.ShowIsoComp->setText("Hide");
 3738     }
 3739     else
 3740     {
 3741         ui.ShowIsoComp->setChecked(false);
 3742         ui.ShowIsoComp->setText("Show");
 3743     }
 3744 }
 3745 void DrawingOptions::on_ParamComponent_activated(int index)
 3746 {
 3747     UpdateDescription(index, PAR_TYPE, MathmodRef->RootObjet.CurrentTreestruct);
 3748     updateShowParComp(index);
 3749 }
 3750 
 3751 void DrawingOptions::on_xyzcheckBox2_clicked()
 3752 {
 3753     MathmodRef->LocalScene.animxyz *= -1;
 3754 }
 3755 
 3756 void DrawingOptions::on_xycheckBox2_clicked()
 3757 {
 3758     MathmodRef->LocalScene.animx *= -1;
 3759 }
 3760 
 3761 void DrawingOptions::on_xyhorizontalScrollBar2_valueChanged(int value)
 3762 {
 3763     MathmodRef->LocalScene.animxValueStep = float(value) / 4;
 3764 }
 3765 
 3766 void DrawingOptions::on_xzcheckBox2_clicked()
 3767 {
 3768     MathmodRef->LocalScene.animy *= -1;
 3769 }
 3770 
 3771 void DrawingOptions::on_xzhorizontalScrollBar2_valueChanged(int value)
 3772 {
 3773     MathmodRef->LocalScene.animyValueStep = float(value) / 4;
 3774 }
 3775 
 3776 void DrawingOptions::on_yzcheckBox2_clicked()
 3777 {
 3778     MathmodRef->LocalScene.animz *= -1;
 3779 }
 3780 
 3781 void DrawingOptions::on_yzhorizontalScrollBar2_valueChanged(int value)
 3782 {
 3783     MathmodRef->LocalScene.animzValueStep = float(value) / 4;
 3784 }
 3785 
 3786 void DrawingOptions::on_InitMatrix_2_clicked()
 3787 {
 3788     MathmodRef->LocalScene.RotStrength =
 3789         MathmodRef->LocalScene.animxValueStep =
 3790             MathmodRef->LocalScene.animyValueStep =
 3791                 MathmodRef->LocalScene.animzValueStep = 0.0;
 3792 }
 3793 
 3794 void DrawingOptions::on_xycheckBox_clicked()
 3795 {
 3796     MathmodRef->ParObjet->tetaxy_ok *= -1;
 3797 }
 3798 
 3799 void DrawingOptions::on_xyhorizontalScrollBar_valueChanged(int value)
 3800 {
 3801     MathmodRef->ParObjet->tetaxy = value / 4.0;
 3802 }
 3803 
 3804 void DrawingOptions::on_xzcheckBox_clicked()
 3805 {
 3806     MathmodRef->ParObjet->tetaxz_ok *= -1;
 3807 }
 3808 
 3809 void DrawingOptions::on_xzhorizontalScrollBar_valueChanged(int value)
 3810 {
 3811     MathmodRef->ParObjet->tetaxz = value / 4.0;
 3812 }
 3813 
 3814 void DrawingOptions::on_yzcheckBox_clicked()
 3815 {
 3816     MathmodRef->ParObjet->tetayz_ok *= -1;
 3817 }
 3818 
 3819 void DrawingOptions::on_yzhorizontalScrollBar_valueChanged(int value)
 3820 {
 3821     MathmodRef->ParObjet->tetayz = value / 4.0;
 3822 }
 3823 
 3824 void DrawingOptions::on_xwcheckBox_clicked()
 3825 {
 3826     MathmodRef->ParObjet->tetaxw_ok *= -1;
 3827 }
 3828 
 3829 void DrawingOptions::on_xwhorizontalScrollBar_valueChanged(int value)
 3830 {
 3831     MathmodRef->ParObjet->tetaxw = value / 4.0;
 3832 }
 3833 
 3834 void DrawingOptions::on_ywcheckBox_clicked()
 3835 {
 3836     MathmodRef->ParObjet->tetayw_ok *= -1;
 3837 }
 3838 
 3839 void DrawingOptions::on_ywhorizontalScrollBar_valueChanged(int value)
 3840 {
 3841     MathmodRef->ParObjet->tetayw = value / 4.0;
 3842 }
 3843 
 3844 void DrawingOptions::on_zwcheckBox_clicked()
 3845 {
 3846     MathmodRef->ParObjet->tetazw_ok *= -1;
 3847 }
 3848 
 3849 void DrawingOptions::on_zwhorizontalScrollBar_valueChanged(int value)
 3850 {
 3851     MathmodRef->ParObjet->tetazw = value / 4.0;
 3852 }
 3853 
 3854 void DrawingOptions::on_linecolumn_3_valueChanged(int value)
 3855 {
 3856     ui.ParamgroupBox_3->setTitle("Grid(u,v)/MaxGrid = (" + QString::number(value) +
 3857                                  ", " + QString::number(value) +") / "+QString::number(Parameters->ParMaxGrid));
 3858     if (!MathmodRef->ParObjet->isRunning())
 3859     {
 3860         MathmodRef->linecolumn_valueChanged_2(value);
 3861     }
 3862     else
 3863     {
 3864         ui.uv4D->blockSignals(true);
 3865         ui.uv4D->setChecked(false);
 3866         ui.uv4D->blockSignals(false);
 3867         MathmodRef->uvactivated4D = -1;
 3868     }
 3869 }
 3870 
 3871 void DrawingOptions::oncolor_4activated(int index)
 3872 {
 3873     MathmodRef->colorstypeParam(index);
 3874 }
 3875 
 3876 void DrawingOptions::on_uv4D_clicked()
 3877 {
 3878     MathmodRef->slot_uv4D_clicked();
 3879 }
 3880 
 3881 void DrawingOptions::on_uv_clicked()
 3882 {
 3883     (MathmodRef->RootObjet.CurrentJsonObject["ParIso"].isArray()) ?
 3884     MathmodRef->slot_uv_clicked(PARISO_TYPE) : MathmodRef->slot_uv_clicked(PAR_TYPE);
 3885 }
 3886 
 3887 void DrawingOptions::on_InitMatrix_clicked()
 3888 {
 3889     MathmodRef->ParObjet->mat4D.unit();
 3890     on_calculate_clicked();
 3891 }
 3892 
 3893 void DrawingOptions::on_ActivateCND_clicked(bool checked)
 3894 {
 3895     ui.CNDgroupBox->setEnabled(checked);
 3896     MathmodRef->LocalScene.activarecnd = checked;
 3897     MathmodRef->update();
 3898 }
 3899 
 3900 void DrawingOptions::on_TCNDcheckBox_clicked(bool checked)
 3901 {
 3902     MathmodRef->LocalScene.cndoptions[3] = checked;
 3903     MathmodRef->update();
 3904 }
 3905 
 3906 void DrawingOptions::on_FCNDcheckBox_clicked(bool checked)
 3907 {
 3908     MathmodRef->LocalScene.cndoptions[0] = checked;
 3909     MathmodRef->update();
 3910 }
 3911 
 3912 void DrawingOptions::on_TNCNDcheckBox_clicked(bool checked)
 3913 {
 3914     MathmodRef->LocalScene.cndoptions[4] = checked;
 3915     MathmodRef->update();
 3916 }
 3917 
 3918 void DrawingOptions::on_FNCNDcheckBox_clicked(bool checked)
 3919 {
 3920     MathmodRef->LocalScene.cndoptions[1] = checked;
 3921     MathmodRef->update();
 3922 }
 3923 
 3924 void DrawingOptions::on_TBordercheckBox_clicked(bool checked)
 3925 {
 3926     MathmodRef->LocalScene.cndoptions[2] = checked;
 3927     MathmodRef->update();
 3928 }
 3929 
 3930 void DrawingOptions::on_actionMesh_triggered()
 3931 {
 3932     MathmodRef->Mesh();
 3933 }
 3934 
 3935 void DrawingOptions::on_calculate_clicked()
 3936 {
 3937     on_InitTButton_clicked();
 3938     Run_JsonObject_activeted();
 3939 }
 3940 
 3941 void DrawingOptions::on_actionAbout_2_triggered()
 3942 {
 3943     ab.show();
 3944 }
 3945 
 3946 void DrawingOptions::on_actionLoad_json_script_triggered()
 3947 {
 3948     LoadNewFileModels(true);
 3949 }
 3950 
 3951 void DrawingOptions::on_actionScreenshot_triggered()
 3952 {
 3953     videoplay();
 3954 }
 3955 
 3956 void DrawingOptions::on_actionEditor_triggered()
 3957 {
 3958     editorwin();
 3959 }
 3960 
 3961 void DrawingOptions::on_actionColors_triggered()
 3962 {
 3963     colorsoptions();
 3964 }
 3965 
 3966 void DrawingOptions::on_Infos_clicked()
 3967 {
 3968     MathmodRef->iso_infos();
 3969 }
 3970 
 3971 void DrawingOptions::on_Mesh_clicked()
 3972 {
 3973     MathmodRef->Mesh();
 3974 }
 3975 
 3976 void DrawingOptions::on_Norm_clicked()
 3977 {
 3978     MathmodRef->draw_norm_clicked();
 3979 }
 3980 
 3981 void DrawingOptions::on_Fill_clicked()
 3982 {
 3983     MathmodRef->fill();
 3984 }
 3985 
 3986 void DrawingOptions::on_Trian_clicked()
 3987 {
 3988     MathmodRef->slot_triangles_clicked();
 3989 }
 3990 
 3991 void DrawingOptions::on_actionOpenGL_triggered()
 3992 {
 3993     Parameters->on_loadconfig_clicked();
 3994     Parameters->show();
 3995 }
 3996 
 3997 void DrawingOptions::on_cut_clicked()
 3998 {
 3999     if (ui.IsoComponent->count() > 1)
 4000     {
 4001         ui.isoNameEdit->setText("");
 4002         on_updateButton_clicked();
 4003     }
 4004     else
 4005     {
 4006         QMessageBox msgBox;
 4007         msgBox.setText("Only one component in this mathematical model.");
 4008         msgBox.exec();
 4009     }
 4010 }
 4011 
 4012 void DrawingOptions::on_actionConvert_K3DS_script_triggered()
 4013 {
 4014     LoadK3DSurfScript("", 1);
 4015 }
 4016 
 4017 void DrawingOptions::on_actionConfiguration_triggered()
 4018 {
 4019     on_actionOpenGL_triggered();
 4020 }
 4021 
 4022 void DrawingOptions::on_actionColors_2_triggered()
 4023 {
 4024     on_actionColors_triggered();
 4025 }
 4026 
 4027 void DrawingOptions::on_Load_clicked()
 4028 {
 4029     LoadNewFileModels(true);
 4030 }
 4031 
 4032 void DrawingOptions::on_ParamComponent_2_activated(int index)
 4033 {
 4034     UpdateDescription(index, PAR_4D_TYPE,
 4035                       MathmodRef->RootObjet.CurrentTreestruct);
 4036 }
 4037 
 4038 void DrawingOptions::on_updateParam_2_clicked()
 4039 {
 4040     on_updateButton_clicked();
 4041 }
 4042 
 4043 void DrawingOptions::Multiplier(int x, int y, int z, QJsonObject &iso,
 4044                                 int index)
 4045 {
 4046     QString Minx, Miny, Minz, Maxx, Maxy, Maxz;
 4047     QString Difx, Dify, Difz;
 4048     QString componentName, fct, cnd, grid;
 4049     QJsonArray oldminx, oldminy, oldminz, oldmaxx, oldmaxy, oldmaxz, oldcmpname,
 4050                oldfxyz, oldcnd, oldgrid;
 4051     bool cndb = false;
 4052     bool gridb = false;
 4053     oldminx = iso["Iso3D"].toObject()["Xmin"].toArray();
 4054     oldminy = iso["Iso3D"].toObject()["Ymin"].toArray();
 4055     oldminz = iso["Iso3D"].toObject()["Zmin"].toArray();
 4056     oldmaxx = iso["Iso3D"].toObject()["Xmax"].toArray();
 4057     oldmaxy = iso["Iso3D"].toObject()["Ymax"].toArray();
 4058     oldmaxz = iso["Iso3D"].toObject()["Zmax"].toArray();
 4059     oldcmpname = iso["Iso3D"].toObject()["Component"].toArray();
 4060     oldfxyz = iso["Iso3D"].toObject()["Fxyz"].toArray();
 4061     if ((gridb = (iso["Iso3D"].toObject()["Grid"].isArray())))
 4062         grid =
 4063             (oldgrid = iso["Iso3D"].toObject()["Grid"].toArray())[index].toString();
 4064     if ((cndb = (iso["Iso3D"].toObject()["Cnd"].isArray())))
 4065         cnd = (oldcnd = iso["Iso3D"].toObject()["Cnd"].toArray())[index].toString();
 4066     componentName = oldcmpname[index].toString();
 4067     fct = oldfxyz[index].toString();
 4068     Minx = "(" + oldminx[index].toString() + ")";
 4069     Miny = "(" + oldminy[index].toString() + ")";
 4070     Minz = "(" + oldminz[index].toString() + ")";
 4071     Maxx = "(" + oldmaxx[index].toString() + ")";
 4072     Maxy = "(" + oldmaxy[index].toString() + ")";
 4073     Maxz = "(" + oldmaxz[index].toString() + ")";
 4074     Difx = "((" + Maxx + "-" + Minx + ")/" + QString::number(x) + ")";
 4075     Dify = "((" + Maxy + "-" + Miny + ")/" + QString::number(y) + ")";
 4076     Difz = "((" + Maxz + "-" + Minz + ")/" + QString::number(z) + ")";
 4077     int l = 0;
 4078     for (int i = 0; i < x; i++)
 4079         for (int j = 0; j < y; j++)
 4080             for (int k = 0; k < z; k++)
 4081             {
 4082                 oldminx.append(Minx + "+" + QString::number(i) + "*" + Difx);
 4083                 oldmaxx.append(Minx + "+" + QString::number(i + 1) + "*" + Difx);
 4084                 oldminy.append(Miny + "+" + QString::number(j) + "*" + Dify);
 4085                 oldmaxy.append(Miny + "+" + QString::number(j + 1) + "*" + Dify);
 4086                 oldminz.append(Minz + "+" + QString::number(k) + "*" + Difz);
 4087                 oldmaxz.append(Minz + "+" + QString::number(k + 1) + "*" + Difz);
 4088                 oldcmpname.append(componentName + QString::number(l));
 4089                 oldfxyz.append(fct);
 4090                 if (cndb)
 4091                     oldcnd.append(cnd);
 4092                 if (gridb)
 4093                     oldgrid.append(grid);
 4094                 l++;
 4095             }
 4096     oldminx.removeAt(index);
 4097     oldminy.removeAt(index);
 4098     oldminz.removeAt(index);
 4099     oldmaxx.removeAt(index);
 4100     oldmaxy.removeAt(index);
 4101     oldmaxz.removeAt(index);
 4102     oldcmpname.removeAt(index);
 4103     oldfxyz.removeAt(index);
 4104     if (cndb)
 4105         oldcnd.removeAt(index);
 4106     if (gridb)
 4107         oldgrid.removeAt(index);
 4108     QJsonObject tmp = iso["Iso3D"].toObject();
 4109     tmp["Xmin"] = oldminx;
 4110     tmp["Ymin"] = oldminy;
 4111     tmp["Zmin"] = oldminz;
 4112     tmp["Xmax"] = oldmaxx;
 4113     tmp["Ymax"] = oldmaxy;
 4114     tmp["Zmax"] = oldmaxz;
 4115     tmp["Component"] = oldcmpname;
 4116     tmp["Fxyz"] = oldfxyz;
 4117     if (cndb)
 4118         tmp["Cnd"] = oldcnd;
 4119     if (gridb)
 4120         tmp["Grid"] = oldgrid;
 4121     iso["Iso3D"] = tmp;
 4122 }
 4123 
 4124 void DrawingOptions::on_Multiplier_clicked()
 4125 {
 4126     int i = ui.xcomboBox->currentIndex(), j = ui.ycomboBox->currentIndex(),
 4127         k = ui.zcomboBox->currentIndex();
 4128     if (i > 0 && j > 0 && k > 0)
 4129     {
 4130         QJsonObject copyCurrentObject = MathmodRef->RootObjet.CurrentJsonObject;
 4131         // Erase unused Keys:
 4132         copyCurrentObject.remove("Param3D");
 4133         copyCurrentObject.remove("Param4D");
 4134         Multiplier(i, j, k, copyCurrentObject, IndexcurrentComponent);
 4135         // Draw here
 4136         DrawJsonModel(copyCurrentObject);
 4137     }
 4138     // Init Combo
 4139     ui.xcomboBox->setCurrentIndex(0);
 4140     ui.ycomboBox->setCurrentIndex(0);
 4141     ui.zcomboBox->setCurrentIndex(0);
 4142 }
 4143 
 4144 void DrawingOptions::UpdateGuiMaxgrid()
 4145 {
 4146     int maxgrd = int(Parameters->IsoMaxGrid);
 4147     ui.xyzg->blockSignals(true);
 4148     ui.xyzg->setMaximum(maxgrd);
 4149     ui.xyzg->setValue(int(Parameters->InitIsoGrid));
 4150     ui.xyzg->blockSignals(false);
 4151     ui.linecolumn_2->blockSignals(true);
 4152     ui.linecolumn_2->setMaximum(int(Parameters->ParMaxGrid));
 4153     ui.linecolumn_2->setValue(int(Parameters->InitParGrid));
 4154     ui.linecolumn_2->blockSignals(false);
 4155     ui.linecolumn_3->blockSignals(true);
 4156     ui.linecolumn_3->setMaximum(int(Parameters->ParMaxGrid));
 4157     ui.linecolumn_3->setValue(int(Parameters->InitParGrid));
 4158     ui.linecolumn_3->blockSignals(false);
 4159 }
 4160 
 4161 void DrawingOptions::UpdateGui(int argc)
 4162 {
 4163     UpdateGuiMaxgrid();
 4164     ListeModelTexture LstModelTexture = (Parameters->LoadCollectionModels(
 4165             JSONMathModels, MathmodRef->collection, argc));
 4166     // Load the script containing isosurface and parametric formulas:
 4167     ui.choice->insertItems(0, LstModelTexture.listeModels);
 4168     ui.comboBoxTexture->insertItems(0, LstModelTexture.listeTextures);
 4169     ui.comboBoxPigment->insertItems(0, LstModelTexture.listePigments);
 4170     AddListModels();
 4171     // Threads setting:
 4172     SetThreadValues(Parameters->Threads);
 4173     // OpenGl specular:
 4174     SetSpecularValues(Parameters->Specular);
 4175     // OpenGl shininess:
 4176     SetShininessValue(Parameters->Shininess);
 4177     // OpenGl diffuse:
 4178     SetDiffuseValues(Parameters->Diffuse);
 4179     // OpenGl Ambient:
 4180     SetAmbientValues(Parameters->Ambient);
 4181     // Show the two windows of the application:
 4182     move(Parameters->ControlX, Parameters->ControlY);
 4183     resize(Parameters->ControlW, Parameters->ControlH);
 4184     // ui.CndGroupBox->hide();
 4185     // ui.NameLabel->hide();
 4186     MathmodRef->move(Parameters->GlwinX, Parameters->GlwinY);
 4187     MathmodRef->resize(Parameters->GlwinW, Parameters->GlwinH);
 4188     //MathmodRef->setFixedSize(Parameters->GlwinW, Parameters->GlwinH);
 4189     // Pigment/texture
 4190     ui.textureEdit->hide();
 4191     // Hide all sliders
 4192     HideSliders();
 4193     // ProgressBar + text informations (set to minimum size 0)
 4194     QList<int> Sizes;
 4195     Sizes << 500 << 300;
 4196     ui.splitter_6->setSizes(Sizes);
 4197     ui.Messagetext->setFontPointSize(10);
 4198 }
 4199 
 4200 void DrawingOptions::on_TimeStepScrollBar_valueChanged(int value)
 4201 {
 4202     double P = 1.0 / double(value);
 4203     uint maxnbthreads = MathmodRef->IsoObjet->WorkerThreadsNumber;
 4204     ui.label_5->setText("1/" + QString::number(value));
 4205     MathmodRef->IsoObjet->masterthread->pace = P;
 4206     for (uint nbthreds = 0; nbthreds < maxnbthreads - 1; nbthreds++)
 4207         MathmodRef->IsoObjet->workerthreads[nbthreds].pace = P;
 4208     MathmodRef->ParObjet->masterthread->pace = P;
 4209     for (uint nbthreds = 0; nbthreds < maxnbthreads - 1; nbthreds++)
 4210         MathmodRef->ParObjet->workerthreads[nbthreds].pace = P;
 4211 }
 4212 
 4213 void DrawingOptions::on_InitTButton_clicked()
 4214 {
 4215     uint maxnbthreads = MathmodRef->IsoObjet->WorkerThreadsNumber;
 4216     MathmodRef->IsoObjet->masterthread->stepMorph = 0;
 4217     for (uint nbthreds = 0; nbthreds < maxnbthreads - 1; nbthreds++)
 4218         MathmodRef->IsoObjet->workerthreads[nbthreds].stepMorph = 0;
 4219     MathmodRef->ParObjet->masterthread->stepMorph = 0;
 4220     for (uint nbthreds = 0; nbthreds < maxnbthreads - 1; nbthreds++)
 4221         MathmodRef->ParObjet->workerthreads[nbthreds].stepMorph = 0;
 4222 }
 4223 
 4224 void DrawingOptions::ShowErrorMessage(QJsonParseError &err, QString &script)
 4225 {
 4226     QString sortie;
 4227     QMessageBox message;
 4228     message.setWindowTitle("Error at : ");
 4229     sortie = (script);
 4230     int before, after;
 4231     if (sortie.length() > (err.offset + 30))
 4232         after = 30;
 4233     else
 4234         after = sortie.length() - err.offset;
 4235     sortie.truncate(err.offset + after);
 4236     if (err.offset - 30 > 0)
 4237         before = 30;
 4238     else
 4239         before = 0;
 4240     sortie = sortie.remove(0, err.offset - before);
 4241     sortie.replace("\t", " ");
 4242     sortie.replace("\n", " ");
 4243     sortie.insert(before, " >>> Error <<< ");
 4244     message.setText("Error : " + err.errorString() +
 4245                     " at position: " + QString::number(err.offset) +
 4246                     "\n\n***********\n" + "..." + sortie + "...");
 4247     message.adjustSize();
 4248     message.exec();
 4249     return;
 4250 }
 4251 
 4252 void DrawingOptions::on_pushButton_2_clicked()
 4253 {
 4254     QJsonParseError err;
 4255     QString sortie;
 4256     QString script =
 4257         ui.ParamEdit->toPlainText().trimmed().replace("\n", "").replace("\t", "").replace("DOTSYMBOL", Parameters->dotsymbol.toStdString().c_str());
 4258     QJsonDocument doc = QJsonDocument::fromJson(script.toUtf8(), &err);
 4259     if (err.error)
 4260     {
 4261         ShowErrorMessage(err, script);
 4262         return;
 4263     }
 4264     Parameters->SaveToFile_CurentMathModel(doc.object());
 4265 }
 4266 
 4267 void DrawingOptions::on_pushButton_3_clicked()
 4268 {
 4269     ui.isoNameEdit->setText(ui.isoNameEdit->toPlainText() + "_01");
 4270     on_updateButton_clicked();
 4271 }
 4272 
 4273 void DrawingOptions::on_cut_2_clicked()
 4274 {
 4275     if (ui.ParamComponent->count() > 1)
 4276     {
 4277         ui.paramNameEdit->setText("");
 4278         on_updateButton_clicked();
 4279     }
 4280     else
 4281     {
 4282         QMessageBox msgBox;
 4283         msgBox.setText("Only one component in this mathematical model.");
 4284         msgBox.exec();
 4285     }
 4286 }
 4287 
 4288 void DrawingOptions::on_pushButton_4_clicked()
 4289 {
 4290     ui.paramNameEdit->setText(ui.paramNameEdit->toPlainText() + "_01");
 4291     on_updateButton_clicked();
 4292 }
 4293 
 4294 void DrawingOptions::on_color_5_activated(int index)
 4295 {
 4296     MathmodRef->colorstypeParIso(index);
 4297 }
 4298 
 4299 void DrawingOptions::on_transparent_ParIso_valueChanged(int value)
 4300 {
 4301     MathmodRef->transparency(value, IndexcurrentComponent);
 4302 }
 4303 
 4304 void DrawingOptions::on_comboBoxTexture_activated(int index)
 4305 {
 4306     QJsonObject tmp;
 4307     tmp = MathmodRef->RootObjet.CurrentJsonObject;
 4308 
 4309     if (index > 0)
 4310     {
 4311         QJsonDocument document;
 4312         document.setObject(MathmodRef->collection.JTextures[index - 1].toObject());
 4313         ui.textureEdit->setText(QString(document.toJson()));
 4314         DrawJsonModel(tmp, index - 1);
 4315     }
 4316     return;
 4317 }
 4318 
 4319 void DrawingOptions::on_comboBoxPigment_activated(int index)
 4320 {
 4321     QJsonObject tmp;
 4322     tmp = MathmodRef->RootObjet.CurrentJsonObject;
 4323     if (index > 0)
 4324     {
 4325         QJsonDocument document;
 4326         document.setObject(MathmodRef->collection.JPigments[index - 1].toObject());
 4327         ui.textureEdit->setText(QString(document.toJson()));
 4328         DrawJsonModel(tmp, 1000 + index - 1);
 4329     }
 4330     return;
 4331 }
 4332 
 4333 void DrawingOptions::on_actionTrianglesWavefront_obj_triggered()
 4334 {
 4335     MathmodRef->SaveSceneAsObjTrian();
 4336 }
 4337 
 4338 void DrawingOptions::on_actionColorTrianglesWavefront_obj_triggered()
 4339 {
 4340     MathmodRef->SaveSceneAsObjTrian(1);
 4341 }
 4342 
 4343 void DrawingOptions::on_ShowtextureScript_clicked()
 4344 {
 4345     static int show = -1;
 4346     show *= -1;
 4347     if (show ==