Skip to content
Snippets Groups Projects
Commit d050b669 authored by Adrian Knobloch's avatar Adrian Knobloch
Browse files

Add a configuration widget for the DebugDrawer

This allows to change the visibility of existing layers and the default
visibility of new layers.
parent 03eda61f
No related branches found
No related tags found
1 merge request!49Debug drawer configuration widget
......@@ -12,3 +12,5 @@ add_subdirectory(DMPController)
#add_subdirectory(DSControllers)
add_subdirectory(RobotStatechartHelpers)
add_subdirectory(DebugDrawerConfigWidget)
\ No newline at end of file
set(LIB_NAME DebugDrawerConfigWidget)
armarx_build_if(ArmarXGui_FOUND "ArmarXGui not available")
armarx_find_qt(QtCore QtGui QtDesigner)
armarx_component_set_name("${LIB_NAME}")
armarx_set_target("Library: ${LIB_NAME}")
set(LIBS
ArmarXCoreInterfaces
ArmarXCore
DebugDrawer
${QT_LIBRARIES}
)
set(SOURCES
./DebugDrawerConfigWidget.cpp
)
set(HEADERS
./DebugDrawerConfigWidget.h
)
set(GUI_MOC_HDRS
./DebugDrawerConfigWidget.h
)
set(GUI_UIS
./DebugDrawerConfigWidget.ui
)
if(ArmarXGui_FOUND)
armarx_gui_library("${LIB_NAME}" "${SOURCES}" "${GUI_MOC_HDRS}" "${GUI_UIS}" "" "${LIBS}")
# add unit tests
add_subdirectory(test)
endif()
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::ArmarXObjects::DebugDrawerConfigWidget
* @author Adrian Knobloch ( adrian dot knobloch at student dot kit dot edu )
* @date 2019
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#include "DebugDrawerConfigWidget.h"
namespace armarx
{
DebugDrawerConfigWidget::DebugDrawerConfigWidget(const DebugDrawerComponentPtr &debugDrawer, QWidget *parent)
: QWidget(parent),
debugDrawer(debugDrawer)
{
ui.setupUi(this);
refresh();
connect(ui.pushButtonRefresh, &QPushButton::released, this, &DebugDrawerConfigWidget::refresh);
connect(ui.listWidgetLayerVisibility, &QListWidget::itemChanged, this, &DebugDrawerConfigWidget::onListItemChanged);
connect(ui.checkBoxDefaultLayerVisibility, &QCheckBox::stateChanged, this, &DebugDrawerConfigWidget::onDefaultLayerVisibilityChanged);
}
void DebugDrawerConfigWidget::refresh()
{
ui.listWidgetLayerVisibility->clear();
for (const auto& layerInfo : debugDrawer->layerInformation())
{
QListWidgetItem* item = new QListWidgetItem(QString::fromStdString(layerInfo.layerName), ui.listWidgetLayerVisibility);
item->setCheckState(layerInfo.visible ? Qt::Checked : Qt::Unchecked);
ui.listWidgetLayerVisibility->addItem(item);
}
ui.checkBoxDefaultLayerVisibility->setCheckState(debugDrawer->getDefaultLayerVisibility() ? Qt::Checked : Qt::Unchecked);
}
void DebugDrawerConfigWidget::onListItemChanged(QListWidgetItem *item)
{
debugDrawer->enableLayerVisu(item->text().toStdString(), item->checkState());
}
void DebugDrawerConfigWidget::onDefaultLayerVisibilityChanged(int checkState)
{
debugDrawer->setDefaultLayerVisibility(checkState != Qt::Unchecked);
}
}
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::ArmarXObjects::DebugDrawerConfigWidget
* @author Adrian Knobloch ( adrian dot knobloch at student dot kit dot edu )
* @date 2019
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#pragma once
#include <RobotAPI/components/DebugDrawer/DebugDrawerComponent.h>
#include "ui_DebugDrawerConfigWidget.h"
#include <QWidget>
namespace armarx
{
/**
* @defgroup Library-DebugDrawerConfigWidget DebugDrawerConfigWidget
* @ingroup RobotAPI
* A description of the library DebugDrawerConfigWidget.
*
* @class DebugDrawerConfigWidget
* @ingroup Library-DebugDrawerConfigWidget
* @brief Brief description of class DebugDrawerConfigWidget.
*
* Detailed description of class DebugDrawerConfigWidget.
*/
class DebugDrawerConfigWidget : public QWidget
{
public:
DebugDrawerConfigWidget(const DebugDrawerComponentPtr& debugDrawer, QWidget* parent = nullptr);
public slots:
void refresh();
void onListItemChanged(QListWidgetItem* item);
void onDefaultLayerVisibilityChanged(int checkState);
protected:
DebugDrawerComponentPtr debugDrawer;
Ui::DebugDrawerConfigWidget ui;
};
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DebugDrawerConfigWidget</class>
<widget class="QWidget" name="DebugDrawerConfigWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>421</width>
<height>236</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="styleSheet">
<string notr="true">QGroupBox{border:2px solid gray;border-radius:5px;margin-top: 1ex;} QGroupBox::title{subcontrol-origin: margin;subcontrol-position:top center;padding:0 3px;}</string>
</property>
<property name="title">
<string>DebugDrawer configuration</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="3" column="0">
<widget class="QLabel" name="labelLayerVisibility">
<property name="text">
<string>Layer visibility</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelDefaultLayerVisibility">
<property name="text">
<string>Default layer visibility</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QListWidget" name="listWidgetLayerVisibility"/>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="checkBoxDefaultLayerVisibility">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButtonRefresh">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
# Libs required for the tests
SET(LIBS ${LIBS} ArmarXCore DebugDrawerConfigWidget)
armarx_add_test(DebugDrawerConfigWidgetTest DebugDrawerConfigWidgetTest.cpp "${LIBS}")
\ No newline at end of file
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::ArmarXObjects::DebugDrawerConfigWidget
* @author Adrian Knobloch ( adrian dot knobloch at student dot kit dot edu )
* @date 2019
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#define BOOST_TEST_MODULE RobotAPI::ArmarXLibraries::DebugDrawerConfigWidget
#define ARMARX_BOOST_TEST
#include <RobotAPI/Test.h>
#include "../DebugDrawerConfigWidget.h"
#include <iostream>
BOOST_AUTO_TEST_CASE(testExample)
{
BOOST_CHECK_EQUAL(true, true);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment