Tue, 30 Jul 2013 07:16:48 +0300
Use repaint() instead of update() when redrawing the scene after a pick so that the new scene is repainted immediately.
395
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | // ============================================================================= |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | // CheckBoxGroup |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | // ============================================================================= |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | class CheckBoxGroup : public QGroupBox { |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | Q_OBJECT |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | public: |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | CheckBoxGroup (const char* label, Qt::Orientation orient = Qt::Horizontal, QWidget* parent = null); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | void addCheckBox (const char* label, int key, bool checked = false); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | vector<int> checkedValues () const; |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | QCheckBox* getCheckBox (int key); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | bool buttonChecked (int key); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | signals: |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | void selectionChanged (); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | private: |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | QBoxLayout* m_layout; |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | std::map<int, QCheckBox*> m_vals; |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | private slots: |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | void buttonChanged (); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | }; |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | CheckBoxGroup::CheckBoxGroup (const char* label, Qt::Orientation orient, QWidget* parent) : QGroupBox (parent) { |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | m_layout = new QBoxLayout (makeDirection (orient)); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | setTitle (label); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | setLayout (m_layout); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | } |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | void CheckBoxGroup::addCheckBox (const char* label, int key, bool checked) { |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | if (m_vals.find (key) != m_vals.end ()) |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | return; |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | QCheckBox* box = new QCheckBox (label); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | box->setChecked (checked); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | m_vals[key] = box; |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | m_layout->addWidget (box); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | connect (box, SIGNAL (stateChanged (int)), this, SLOT (buttonChanged ())); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | } |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | vector<int> CheckBoxGroup::checkedValues () const { |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | vector<int> vals; |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | for (const auto& kv : m_vals) |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | if (kv.second->isChecked ()) |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | vals << kv.first; |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | return vals; |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | } |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | QCheckBox* CheckBoxGroup::getCheckBox (int key) { |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | return m_vals[key]; |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | } |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | void CheckBoxGroup::buttonChanged () { |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | emit selectionChanged (); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | } |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | bool CheckBoxGroup::buttonChecked (int key) { |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | return m_vals[key]->isChecked (); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | } |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | CheckBoxGroup* makeAxesBox() { |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | CheckBoxGroup* cbg_axes = new CheckBoxGroup ("Axes", Qt::Horizontal); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | cbg_axes->addCheckBox ("X", X); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | cbg_axes->addCheckBox ("Y", Y); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | cbg_axes->addCheckBox ("Z", Z); |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | return cbg_axes; |
5210bcb1d7e0
Further restructure, removed GUI toolbar icon size slider (always 22x22 now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | } |