Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
QHyodaToolCell.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7#include "QHyodaJob.h"
8#include "QHyodaToolCell.h"
9#include "QHyodaGLCell.h"
10
11
12/******************************************************************************
13 * STATIC DECLARATIONS
14 *****************************************************************************/
15static double rawStringToDouble(QString qStr);
16static unsigned long long rawStringToULongLong(QString qStr);
17
18
19
20
21/******************************************************************************
22 * QHyodaToolCell
23 *****************************************************************************/
24QHyodaToolCell::QHyodaToolCell(QHyodaJob *_job,
25 QHyodaTool *_tools):job(_job),
26 tools(_tools),
27 cell(new QHyodaGLCell(this)){
28 qDebug() << "QHyodaToolCell::QHyodaToolCell";
29 setupUi(this);
30 groupBox->layout()->addWidget(cell);
31 vLayout->setStretch(1,1);
32 connect(targetCellNumLineEdit, SIGNAL(returnPressed()), this, SLOT(targetCellUidLineEditSlot()));
33 connect(cellHSlider,SIGNAL(valueChanged(int)), this, SLOT(targetCellUidSliderSlot(int)));
34 targetCellNumLineEdit->setEnabled(true);
35 cellHSlider->setEnabled(true);
36 qDebug() << "QHyodaToolCell::QHyodaToolCell done";
37}
38
39
40/******************************************************************************
41 * ~QHyodaToolCell
42 *****************************************************************************/
43QHyodaToolCell::~QHyodaToolCell(){
44 qDebug() << "QHyodaToolCell::~QHyodaToolCell";
45 delete cell;
46}
47
48
49void QHyodaToolCell::close(){
50 qDebug() << "QHyodaToolCell::cell";
51}
52
53
54/******************************************************************************
55 * setRange
56 *****************************************************************************/
57void QHyodaToolCell::setRange(quint64 mesh_total_nb_cell){
58 //qDebug()<<"QHyodaToolCell::setRange"<<mesh_total_nb_cell;
59 cellHSlider->setMaximum(mesh_total_nb_cell-1);
60 cellHSlider->setTickInterval(mesh_total_nb_cell>>2);
61 cellHSlider->setPageStep(mesh_total_nb_cell>>3);
62 cellHSlider->setSingleStep(mesh_total_nb_cell>>8);
63 cellHSlider->setValue((mesh_total_nb_cell>>1)-1);
64 //qDebug()<<"QHyodaToolCell::setRange done";
65}
66
67static unsigned int l2g(unsigned int i){
68 if (i==0) return 0;
69 if (i==1) return 1;
70 if (i==2) return 2;
71 if (i==3) return 3;
72 if (i==4) return 4;
73 if (i==5) return 5;
74 if (i==6) return 6;
75 if (i==7) return 7;
76 qFatal("l2g INVALID code!");
77}
78
79/******************************************************************************
80 * refresh
81 *****************************************************************************/
82void QHyodaToolCell::refresh(const QStringList &splitted_output){
83 //qDebug()<<"\33[7m[QHyodaToolCell::refresh] splitted_output=" << splitted_output << "\33[m";
84 //qDebug()<<"QHyodaToolCell::refresh target_cell_uid"<<job->data->target_cell_uid;
85
86 unsigned long long got_target_cell_rank=rawStringToULongLong(splitted_output.at(29));
87 uidRankLabel->setText(QString("%1").arg(got_target_cell_rank));
88
89 cell->cell_nb_nodes=rawStringToULongLong(splitted_output.at(31));
90 //qDebug()<<"\33[7m[QHyodaToolCell::refresh] got_target_cell_nb_nodes="<<cell->cell_nb_nodes<< "\33[m";
91
92 const int offset=33;
93
94 // Flush current coords
95 for(unsigned int i=0;i<cell->cell_nb_nodes; ++i)
96 coords[i][0]=coords[i][1]=coords[i][2]=0.0;
97
98 // On flush toute la structure géométrique
99 cell->clear();
100
101 // On fetch le noeud 0, mais on l'impose à 0.0 (on le translate à l'origine)
102 coords[0][0]=rawStringToDouble(splitted_output.at(offset+0));
103 coords[0][1]=rawStringToDouble(splitted_output.at(offset+2));
104 coords[0][2]=rawStringToDouble(splitted_output.at(offset+4));
105 // On le pousse dans la géométrie comme référence
106 cell->add_node(QVector3D(0.0,0.0,0.0), QColor(Qt::blue));
107
108 for(unsigned int iNode=1, iAt=offset+6; iNode<cell->cell_nb_nodes; ++iNode,iAt+=6){
109 coords[iNode][0]=rawStringToDouble(splitted_output.at(iAt))-coords[0][0];
110 coords[iNode][1]=rawStringToDouble(splitted_output.at(iAt+2))-coords[0][1];
111 coords[iNode][2]=rawStringToDouble(splitted_output.at(iAt+4))-coords[0][2];
112 //qDebug()<<"QHyodaToolCell::refresh "<<coords[iNode][0]<<coords[iNode][1]<<coords[iNode][2];
113 cell->add_node(QVector3D(coords[iNode][0],coords[iNode][1],coords[iNode][2]), QColor(Qt::cyan));
114 }
115 cell->update();
116}
117
118
119/******************************************************************************
120 * targetCellUidLineEditSlot
121 *****************************************************************************/
122void QHyodaToolCell::targetCellUidLineEditSlot(void){
123 bool ok;
124 unsigned long long text2ull=targetCellNumLineEdit->text().toULongLong(&ok,10);
125 if ((!ok) || (text2ull>=job->data->mesh_total_nb_cell)){
126 qDebug()<<"QHyodaToolCell::targetCellUidLineEditSlot ERROR while converting targetCellUid";
127 return;
128 }
129 job->data->target_cell_uid=text2ull;
130 cellHSlider->setValue(text2ull);
131 job->gdb->state=QHyodaGdb::TargetCell;
132}
133
134
135/******************************************************************************
136 * targetCellUidSliderSlot
137 *****************************************************************************/
138void QHyodaToolCell::targetCellUidSliderSlot(int value){
139// qDebug()<<"QHyodaJob::targetCellUidSliderSlot targetCellUid"<<cellHSlider->value();
140 targetCellNumLineEdit->setText(QString("%1").arg(value));
141 job->data->target_cell_uid=value;
142 job->gdb->state=QHyodaGdb::TargetCell;
143}
144
145
146
147/******************************************************************************
148 * STATIC TOOLS
149 *****************************************************************************/
150static double rawStringToDouble(QString qStr){
151 const char *s=qStr.toLocal8Bit().constData();
152 double ret=0.;
153 sscanf(s, "%llx", (unsigned long long *)&ret);
154 return ret;
155}
156
157static unsigned long long rawStringToULongLong(QString qStr){
158 const char *s=qStr.toLocal8Bit().constData();
159 unsigned long long ret=0;
160 sscanf(s, "%llx", &ret);
161 return ret;
162}