Skip to content

Commit

Permalink
Remove reset button from transformer panel
Browse files Browse the repository at this point in the history
- superfluous for small amount of checkboxes
- Code-Style: reorder functions in transformer panel
  • Loading branch information
Martin-Idel-SI committed Sep 6, 2018
1 parent 45ca7a4 commit 3216dd5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 31 deletions.
27 changes: 6 additions & 21 deletions rviz_common/src/rviz_common/transformation_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,11 @@ properties::PropertyTreeWidget * TransformationPanel::initializeTreeWidget()
QHBoxLayout * TransformationPanel::initializeBottomButtonRow()
{
save_button_ = new QPushButton("Save");
reset_button_ = new QPushButton("Reset");

connect(save_button_, SIGNAL(clicked()), this, SLOT(onSaveClicked()));
connect(reset_button_, SIGNAL(clicked()), this, SLOT(onResetClicked()));

auto button_layout = new QHBoxLayout();
button_layout->addWidget(save_button_);
button_layout->addWidget(reset_button_);
return button_layout;
}

Expand Down Expand Up @@ -144,17 +141,6 @@ void TransformationPanel::onSaveClicked()
}
}

void TransformationPanel::onResetClicked()
{
auto transformer = transformation_manager_->getCurrentTransformerInfo();

auto package_property_entry = package_properties_.find(transformer.package);
if (package_property_entry != package_properties_.end()) {
package_property_entry->second->subProp(transformer.name)->setValue(true);
}
updateButtonState();
}

void TransformationPanel::onItemClicked(const QModelIndex & index)
{
auto property = dynamic_cast<properties::GroupedCheckboxProperty *>(tree_model_->getProp(index));
Expand All @@ -165,15 +151,14 @@ void TransformationPanel::onItemClicked(const QModelIndex & index)
}

void TransformationPanel::updateButtonState()
{
save_button_->setEnabled(checkedPropertyIsNotCurrentTransformer());
}

bool TransformationPanel::checkedPropertyIsNotCurrentTransformer()
{
auto checked_property = checkbox_property_group_->getChecked();
if (checked_property && isCurrentTransformerProperty(checked_property)) {
save_button_->setEnabled(false);
reset_button_->setEnabled(false);
} else {
save_button_->setEnabled(true);
reset_button_->setEnabled(true);
}
return !(checked_property && isCurrentTransformerProperty(checked_property));
}

bool TransformationPanel::isCurrentTransformerProperty(
Expand Down
19 changes: 9 additions & 10 deletions rviz_common/src/rviz_common/transformation_panel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,31 @@ class TransformationPanel : public Panel

private Q_SLOTS:
void onSaveClicked();
void onResetClicked();
void onItemClicked(const QModelIndex & index);

private:
void updateButtonState();
bool isCurrentTransformerProperty(properties::GroupedCheckboxProperty * property);
bool checkedPropertyIsNotCurrentTransformer();

properties::PropertyTreeWidget * initializeTreeWidget();
QHBoxLayout * initializeBottomButtonRow();
void createProperty(const PluginInfo & transformer_info);
properties::Property * getOrCreatePackageProperty(const QString & package);

properties::Property * root_property_;
properties::PropertyTreeModel * tree_model_;
properties::PropertyTreeWidget * tree_widget_;
properties::PropertyTreeWidget * initializeTreeWidget();

QPushButton * save_button_;
QPushButton * reset_button_;
QHBoxLayout * initializeBottomButtonRow();

std::shared_ptr<properties::GroupedCheckboxPropertyGroup> checkbox_property_group_;

transformation::TransformationManager * transformation_manager_;

std::map<properties::Property *, PluginInfo> transformer_property_infos_;
void createProperty(const PluginInfo & transformer_info);

std::map<QString, properties::Property *> package_properties_;
properties::Property * getOrCreatePackageProperty(const QString & package);

void updateButtonState();

bool isCurrentTransformerProperty(properties::GroupedCheckboxProperty * property);
};

} // namespace rviz_common
Expand Down

0 comments on commit 3216dd5

Please sign in to comment.