26 #include <QPushButton>
28 #include <MemoryX/gui-plugins/SceneEditor/ui_SaveSnapshotDialog.h>
46 gui::dialog::SaveSnapshotDialog::connectSlots()
49 ui->newSnapshotRadioButton, SIGNAL(toggled(
bool)),
this, SLOT(enableSaveNewSnapshot(
bool)));
50 connect(ui->replaceSnapshotRadioButton,
51 SIGNAL(toggled(
bool)),
53 SLOT(enableReplaceSnapshot(
bool)));
54 connect(ui->saveAllRadioButton, SIGNAL(toggled(
bool)),
this, SLOT(enableSaveAllObjects(
bool)));
55 connect(ui->saveGroupsRadioButton, SIGNAL(toggled(
bool)),
this, SLOT(enableSaveGroups(
bool)));
57 ui->snapshotNameLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(checkOkButtonStatus()));
59 ui->groupsListWidget, SIGNAL(itemSelectionChanged()),
this, SLOT(checkOkButtonStatus()));
63 gui::dialog::SaveSnapshotDialog::showEvent(QShowEvent*)
68 ui->existingSnapshotsComboBox->clear();
69 std::vector<std::string> allSnapshotsVector =
70 controller->getMemoryXController()->getAllSnapshots();
72 for (std::vector<std::string>::iterator it = allSnapshotsVector.begin();
73 it != allSnapshotsVector.end();
76 ui->existingSnapshotsComboBox->insertItem(ui->existingSnapshotsComboBox->count(),
77 QString::fromStdString(*it));
81 ui->groupsListWidget->clear();
82 std::vector<scene3D::SceneGroupPtr> allGroupsVector =
83 controller->getScene()->getGroupManager()->getAllGroups();
85 for (std::vector<scene3D::SceneGroupPtr>::iterator it = allGroupsVector.begin();
86 it != allGroupsVector.end();
89 ui->groupsListWidget->insertItem(ui->groupsListWidget->count(),
90 QString::fromStdString((*it)->getGroupId()));
93 checkOkButtonStatus();
98 gui::dialog::SaveSnapshotDialog::accept()
102 QString snapshotName = newSnapshot ? ui->snapshotNameLineEdit->text()
103 : ui->existingSnapshotsComboBox->currentText();
104 std::string snapshotNameStr = snapshotName.toStdString();
108 controller->saveSnapshotAsJSON(snapshotNameStr);
109 controller->getMemoryXController()->saveSceneInSnapshot(snapshotNameStr);
114 std::vector<std::string> allObjects;
115 QList<QListWidgetItem*> allSelectedGroups = ui->groupsListWidget->selectedItems();
117 for (QList<QListWidgetItem*>::iterator it = allSelectedGroups.begin();
118 it != allSelectedGroups.end();
122 controller->getScene()->getGroupManager()->getGroupById(
123 (*it)->text().toStdString());
124 std::vector<scene3D::SceneObjectPtr> allObjectsInGroup =
125 selectedGroup->getAllObjects();
127 for (std::vector<scene3D::SceneObjectPtr>::iterator it = allObjectsInGroup.begin();
128 it != allObjectsInGroup.end();
131 allObjects.insert(allObjects.end(), (*it)->getObjectId());
135 controller->getMemoryXController()->saveObjectsInSnapshot(snapshotNameStr, allObjects);
144 gui::dialog::SaveSnapshotDialog::checkOkButtonStatus()
146 bool inputIsValid = (!ui->snapshotNameLineEdit->text().isEmpty() || !newSnapshot) &&
147 (ui->groupsListWidget->selectedItems().count() > 0 || allObjects);
148 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(inputIsValid);
152 gui::dialog::SaveSnapshotDialog::enableSaveNewSnapshot(
bool enabled)
156 ui->snapshotNameLineEdit->setEnabled(
enabled);
157 ui->existingSnapshotsComboBox->setDisabled(
enabled);
159 checkOkButtonStatus();
164 gui::dialog::SaveSnapshotDialog::enableReplaceSnapshot(
bool enabled)
168 ui->existingSnapshotsComboBox->setEnabled(
enabled);
169 ui->snapshotNameLineEdit->setDisabled(
enabled);
171 checkOkButtonStatus();
176 gui::dialog::SaveSnapshotDialog::enableSaveAllObjects(
bool enabled)
180 ui->groupsListWidget->setDisabled(
enabled);
182 checkOkButtonStatus();
187 gui::dialog::SaveSnapshotDialog::enableSaveGroups(
bool enabled)
191 ui->groupsListWidget->setEnabled(
enabled);
193 checkOkButtonStatus();
200 this->ui->retranslateUi(
this);