-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntropyQueryContainer.cpp
More file actions
119 lines (87 loc) · 4.77 KB
/
EntropyQueryContainer.cpp
File metadata and controls
119 lines (87 loc) · 4.77 KB
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
#include <QLinearGradient>
#include "EntropyQueryContainer.h"
#include "Scene.h"
//Constructor
EntropyQueryContainer::EntropyQueryContainer(AppSettings * appSettings, Scene * scene, EntropySlider * entropySlider)
{
this->appSettings = appSettings;
this->scene = scene;
this->entropySlider = entropySlider;
appSettings->currentEntropyThreshold = appSettings->minEntropyThreshold;
arrowButton1 = new ArrowButton(false);
arrowButton2 = new ArrowButton(true);
//arrowButton1->resize(100, 100);
//arrowButton2->resize(100, 100);
//Sizing policies for the layout
QSizePolicy arrow1Policy(QSizePolicy::Preferred, QSizePolicy::Preferred);
arrow1Policy.setHorizontalStretch(5);
arrowButton1->setSizePolicy(arrow1Policy);
QSizePolicy arrow2Policy(QSizePolicy::Preferred, QSizePolicy::Preferred);
arrow2Policy.setHorizontalStretch(5);
arrowButton2->setSizePolicy(arrow2Policy);
//Build the layout
layout = new QVBoxLayout();
layout->addWidget(arrowButton1);
layout->addWidget(entropySlider);
layout->addWidget(arrowButton2);
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
this->setLayout(layout);
//Set up events
connect((QObject*)arrowButton1, SIGNAL(clicked()), this, SLOT(doQueryUp()));
connect((QObject*)arrowButton2, SIGNAL(clicked()), this, SLOT(doQueryDown()));
}
//This function increases the current entropy threshold query value then runs the query on the split tree structure
//It will first try to increase by the configured threshold but will continue increasing the value bit by bit until some sort of
//change in the tree structure is detected. This way a change always happens when the button is clicked.
void EntropyQueryContainer::doQueryUp()
{
this->appSettings->currentEntropyThreshold += appSettings->entropyThresholdIncrement;
if (appSettings->currentEntropyThreshold > appSettings->maxEntropyThreshold) {
appSettings->currentEntropyThreshold = appSettings->maxEntropyThreshold;
}
cout << "Current entropy threshold value: " << appSettings->currentEntropyThreshold << endl;
entropySlider->setRunEntropyQueries(false);
bool entropyQueryChanged = false;
do
{
entropyQueryChanged = scene->initiateEntropyQuery(appSettings->currentEntropyThreshold);
entropySlider->setValue((appSettings->currentEntropyThreshold - appSettings->minEntropyThreshold) / (appSettings->maxEntropyThreshold - appSettings->minEntropyThreshold) * 100);
if (!entropyQueryChanged) {
this->appSettings->currentEntropyThreshold += appSettings->entropyThresholdIncrement;
}
} while (!entropyQueryChanged && appSettings->currentEntropyThreshold <= appSettings->maxEntropyThreshold);
if (appSettings->currentEntropyThreshold > appSettings->maxEntropyThreshold) {
appSettings->currentEntropyThreshold = appSettings->maxEntropyThreshold;
scene->initiateEntropyQuery(appSettings->currentEntropyThreshold);
entropySlider->setValue((appSettings->currentEntropyThreshold - appSettings->minEntropyThreshold) / (appSettings->maxEntropyThreshold - appSettings->minEntropyThreshold) * 100);
}
entropySlider->setRunEntropyQueries(true);
}
//This function decreases the current entropy threshold query value then runs the query on the split tree structure
//It will first try to decrease by the configured threshold but will continue decreasing the value bit by bit until some sort of
//change in the tree structure is detected. This way a change always happens when the button is clicked.
void EntropyQueryContainer::doQueryDown()
{
this->appSettings->currentEntropyThreshold -= appSettings->entropyThresholdIncrement;
if (appSettings->currentEntropyThreshold < appSettings->minEntropyThreshold) {
appSettings->currentEntropyThreshold = appSettings->minEntropyThreshold;
}
cout << "Current entropy threshold value: " << appSettings->currentEntropyThreshold << endl;
entropySlider->setRunEntropyQueries(false);
bool entropyQueryChanged = false;
do
{
entropyQueryChanged = scene->initiateEntropyQuery(appSettings->currentEntropyThreshold);
entropySlider->setValue((appSettings->currentEntropyThreshold - appSettings->minEntropyThreshold) / (appSettings->maxEntropyThreshold - appSettings->minEntropyThreshold) * 100);
if (!entropyQueryChanged) {
this->appSettings->currentEntropyThreshold -= appSettings->entropyThresholdIncrement;
}
} while (!entropyQueryChanged && appSettings->currentEntropyThreshold >= appSettings->minEntropyThreshold);
if (appSettings->currentEntropyThreshold < appSettings->minEntropyThreshold) {
appSettings->currentEntropyThreshold = appSettings->minEntropyThreshold;
scene->initiateEntropyQuery(appSettings->currentEntropyThreshold);
entropySlider->setValue((appSettings->currentEntropyThreshold - appSettings->minEntropyThreshold) / (appSettings->maxEntropyThreshold - appSettings->minEntropyThreshold) * 100);
}
entropySlider->setRunEntropyQueries(true);
}