Callback when one of the scene/vis parameters has changed */
| 5258 | /** Callback when one of the scene/vis parameters has changed |
| 5259 | */ |
| 5260 | void G4UIQt::VisParameterCallback(QWidget* widget) |
| 5261 | { |
| 5262 | if (widget == nullptr) { |
| 5263 | return; |
| 5264 | } |
| 5265 | |
| 5266 | // Look in all the Grid layout, but only column 1 (0 is the parameter name) |
| 5267 | auto grid = dynamic_cast<QGridLayout*>(widget->layout()); |
| 5268 | if (grid == nullptr) { |
| 5269 | return; |
| 5270 | } |
| 5271 | QString command; |
| 5272 | QWidget* name = grid->itemAtPosition(grid->rowCount() - 1, 0)->widget(); |
| 5273 | if (dynamic_cast<QLabel*>(name) == nullptr) { |
| 5274 | return; |
| 5275 | } |
| 5276 | command += (dynamic_cast<QLabel*>(name))->text() + " "; |
| 5277 | |
| 5278 | for (G4int a = 0; a < grid->rowCount() - 1; ++a) { |
| 5279 | QWidget* widgetTmp = grid->itemAtPosition(a, 1)->widget(); |
| 5280 | |
| 5281 | // 4 kind of widgets : QLineEdit / QComboBox / radioButtonsGroup / QPushButton (color chooser) |
| 5282 | if (widgetTmp != nullptr) { |
| 5283 | if (dynamic_cast<QLineEdit*>(widgetTmp) != nullptr) { |
| 5284 | command += (dynamic_cast<QLineEdit*>(widgetTmp))->text() + " "; |
| 5285 | } |
| 5286 | else if (dynamic_cast<QComboBox*>(widgetTmp) != nullptr) { |
| 5287 | command += (dynamic_cast<QComboBox*>(widgetTmp)) |
| 5288 | ->itemText((dynamic_cast<QComboBox*>(widgetTmp))->currentIndex()) + |
| 5289 | " "; |
| 5290 | |
| 5291 | // Color chooser |
| 5292 | } |
| 5293 | else if (dynamic_cast<QPushButton*>(widgetTmp) != nullptr) { |
| 5294 | command += widgetTmp->accessibleName() + " "; |
| 5295 | |
| 5296 | // Check for Button group |
| 5297 | } |
| 5298 | else if (dynamic_cast<QWidget*>(widgetTmp) != nullptr) { |
| 5299 | if (widgetTmp->layout()->count() > 0) { |
| 5300 | if (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget()) != nullptr) { |
| 5301 | QAbstractButton* checked = |
| 5302 | (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget())) |
| 5303 | ->group() |
| 5304 | ->checkedButton(); |
| 5305 | if (checked != nullptr) { |
| 5306 | command += (dynamic_cast<QRadioButton*>(widgetTmp->layout()->itemAt(0)->widget())) |
| 5307 | ->group() |
| 5308 | ->checkedButton() |
| 5309 | ->text() + |
| 5310 | " "; |
| 5311 | } |
| 5312 | } |
| 5313 | } |
| 5314 | } |
| 5315 | } |
| 5316 | } |
| 5317 | if (command != "") { |
no test coverage detected