-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformobjectcontrol.cc
1958 lines (1873 loc) · 77.7 KB
/
formobjectcontrol.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ============================================================================
// Copyright Jean-Charles LAMBERT - 2007-2023
// e-mail: [email protected]
// address: Centre de donneeS Astrophysique de Marseille (CeSAM)
// Laboratoire d'Astrophysique de Marseille
// P�le de l'Etoile, site de Ch�teau-Gombert
// 38, rue Fr�d�ric Joliot-Curie
// 13388 Marseille cedex 13 France
// CNRS U.M.R 7326
// ============================================================================
// See the complete license in LICENSE and/or "http://www.cecill.info".
// ============================================================================
#include "glwindow.h"
#include "formobjectcontrol.h"
#include <iostream>
#include <sstream>
#include <QTableWidgetItem>
#include <QColorDialog>
#include <QRegExp>
#include <assert.h>
#include <QFileDialog>
#include <QMessageBox>
#include "globaloptions.h"
#include "gltexture.h"
#include "glnemoexception.h"
namespace glnemo {
#define RT_VISIB 0
#define RT_COLOR 2
#define ST_VISIB 0
#define ST_COLOR 1
#define FT_VISIB 0
#define FT_COLOR 3
int last_row=0;
bool EMIT=true; // EMIT only signal from user requests
// Object Start Table
int osrange=0;
int osselec=0;
int osfile =0;
// ============================================================================
// Constructor
// create the 2 tables : Range and File
FormObjectControl::FormObjectControl(CPointsetManager *_pointset_manager, GlobalOptions *global_options,
QWidget *parent) : QDialog(parent)
{
pointset_manager = _pointset_manager;
go = global_options;
ignoreCloseEvent = true;
form.setupUi(this);
current_data = NULL;
// set number of rows per table (20)
form.range_table->setRowCount(20);
osrange=0;
osselec=osrange+form.range_table->rowCount();
form.range_table->setColumnWidth(0,25); // Vis
form.range_table->setColumnWidth(1,150); // Range
form.range_table->setColumnWidth(2,45); // Color
for (int i=0; i < form.range_table->rowCount(); i++) {
form.range_table->setRowHeight(i,25);
}
// create object index array
int no=form.range_table->rowCount();
object_index = new int[no];
for (int i=0; i<no;i++) object_index[i]=-1; // -1=>object does not exist
current_object = 0;
pov = NULL;
first=true;
lock = true;
// insert checkbox and color widget into tables
initTableWidget(form.range_table ,0,RT_VISIB,RT_COLOR); // range
// Selection mode and behaviour
form.range_table->setSelectionMode(QAbstractItemView::SingleSelection);
form.range_table->setSelectionBehavior(QAbstractItemView::SelectItems);
// create range selection combobox to store objects' particles indexes.
combobox = new QComboBoxTable(0,0,0);
form.range_table->setCellWidget(0,RT_COLOR-1,combobox);
// add default object range
combobox->addItem("");
combobox->addItem("0:99999"); // add default range 1
combobox->addItem("0:199999"); // add default range 2
connect(combobox,SIGNAL(comboActivated(const int, const int)),this,
SLOT(checkComboLine(const int, const int)));
// intialyze texture combobox according to the texture array
// loop and load all embeded textures
int i=0;
while (GLTexture::TEXTURE[i][0]!=NULL) {
form.texture_box->addItem(QIcon(GlobalOptions::RESPATH+GLTexture::TEXTURE[i][0]),GLTexture::TEXTURE[i][1]);
std::cerr << "texture i="<<i<<" = " << GLTexture::TEXTURE[i][1].toStdString() << "\n";
i++;
}
// check GLSL_support
if (! GLWindow::GLSL_support) {
form.gaz_glsl_check->setChecked(false);
form.gaz_glsl_check->setDisabled(true);
} else {
form.gaz_glsl_check->setChecked(true);
}
//connect(combobox,SIGNAL(my_editTextChanged(const QString&, const int, const int)),
// this,SLOT(updateRange(const QString&, const int, const int)));
//form.dens_histo_view->setParent(form.tab_density);
dens_histo = new DensityHisto(form.dens_histo_view);
form.dens_histo_view->setScene(dens_histo);
form.dens_histo_view->repaint();
//DEACTIVARED form.dens_glob_box->setDisabled(true);
dens_color_bar = new DensityColorBar(go,form.dens_bar_view);
form.dens_bar_view->setScene(dens_color_bar);
form.objects_properties->setTabEnabled(1,false);
form.objects_properties->setCurrentIndex(0); // set position to first tab
my_mutex2 = new QMutex(QMutex::Recursive);
auto custom_delete_cpointset_btn = new DeletePushButton();
custom_delete_cpointset_btn->setObjectName(form.delete_cpointset_btn->objectName());
custom_delete_cpointset_btn->setToolTip(form.delete_cpointset_btn->toolTip());
custom_delete_cpointset_btn->setText(form.delete_cpointset_btn->text());
form.delete_cpointset_layout->replaceWidget(form.delete_cpointset_btn, custom_delete_cpointset_btn);
connect(custom_delete_cpointset_btn, SIGNAL(deleteClicked(bool)), this, SLOT(delete_cpointsets(bool)));
auto custom_delete_cpoints_btn = new DeletePushButton();
custom_delete_cpoints_btn->setObjectName(form.delete_cpoints_btn->objectName());
custom_delete_cpoints_btn->setToolTip(form.delete_cpoints_btn->toolTip());
custom_delete_cpoints_btn->setText(form.delete_cpoints_btn->text());
form.delete_cpoints_layout->replaceWidget(form.delete_cpoints_btn, custom_delete_cpoints_btn);
connect(custom_delete_cpoints_btn, SIGNAL(deleteClicked(bool)), this, SLOT(delete_cpoints(bool)));
delete form.delete_cpoints_btn;
delete form.delete_cpointset_btn;
form.cpoints_set_treewidget->setSelectionMode(QAbstractItemView::SelectionMode::ExtendedSelection);
form.cpoints_set_treewidget->setColumnHidden(1, true);
// form.color_picker_button->setStyleSheet("QPushButton:disabled{background-color:#eeeeee}"); // FIXME does not work
}
// ============================================================================
// Destructor
FormObjectControl::~FormObjectControl()
{
delete [] object_index;
delete dens_histo;
delete dens_color_bar;
}
// ============================================================================
// initTableWidget()
// Initialize Range and File table
void FormObjectControl::initTableWidget(QTableWidget * table, const int i_table,
const int c_visib, const int c_col)
{
for (int i=0; i<table->rowCount(); i++) {
#if 0
ParticlesObject * po = new ParticlesObject();
povrange.push_back(*po);
delete po;
#endif
// set checkbox widget
QCheckBoxTable * checkbox = new QCheckBoxTable(i,i_table,this);
assert(checkbox);
if ( ! i_table)
connect(checkbox,SIGNAL(changeVisib(const bool,const int ,const int )),
this,SLOT(updateVisib(const bool ,const int ,const int )));
else
connect(checkbox,SIGNAL(changeVisib(const bool,const int ,const int )),
this,SLOT(updateVisib(const bool ,const int ,const int )));
checkbox->setChecked(false);
table->setCellWidget(i,c_visib,checkbox);
// set Color
QTableWidgetItem * cellcol=new QTableWidgetItem();
cellcol->setBackground(Qt::white);
table->setItem(i,c_col,cellcol);
// set particles info
QTableWidgetItem * partcol=new QTableWidgetItem();
partcol->setText(""); // put a blank text
table->setItem(i,c_col-1,partcol);
}
}
// ============================================================================
// resetTableWidget()
// RAZ Range and File table
void FormObjectControl::resetTableWidget(QTableWidget * table, const int i_table,
const int c_col, const int row)
{
// get item color
QTableWidgetItem * cellcol = table->item(row,c_col);
assert(cellcol);
// set color
cellcol->setBackground(Qt::white);
//!!table->setItem(row,c_col,cellcol);
// get visibility box
QCheckBoxTable * checkbox = static_cast<QCheckBoxTable *>
(table->cellWidget(row,i_table));
assert(checkbox);
// set visibility
checkbox->setChecked(false);
// set particles info
QTableWidgetItem * partrange=table->item(row,c_col-1);
assert(partrange);
partrange->setText(""); // put a blank text
//!!table->setItem(row,c_col-1,partrange);
}
// ============================================================================
// update()
// upate table with new objects
void FormObjectControl::update(ParticlesData * _p_data,
ParticlesObjectVector * _pov,
GlobalOptions * _go,
bool reset_table)
{
go = _go;
dens_color_bar->setGo(go);
form.dynamic_cmap->setChecked(go->dynamic_cmap);
if (go && ! go->duplicate_mem) mutex_data->lock();
lock=false;
current_data = _p_data;
nbody = *(current_data->nbody);
pov = _pov;
// get physical value data array
phys_select = current_data->getPhysData();
// parse all the objects to check if physic is present
checkPhysic();
int cpt=0;
combobox->clear();
for (int i=0; i < form.range_table->rowCount(); i++) {
if (i < (int) pov->size()) { // remains objects
object_index[i]=cpt++;
QTableWidget * tw;
if ((*pov)[i].selectFrom() == ParticlesObject::Range) { // Range
tw = form.range_table;
updateTable(tw,i,RT_VISIB ,RT_COLOR);
updateRangeTable(i);
}
#if 0
else { // File
tw = form.range_table;
updateTable(tw,i,FT_VISIB,FT_COLOR);
updateFileTable(i);
}
#endif
//updateObjectSettings(i);
}
else { // not belonging to object list
if (reset_table) {
object_index[i]=-1;
resetTableWidget(form.range_table,RT_VISIB,RT_COLOR,i);
} else {
//std::cerr << "combobox = " << (combobox->currentText()).toStdString() << "\n";
}
}
//if (i) form.range_table->setCellWidget(i,1,NULL);
}
first=false;
///!!!!updateObjectSettings(0);
///MODIFICATION April,15 2011
updateObjectSettings(last_row);
EMIT=false;
// stretch tab
form.z_stretch_jit_cb->setChecked(go->z_stretch_jit);
form.z_stretch_max_spin->setValue((double) go->z_stretch_max);
form.z_stretch_slide->setValue(form.z_stretch_slide->maximum());
EMIT=true;
///MODIFICATION April,15 2011
form.range_table->setCurrentCell(current_object,1);
// set active row
lock=true;
if (go && ! go->duplicate_mem) mutex_data->unlock();
on_range_table_cellClicked(last_row,1);
//physicalSelected();
}
// ============================================================================
// updateTable()
void FormObjectControl::updateTable(QTableWidget * table, const int row,
const int c_visib, const int c_col)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj=object_index[row]; // object's index
assert(i_obj < (int)pov->size());
// update visible box
QCheckBoxTable * checkbox = static_cast<QCheckBoxTable *>(table->cellWidget(row,c_visib));
assert(checkbox);
checkbox->setChecked((*pov)[i_obj].isVisible());
// update color
QTableWidgetItem * twi = table->item(row,c_col);
assert(twi);
twi->setBackground(QBrush((*pov)[i_obj].getColor())); // !!!!!!!
//(*pov)[i_obj].setColor(twi->background().color()); // !!!!!!!
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// updateRangeTable()
void FormObjectControl::updateRangeTable(const int row)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj=object_index[row]; // object's index
assert(i_obj < (int)pov->size());
QString text;
if ((*pov)[i_obj].step == 1)
text = QString("%1:%2" ).arg((*pov)[i_obj].first,0,10).arg((*pov)[i_obj].last,0,10);
else
text = QString("%1:%2:%3").arg((*pov)[i_obj].first,0,10)
.arg((*pov)[i_obj].last ,0,10)
.arg((*pov)[i_obj].step ,0,10);
QTableWidgetItem * twi = form.range_table->item(row,1);
assert(twi);
twi->setText(text); // put the object range corresponding to the object to the TABLE
combobox->addItem(text);// add the object range in the combobox
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// updateFileTable()
void FormObjectControl::updateFileTable(const int row)
{
if (row) {;}
}
// ============================================================================
// on_range_table_cellClicked()
// process the Clicked event
int FormObjectControl::on_range_table_cellClicked(int row,int column)
{
if (! pov) return 0;
//if (lock)
if (go && ! go->duplicate_mem)
mutex_data->lock();
lock=false;
bool valid=false;
last_row = row; // save the current row clicked
int i_obj= object_index[row]; // object's index
//assert(i_obj < (int)pov->size());
// -
// --- process click event on [combo box cell]
// -
int rcolumn=1;
// get the combobox from the active cell
QComboBoxTable * my_combo = static_cast<QComboBoxTable *>
(form.range_table->cellWidget(row,rcolumn));
// get back the text line from cell
QTableWidgetItem * item = (form.range_table->item(row,rcolumn)); // check item in range column !!
assert(item);
QString text="none";
text=item->text();
if ( ! my_combo ) { // no combobox yet from the cell
if (form.range_table->cellWidget(combobox->row,rcolumn)) {
QComboBoxTable * combobox1 = new QComboBoxTable(row,rcolumn,this); // new combo
*combobox1 = *combobox; // copy old to new
form.range_table->removeCellWidget(combobox->row,rcolumn); // remove old
delete combobox;
combobox = combobox1; // link old to new
// establish connection
connect(combobox,
SIGNAL(comboActivated(
const int, const int)),this,
SLOT(checkComboLine(const int, const int)));
}
combobox->row = row; // adjust row
combobox->display();
combobox->setEditText(item->text()); // add object to the combobox
form.range_table->setCellWidget(row,rcolumn,combobox); // put the combobox to the current cell
}
else { // widget exist
assert(combobox->row == row);
// combobox->setEditText(item->text()); // add object to the combobox
// combobox->display();
#if 0
combobox->setEditText(item->text()); // add object to the combobox
combobox->display();
#else
if (object_index[row] != -1 ) // object exist
combobox->setEditText(item->text()); // put range from table
combobox->display(); // display combobox
#endif
}
current_object = row;
updateObjectSettings(row); // Update object properties on the form
// -
// --- process click event on [Color cell]
// -
if (column == RT_COLOR) {
form.range_table->setCurrentCell(row,column-1);
// update color
QTableWidgetItem * twi = form.range_table->item(row,column);
assert(twi);
QColor color=QColorDialog::getColor(twi->background().color());
if (color.isValid() && pov && i_obj != -1) {
valid=true;
twi->setBackground(QBrush(color));
ParticlesObject * pobj = &(*pov)[i_obj];
pobj->setColor(color);
emit gazColorObjectChanged(i_obj);
}
}
if (column == RT_VISIB) {
}
current_object = row;
if (valid) {
if (i_obj < (int)pov->size()) {
//emit gazAlphaObjectChanged(i_obj);
}
emit objectSettingsChanged();
}
lock=true;
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
return 1;
}
// ============================================================================
// checkComboLine()
// parse the range entered in the combobox. Create a new object if valid
void FormObjectControl::checkComboLine(const int row, const int col)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
lock=false;
QTableWidgetItem * item = (form.range_table->item(row,col));
assert(item);
if (item) {
//construct regexp
QRegExp rx("^(\\d{1,})((:)(\\d{1,})){,1}((:)(\\d{1,})){,1}$");
int match=rx.indexIn(combobox->currentText());
if (match == -1) { // not match
}
else {
int first,last,step=1;
// get first
std::istringstream iss((rx.cap(1)).toStdString());
iss >> first;
// get last
if (rx.captureCount()>4) {
std::istringstream iss((rx.cap(4)).toStdString());
iss >> last;
// get step
if (rx.captureCount()>=7) {
std::istringstream iss((rx.cap(7)).toStdString());
iss >> step;
}
}
else {
last=first;
}
#if 0
std::cerr << "whole string =["<<(rx.cap(0)).toStdString()<<"\n";
for (int i=0;i<=rx.captureCount();i++) {
std::cerr << "cap ="<<(rx.cap(i)).toStdString()<<"\n";
}
std::cerr << "ncap="<<rx.captureCount()<<" first="<<first<<" last="<<last<<" step="<<step<<"\n";
#endif
// check if the syntax is correct
int npart=last-first+1; // #part
// if (current_data && npart <= *(current_data->nbody) && npart>0) { // valid object
if (pov && npart <= nbody && npart>0) { // valid object
item->setText(combobox->currentText()); // fill cell
int i_obj= object_index[row]; // object's index
if ( i_obj != -1) { // it's an existing object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
if (! pobj->hasIndexesList()) { // only range allowed
pobj->npart = npart;
pobj->first = first;
pobj->last = last;
pobj->step = step;
pobj->buildIndexList(); // build object index list
current_object = row;
// parse all the objects to check if physic is present
//checkPhysic(); // uncomment this to activate physic rendering (2/sep/2011)
updateObjectSettings(row);// update form !!! CAUSE OF CRASH
emit objectUpdate(); // update OpenGL
}
}
else { // it's a new object
ParticlesObject * po = new ParticlesObject(); // new object
po->buildIndexList( npart,first,last,step); // object's particles indexes
// get color
QTableWidgetItem * twi = form.range_table->item(row,RT_COLOR);
assert(twi);
// set color
po->setColor(twi->background().color());
// get visibility
QCheckBoxTable * checkbox = static_cast<QCheckBoxTable *>
(form.range_table->cellWidget(row,RT_VISIB));
assert(checkbox);
// set visibility
po->setVisible(checkbox->isChecked());
pov->push_back(*po); // insert object
delete po;
object_index[row] = pov->size()-1; // update object list
current_object = row; //
updateObjectSettings(row); // update form !!! CAUSE OF CRASH
emit objectUpdate(); // update OpenGL object
}
}
else { // invalid object
}
// check if the syntax is correct
}
}
else {
std::cerr << "WARNING [checkComboLine] no item !!!!\n";
}
lock=true;
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// on_coon_commit_button_clicked()
void FormObjectControl::on_range_table_cellPressed(int row,int column)
{
if (row && column) {;}
// std::cerr << "cell cellPressed : " << row << " X " << column << "\n";
}
// ============================================================================
// on_coon_commit_button_clicked()
void FormObjectControl::on_range_table_itemClicked(QTableWidgetItem * item)
{
if (item) {;}
// std::cerr << "item Clicked : ";
}
// ============================================================================
// updateVisib()
void FormObjectControl::updateVisib(const bool visib,const int row,const int table)
{
if (table) {;}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj= object_index[row]; // object's index
if (pov && i_obj != -1) {
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
pobj->setVisible(visib);
emit objectSettingsChanged();
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// updateRange()
void FormObjectControl::updateRange(const QString& text, const int row, const int table)
{
if (text=="") {;}
if (table) {;}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj= object_index[row]; // object's index
if (pov && i_obj != -1) {
assert(i_obj < (int)pov->size());
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// updateObjectSettings()
// update all the Object's FORM properties(slides, buttons etc..)
// from object's settings
void FormObjectControl::updateObjectSettings( const int row)
{
//if (go && ! go->duplicate_mem) mutex_data->lock();
my_mutex.lock();
EMIT = false;
int i_obj= object_index[row]; // object's index
if (pov && i_obj != -1) {
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
// Particles Settings
form.part_check->setChecked(pobj->isPartEnable());
form.part_slide_size->setValue((int) (pobj->getPartSize()*form.part_slide_size->maximum()/
GlobalOptions::MAX_PARTICLES_SIZE));
form.part_slide_alpha->setValue(pobj->getPartAlpha());
// Gaz Settings
form.gaz_check->setChecked(pobj->isGazEnable());
form.gaz_slide_size->setValue((int) (pobj->getGazSize()*form.gaz_slide_size->maximum()/
pobj->getGazSizeMax()));
form.gaz_slide_alpha->setValue(pobj->getGazAlpha());
form.texture_spin->setValue(pobj->getGazSizeMax());
form.gaz_rot_check->setChecked(pobj->isGazRotate());
if (GLWindow::GLSL_support)
form.gaz_glsl_check->setChecked(pobj->isGazGlsl());
form.texture_box->setCurrentIndex(pobj->getTextureIndex());
// Velocity Settings
form.vel_check->setChecked(pobj->isVelEnable());
int x=(float) pobj->getVelSize() * (float)
form.vel_slide_size->maximum()/pobj->getVelSizeMax();
form.vel_slide_size->setValue(x);
form.vel_slide_alpha->setValue(pobj->getVelAlpha());
form.vel_spin->setValue((pobj->getVelSizeMax()));
// -- Orbits TAB
form.odisplay_check->setChecked(pobj->isOrbitsEnable());
form.orecord_check->setChecked(pobj->isOrbitsRecording());
form.orbit_history_spin->setValue(pobj->getOrbitsHistory());
form.orbit_max_spin->setValue(pobj->getOrbitsMax());
// -- Physical quantity TAB
if (!pobj->hasPhysic() ) {
form.objects_properties->setTabEnabled(1,false); // disable physical tab
} else {
form.objects_properties->setTabEnabled(1,true); // enable physical tab
form.dens_phys_radio->setEnabled (current_data->rho!=NULL ?true:false);
form.temp_phys_radio->setEnabled (current_data->temp!=NULL ?true:false);
form.tempdens_phys_radio->setEnabled(current_data->temp!=NULL ?true:false);
form.pressure_phys_radio->setEnabled(current_data->pressure!=NULL?true:false);
form.velnorm_phys_radio->setEnabled(current_data->vel_norm!=NULL?true:false);
setPhysicalTabName();
}
if (pobj->hasPhysic() && phys_select && phys_select->isValid()) {
//std::cerr << "updateObjectSettings("<<row<<") getMax="<<log(phys_select->getMax())<< " getMin="<<
// log(phys_select->getMin())<<"\n";
dens_histo->drawDensity(phys_select->data_histo);
double diff_rho=(log(phys_select->getMax())-log(phys_select->getMin()))/100.;
//min
double minphys=pobj->getMinPhys(); // object's max phys value
double maxphys=pobj->getMaxPhys(); // object's min phys value
double gminphys=minphys,
gmaxphys=maxphys;
//std::cerr << "minphys ="<<minphys << " maxphys="<<maxphys<<"\n";
if (go->phys_min_glob !=-1 && go->phys_max_glob !=-1) {
// physical min/max values has been specified from the
// command line, or user has interactively modified min/max
gminphys = go->phys_min_glob;
gmaxphys = go->phys_max_glob;
}
// compute min/max value for the object according to
// the global value if it has been defined
//min
int min=rint((log(gminphys)-log(phys_select->getMin()))*1./diff_rho);
form.dens_slide_min->setValue(min);
//max
int max=rint((log(gmaxphys)-log(phys_select->getMin()))*1./diff_rho);
form.dens_slide_max->setValue(max);
//pobj->setMaxPercenPhys(std::max(1,max-1));
#if 1
setNewPhys(false);
go->gcb_min = form.dens_slide_min->value();
go->gcb_max = form.dens_slide_max->value();
#endif
dens_histo->drawDensity(form.dens_slide_min->value(),form.dens_slide_max->value());
dens_color_bar->draw(form.dens_slide_min->value(),form.dens_slide_max->value());
//pobj->setMinPhys(minphys);
//pobj->setMaxPhys(maxphys);
#if 0 // July 2012
go->phys_min_glob = minphys;
go->phys_max_glob = maxphys;
#else
// there is no physical values set on the CL
// then we set min/max glob from the first frame
if (go->phys_min_glob ==-1 && go->phys_max_glob ==-1) {
go->phys_min_glob = pobj->getMinPhys();
go->phys_max_glob = pobj->getMaxPhys();
}
#endif
}
}
if ( i_obj == -1 ) { // no object selected
// Particles Settings
form.part_check->setChecked(true);
form.part_slide_size->setValue(form.part_slide_size->maximum());
form.part_slide_alpha->setValue(254);
// Gaz Settings
form.gaz_check->setChecked(false);
form.gaz_slide_size->setValue(form.gaz_slide_size->maximum());
form.gaz_slide_alpha->setValue(254);
form.gaz_rot_check->setChecked(true);
form.texture_spin->setValue(1.0);
// Velocity Settings
form.vel_check->setChecked(false);
form.vel_slide_size->setValue(form.vel_slide_size->maximum());
form.vel_slide_alpha->setValue(254);
form.vel_spin->setValue(4);
// -- Orbits TAB
form.odisplay_check->setChecked(false);
form.orecord_check->setChecked(false);
form.orbit_history_spin->setValue(form.orbit_history_spin->maximum());
form.orbit_max_spin->setValue(form.orbit_max_spin->maximum());
}
EMIT = true;
//if (go && ! go->duplicate_mem) mutex_data->unlock();
my_mutex.unlock();
}
// ============================================================================
// checkPhysic()
void FormObjectControl::checkPhysic()
{
if (pov && pov->size()>0) {
for (int i=0; i<(int)pov->size();i++) {
ParticlesObject * pobj = &(*pov)[i];
pobj->setPhysic(false);
// check if physic exist and set it
for (int i=0; i < pobj->npart; i+=pobj->step) {
int index=pobj->index_tab[i];
if (phys_select && phys_select->isValid()) {
if (phys_select->data[index] != -1) pobj->setPhysic(true);
}
}
//
if (pobj->hasPhysic() && phys_select && phys_select->isValid()) {
if (go->phys_min_glob==-1 && go->phys_max_glob==-1) { // glob phys not defined
if (pobj->getMinPhys()==-1. && // default parameter -1 -1
pobj->getMaxPhys()==-1.) { // it's a NEW object, so we set min/max phys
pobj->setMinPhys(phys_select->getMin());
pobj->setMaxPhys(phys_select->getMax());
}
} else { // global phys defined
if (pobj->getMinPhys()==-1. && // default parameter for the object
pobj->getMaxPhys()==-1.) { //
pobj->setMinPhys(go->phys_min_glob);
pobj->setMaxPhys(go->phys_max_glob);
}
}
#if 0 // july 2012
//min
float minphys=pobj->getMinPhys();
float maxphys=pobj->getMaxPhys();
go->phys_min_glob = minphys;
go->phys_max_glob = maxphys;
#endif
}
}
}
}
// ============================================================================
// ON PARTICLES
// ============================================================================
// ============================================================================
// on_part_check_clicked()
void FormObjectControl::on_part_check_clicked(bool value)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1) { // at least one object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
pobj->setPart(value);
if (EMIT) emit objectSettingsChanged();
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// on_part_slide_size_valueChanged
void FormObjectControl::on_part_slide_size_valueChanged(int value)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1) { // at least one object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
pobj->setPartSize((float)value*GlobalOptions::MAX_PARTICLES_SIZE/
form.part_slide_size->maximum());
//std::cerr << "part value = " << value << "\n";
if (EMIT) emit objectSettingsChanged();
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// on_part_slide_alpha_valueChanged
void FormObjectControl::on_part_slide_alpha_valueChanged(int value)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1 ) { // at least one object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
pobj->setPartAlpha(value);
if (EMIT) emit objectSettingsChanged();
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// ON GAZ
// ============================================================================
// ============================================================================
// on_gaz_check_clicked()
void FormObjectControl::on_gaz_check_clicked(bool value)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1 ) { // at least one object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
//form.texture_spin->setValue(pobj->getGazSizeMax())
//form.gaz_slide_size->setValue(pobj->getGazSize());
pobj->setGaz(value);
if (EMIT) emit objectSettingsChanged();
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// on_gaz_slide_size_valueChanged
void FormObjectControl::on_gaz_slide_size_valueChanged(int value)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1 ) { // at least one object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
pobj->setGazSize(value*form.texture_spin->value()/
form.gaz_slide_size->maximum());
if (EMIT) {
//emit gazSizeObjectChanged(i_obj);
emit objectSettingsChanged();
}
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// on_gaz_slide_alpha_valueChanged
void FormObjectControl::on_gaz_slide_alpha_valueChanged(int value)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1) { // at least one object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
pobj->setGazAlpha(value);
if (EMIT) {
//emit gazAlphaObjectChanged(i_obj);
emit objectSettingsChanged();
}
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// on_gaz_rot_check_clicked()
void FormObjectControl::on_gaz_rot_check_clicked(bool value)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1 ) { // at least one object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
pobj->setGazRotate(value);
if (EMIT) emit objectSettingsChanged();
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// on_gaz_glsl_check_clicked()
void FormObjectControl::on_gaz_glsl_check_clicked(bool value)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1 ) { // at least one object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
//form.texture_spin->setValue(pobj->getGazSizeMax())
//form.gaz_slide_size->setValue(pobj->getGazSize());
pobj->setGazGlsl(value);
if (EMIT) emit objectSettingsChanged();
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// on_texture_spin_valueChanged
void FormObjectControl::on_texture_spin_valueChanged(double value)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1 ) { // at least one object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
//go->vel_vector_size = form.vel_slide_size->value();
pobj->setGazSizeMax(value);
pobj->setGazSize((float) form.gaz_slide_size->value()*(value/form.gaz_slide_size->maximum()));
if (EMIT) {
//emit gazSizeObjectChanged(i_obj);
emit objectSettingsChanged();
}
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// ON VEL
// ============================================================================
// ============================================================================
// on_vel_check_clicked()
void FormObjectControl::on_vel_check_clicked(bool value)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1) { // at least one object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
//pobj->setVelSize(((float) form.vel_spin->value()));
pobj->setVel(value);
if (EMIT) emit objectUpdateVel(i_obj);
if (EMIT) emit objectSettingsChanged();
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// on_vel_slide_size_valueChanged
void FormObjectControl::on_vel_slide_size_valueChanged(int value)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1) { // at least one object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
pobj->setVelSize((float) value*((float) form.vel_spin->value()/float(form.vel_slide_size->maximum())));
if (form.vel_check->isChecked()) {
if (EMIT) emit objectUpdateVel(i_obj);
if (EMIT) emit objectSettingsChanged();
}
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// on_vel_slide_alpha_valueChanged
void FormObjectControl::on_vel_slide_alpha_valueChanged(int value)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1) { // at least one object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
pobj->setVelAlpha(value);
if (form.vel_check->isChecked()) {
if (EMIT) emit objectSettingsChanged();
}
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// on_vel_spin_valueChanged
void FormObjectControl::on_vel_spin_valueChanged(double value)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1 ) { // at least one object
assert(i_obj < (int)pov->size());
ParticlesObject * pobj = &(*pov)[i_obj];
//go->vel_vector_size = form.vel_slide_size->value();
pobj->setVelSizeMax(value);
pobj->setVelSize((float) form.vel_slide_size->value()*((float) value/form.vel_slide_size->maximum()));
if (form.vel_check->isChecked()) {
if (EMIT) emit objectUpdateVel(i_obj);
if (EMIT) emit objectSettingsChanged();
}
}
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->unlock();
}
// ============================================================================
// ON TEXTURE BOX
// ============================================================================
// ============================================================================
// on_texture_box_activated
void FormObjectControl::on_texture_box_activated(int index)
{
//if (lock)
if (go && ! go->duplicate_mem) mutex_data->lock();
int i_obj = object_index[current_object];
if (pov && pov->size()>0 && i_obj != -1 ) { // at least one object
assert(i_obj < (int)pov->size());