Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Merge requests
!500
Feature/arviz profiles
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Feature/arviz profiles
feature/arviz-profiles
into
master
Overview
0
Commits
5
Pipelines
1
Changes
1
Merged
Andre Meixner
requested to merge
feature/arviz-profiles
into
master
3 months ago
Overview
0
Commits
5
Pipelines
1
Changes
1
Expand
0
0
Merge request reports
Viewing commit
d297936d
Prev
Next
Show latest version
1 file
+
1
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
d297936d
minor
· d297936d
Fabian Reister
authored
3 months ago
source/RobotAPI/gui-plugins/ArViz/ArvizProfileManagerWidget.h
0 → 100644
+
175
−
0
Options
/*
* 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::gui-plugins::ArVizProfileManagerWidget
* @author Andre Meixner ( andre dot meixner at kit dot edu )
* @date 2024
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#pragma once
#include
<QWidget>
#include
<QDialog>
#include
<QComboBox>
#include
<QPushButton>
#include
<QLineEdit>
#include
<QSettings>
#include
<QString>
#include
<QCheckBox>
#include
<QRadioButton>
#include
<mutex>
#include
<qcheckbox.h>
#include
<unordered_set>
#include
<string>
#include
<utility>
#include
<RobotAPI/components/ArViz/Coin/Visualizer.h>
namespace
armarx
{
struct
pair_hash
{
template
<
typename
T1
,
typename
T2
>
std
::
size_t
operator
()(
const
std
::
pair
<
T1
,
T2
>&
p
)
const
{
auto
h1
=
std
::
hash
<
T1
>
{}(
p
.
first
);
auto
h2
=
std
::
hash
<
T2
>
{}(
p
.
second
);
return
h1
^
(
h2
<<
1
);
}
};
using
Layers
=
std
::
unordered_set
<
viz
::
CoinLayerID
,
pair_hash
>
;
struct
Profile
{
Layers
layers
;
bool
additive
=
false
;
};
class
ProfileDialog
:
public
QDialog
{
Q_OBJECT
public:
explicit
ProfileDialog
(
QWidget
*
parent
=
nullptr
,
const
QString
&
name
=
""
,
bool
additive
=
false
,
bool
addDialog
=
true
,
bool
isDefault
=
false
);
~
ProfileDialog
();
QString
getName
()
const
;
bool
isAdditive
()
const
;
bool
isDefaultProfile
()
const
;
signals:
void
deleteProfileSignal
();
private
slots
:
void
deleteProfile
();
private:
QLineEdit
*
nameInput
;
QRadioButton
*
additiveRadioButton
;
QRadioButton
*
substractiveRadioButton
;
QPushButton
*
deleteButton
;
QCheckBox
*
defaultCheckBox
;
};
class
ArvizProfileManagerWidget
:
public
QWidget
{
Q_OBJECT
public:
explicit
ArvizProfileManagerWidget
(
QWidget
*
parent
=
nullptr
);
inline
void
update
(
const
viz
::
CoinLayerID
&
layerID
,
bool
visible
)
{
std
::
scoped_lock
lock
(
mtx
);
if
(
currentProfile
.
additive
==
visible
)
{
currentProfile
.
layers
.
insert
(
layerID
);
}
else
if
(
currentProfile
.
layers
.
count
(
layerID
)
>
0
)
{
currentProfile
.
layers
.
erase
(
layerID
);
currentProfile
.
layers
.
erase
({
layerID
.
first
,
"*"
});
}
}
inline
void
update
(
const
std
::
string
&
componentName
,
bool
visible
)
{
update
({
componentName
,
"*"
},
visible
);
}
inline
bool
isHidden
(
const
viz
::
CoinLayerID
&
layerID
)
const
{
std
::
scoped_lock
lock
(
mtx
);
const
bool
result
=
currentProfile
.
layers
.
count
(
layerID
)
>
0
or
currentProfile
.
layers
.
count
({
layerID
.
first
,
"*"
})
>
0
;
if
(
currentProfile
.
additive
)
{
return
not
result
;
}
else
{
return
result
;
}
}
inline
bool
isHidden
(
const
std
::
string
&
componentName
)
const
{
std
::
scoped_lock
lock
(
mtx
);
return
currentProfile
.
additive
==
(
currentProfile
.
layers
.
count
({
componentName
,
"*"
})
==
0
);
}
signals
:
void
publishUpdate
();
void
fetchUpdate
();
public
slots
:
void
onProfileSelected
(
int
index
);
private
slots
:
void
saveCurrentProfile
();
void
deleteCurrentProfileSave
();
void
addProfile
();
void
editProfile
();
private
:
void
loadLayerNames
();
void
loadProfile
(
const
QString
&
name
);
bool
saveProfile
(
const
QString
&
name
,
const
Profile
&
profile
);
ProfileDialog
*
dialog
=
nullptr
;
QComboBox
*
layersComboBox
;
QPushButton
*
addButton
;
QPushButton
*
editButton
;
QPushButton
*
saveButton
;
QSettings
settings
;
mutable
std
::
mutex
mtx
;
Profile
currentProfile
;
static
const
QString
SETTINGS_DEFAULT_PROFILE_KEY
;
};
}
Loading