File: contourSurfaceDialog.C

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 239,888 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; makefile: 95
file content (102 lines) | stat: -rw-r--r-- 2,383 bytes parent folder | download | duplicates (4)
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
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

#include <BALL/VIEW/DIALOGS/contourSurfaceDialog.h>
#include <BALL/VIEW/WIDGETS/datasetControl.h>
#include <BALL/VIEW/DATATYPE/standardDatasets.h>
#include <BALL/VIEW/KERNEL/common.h>

#include <QtWidgets/QLineEdit>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QLayout>

namespace BALL
{
 namespace VIEW
 {

ContourSurfaceDialog::ContourSurfaceDialog( QWidget* parent,  const char* name )
 : QDialog(parent), 
 	 Ui_ContourSurfaceDialogData()
{
	setupUi(this);

	// signals and slots connections
	connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
	connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
	connect( threshold, SIGNAL( textChanged(const QString&) ), this, SLOT( valuesChanged() ) );
	connect( grids, SIGNAL( activated(int) ), this, SLOT( valuesChanged() ) );
	connect( color_button, SIGNAL( clicked() ), this, SLOT( chooseColor() ) );

	setObjectName(name);
}

ContourSurfaceDialog::~ContourSurfaceDialog()
{
}

double ContourSurfaceDialog::getThreshold() const	
{
	if (threshold->text().isEmpty()) return std::numeric_limits<double>::max();
	try
	{
		return (double)ascii(threshold->text()).toFloat();
	}
	catch(...)
	{
		return std::numeric_limits<double>::max();
	}
}

void ContourSurfaceDialog::setGrid(Dataset* grid)
{
	grid_ = grid;
}

Dataset* ContourSurfaceDialog::getGrid() 
{
	return grid_;
}

void ContourSurfaceDialog::valuesChanged()
{
	buttonOk->setEnabled((grids->currentIndex() != -1) && 
												!grids->currentText().isEmpty() &&
												(getThreshold() != std::numeric_limits<double>::max()));
}

int ContourSurfaceDialog::exec()
{
	grids->clear();
	vector<Dataset*> sets = controller_->getDatasets();
	vector<Dataset*>::iterator it = sets.begin();
	unsigned int index_selected_grid=0;
	for (unsigned int i=0; it != sets.end(); it++, i++)
	{
		grids->addItem((**it).getName().c_str());
		if(*it==grid_) index_selected_grid=i;
	}
	grids->setCurrentIndex(index_selected_grid);

	valuesChanged();
	if (!QDialog::exec()) return QDialog::Rejected;
	
	if (grids->currentIndex() == -1) grid_ = 0;
	else grid_ = sets[grids->currentIndex()];

	return QDialog::Accepted;
}

void ContourSurfaceDialog::chooseColor()
{
	VIEW::chooseColor(color_label);
}

ColorRGBA ContourSurfaceDialog::getColor()
{
	return VIEW::getColor(color_label);
}
		

}} //namespaces