Generated on Sat Feb 7 2015 02:01:18 for Gecode by doxygen 1.8.9.1
preferences.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Guido Tack <tack@gecode.org>
5  *
6  * Copyright:
7  * Guido Tack, 2007
8  *
9  * Last modified:
10  * $Date: 2013-01-23 06:40:54 +0100 (Wed, 23 Jan 2013) $ by $Author: tack $
11  * $Revision: 13229 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
39 
40 namespace Gecode { namespace Gist {
41 
43  : QDialog(parent) {
44  QSettings settings("gecode.org", "Gist");
45  hideFailed = settings.value("search/hideFailed", true).toBool();
46  zoom = settings.value("search/zoom", false).toBool();
47  copies = settings.value("search/copies", false).toBool();
48  refresh = settings.value("search/refresh", 500).toInt();
49  refreshPause = settings.value("search/refreshPause", 0).toInt();
51  settings.value("smoothScrollAndZoom", true).toBool();
52  moveDuringSearch = false;
53 
54  c_d = opt.c_d;
55  a_d = opt.a_d;
56 
57  hideCheck =
58  new QCheckBox(tr("Hide failed subtrees automatically"));
59  hideCheck->setChecked(hideFailed);
60  zoomCheck =
61  new QCheckBox(tr("Automatic zoom enabled on start-up"));
62  zoomCheck->setChecked(zoom);
63  smoothCheck =
64  new QCheckBox(tr("Smooth scrolling and zooming"));
65  smoothCheck->setChecked(smoothScrollAndZoom);
66 
67  QPushButton* defButton = new QPushButton(tr("Defaults"));
68  QPushButton* cancelButton = new QPushButton(tr("Cancel"));
69  QPushButton* okButton = new QPushButton(tr("Ok"));
70  okButton->setDefault(true);
71  QHBoxLayout* buttonLayout = new QHBoxLayout();
72  buttonLayout->addWidget(defButton);
73  buttonLayout->addWidget(cancelButton);
74  buttonLayout->addWidget(okButton);
75 
76  connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
77  connect(defButton, SIGNAL(clicked()), this, SLOT(defaults()));
78  connect(okButton, SIGNAL(clicked()), this, SLOT(writeBack()));
79 
80  QLabel* refreshLabel = new QLabel(tr("Display refresh rate:"));
81  refreshBox = new QSpinBox();
82  refreshBox->setRange(0, 1000000);
83  refreshBox->setValue(refresh);
84  refreshBox->setSingleStep(100);
85  QHBoxLayout* refreshLayout = new QHBoxLayout();
86  refreshLayout->addWidget(refreshLabel);
87  refreshLayout->addWidget(refreshBox);
88 
89  slowBox =
90  new QCheckBox(tr("Slow down search"));
91  slowBox->setChecked(refreshPause > 0);
92 
93  refreshBox->setEnabled(refreshPause == 0);
94 
95  connect(slowBox, SIGNAL(stateChanged(int)), this,
96  SLOT(toggleSlow(int)));
97 
99  new QCheckBox(tr("Move cursor during search"));
101 
102  QVBoxLayout* layout = new QVBoxLayout();
103  layout->addWidget(hideCheck);
104  layout->addWidget(zoomCheck);
105  layout->addWidget(smoothCheck);
106  layout->addLayout(refreshLayout);
107  layout->addWidget(slowBox);
108  layout->addWidget(moveDuringSearchBox);
109 
110  QTabWidget* tabs = new QTabWidget;
111  QWidget* page1 = new QWidget;
112  page1->setLayout(layout);
113  tabs->addTab(page1, "Drawing");
114 
115  QLabel* cdlabel = new QLabel(tr("Commit distance:"));
116  cdBox = new QSpinBox();
117  cdBox->setRange(0, 10000);
118  cdBox->setValue(c_d);
119  cdBox->setSingleStep(1);
120  QHBoxLayout* cdLayout = new QHBoxLayout();
121  cdLayout->addWidget(cdlabel);
122  cdLayout->addWidget(cdBox);
123  QLabel* adlabel = new QLabel(tr("Adaptive distance:"));
124  adBox = new QSpinBox();
125  adBox->setRange(0, 10000);
126  adBox->setValue(a_d);
127  adBox->setSingleStep(1);
128  QHBoxLayout* adLayout = new QHBoxLayout();
129  adLayout->addWidget(adlabel);
130  adLayout->addWidget(adBox);
131  copiesCheck =
132  new QCheckBox(tr("Show clones in the tree"));
133  copiesCheck->setChecked(copies);
134  layout = new QVBoxLayout();
135  layout->addLayout(cdLayout);
136  layout->addLayout(adLayout);
137  layout->addWidget(copiesCheck);
138  QWidget* page2 = new QWidget;
139  page2->setLayout(layout);
140  tabs->addTab(page2, "Search");
141 
142  QVBoxLayout* mainLayout = new QVBoxLayout();
143  mainLayout->addWidget(tabs);
144  mainLayout->addLayout(buttonLayout);
145  setLayout(mainLayout);
146 
147  setWindowTitle(tr("Preferences"));
148  }
149 
150  void
152  hideFailed = hideCheck->isChecked();
153  zoom = zoomCheck->isChecked();
154  refresh = refreshBox->value();
155  refreshPause = slowBox->isChecked() ? 200 : 0;
156  moveDuringSearch = moveDuringSearchBox->isChecked();
157  smoothScrollAndZoom = smoothCheck->isChecked();
158  copies = copiesCheck->isChecked();
159  c_d = cdBox->value();
160  a_d = adBox->value();
161  QSettings settings("gecode.org", "Gist");
162  settings.setValue("search/hideFailed", hideFailed);
163  settings.setValue("search/zoom", zoom);
164  settings.setValue("search/copies", copies);
165  settings.setValue("search/refresh", refresh);
166  settings.setValue("search/refreshPause", refreshPause);
167  settings.setValue("smoothScrollAndZoom", smoothScrollAndZoom);
168 
169  accept();
170  }
171 
172  void
174  hideFailed = true;
175  zoom = false;
176  refresh = 500;
177  refreshPause = 0;
178  smoothScrollAndZoom = true;
179  moveDuringSearch = false;
180  copies = false;
181  c_d = 8;
182  a_d = 2;
183  hideCheck->setChecked(hideFailed);
184  zoomCheck->setChecked(zoom);
185  refreshBox->setValue(refresh);
186  slowBox->setChecked(refreshPause > 0);
187  smoothCheck->setChecked(smoothScrollAndZoom);
188  copiesCheck->setChecked(copies);
190  }
191 
192  void
194  refreshBox->setEnabled(state != Qt::Checked);
195  }
196 
197 }}
198 
199 // STATISTICS: gist-any
unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance) ...
Definition: search.hh:213
bool zoom
Whether to automatically zoom during search.
Definition: preferences.hh:79
unsigned int c_d
Create a clone after every c_d commits (commit distance)
Definition: search.hh:211
bool hideFailed
Whether to automatically hide failed subtrees during search.
Definition: preferences.hh:77
Options opt
The options.
Definition: test.cpp:101
bool copies
Whether to show where copies are in the tree.
Definition: preferences.hh:81
void toggleSlow(int state)
Toggle slow down setting.
int c_d
The copying distance.
Definition: preferences.hh:92
void defaults(void)
Reset to defaults.
PreferencesDialog(const Options &opt, QWidget *parent=0)
Constructor.
Definition: preferences.cpp:42
bool smoothScrollAndZoom
Whether to use smooth scrolling and zooming.
Definition: preferences.hh:87
void writeBack(void)
Write settings.
int refresh
How often to refresh the display during search.
Definition: preferences.hh:83
int refreshPause
Milliseconds to wait after each refresh (to slow down search)
Definition: preferences.hh:85
Gecode toplevel namespace
Options for Gist
Definition: gist.hh:238
bool moveDuringSearch
Whether to move cursor during search.
Definition: preferences.hh:89
int a_d
The adaptive recomputation distance.
Definition: preferences.hh:94