Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
CAMP
campvis-public
Commits
53765b39
Commit
53765b39
authored
Jun 30, 2014
by
CAMP C++ Builder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core API: StatusProperty and StatusPropertyWidget and required changes to AbstractPropertyWidget
parent
37ac01ea
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
283 additions
and
3 deletions
+283
-3
application/CMakeLists.txt
application/CMakeLists.txt
+1
-0
application/gui/properties/abstractpropertywidget.cpp
application/gui/properties/abstractpropertywidget.cpp
+2
-2
application/gui/properties/abstractpropertywidget.h
application/gui/properties/abstractpropertywidget.h
+1
-1
application/gui/properties/statuspropertywidget.cpp
application/gui/properties/statuspropertywidget.cpp
+73
-0
application/gui/properties/statuspropertywidget.h
application/gui/properties/statuspropertywidget.h
+71
-0
core/properties/allproperties.h
core/properties/allproperties.h
+1
-0
core/properties/statusproperty.cpp
core/properties/statusproperty.cpp
+39
-0
core/properties/statusproperty.h
core/properties/statusproperty.h
+95
-0
No files found.
application/CMakeLists.txt
View file @
53765b39
...
...
@@ -62,6 +62,7 @@ SET(CampvisApplicationToBeMocced
gui/properties/propertycollectionwidget.h
gui/properties/simpletransferfunctioneditor.h
gui/properties/stringpropertywidget.h
gui/properties/statuspropertywidget.h
gui/properties/transferfunctionpropertywidget.h
tools/qtexteditlog.h
tools/bufferinglog.h
...
...
application/gui/properties/abstractpropertywidget.cpp
View file @
53765b39
...
...
@@ -67,8 +67,8 @@ namespace campvis {
_property
->
s_changed
.
disconnect
(
this
);
}
void
AbstractPropertyWidget
::
addWidget
(
QWidget
*
widget
)
{
_layout
->
addWidget
(
widget
,
1
);
void
AbstractPropertyWidget
::
addWidget
(
QWidget
*
widget
,
int
stretch
)
{
_layout
->
addWidget
(
widget
,
stretch
);
}
void
AbstractPropertyWidget
::
onPropertyChanged
(
const
AbstractProperty
*
property
)
{
...
...
application/gui/properties/abstractpropertywidget.h
View file @
53765b39
...
...
@@ -63,7 +63,7 @@ namespace campvis {
/**
* Adds a widget to the local Qt layout.
*/
void
addWidget
(
QWidget
*
widget
);
void
addWidget
(
QWidget
*
widget
,
int
stretch
=
1
);
AbstractProperty
*
_property
;
///< The property this widget handles
DataContainer
*
_dataContainer
;
///< DataContainer to use (e.g. to populate GUI), may be 0!
...
...
application/gui/properties/statuspropertywidget.cpp
0 → 100644
View file @
53765b39
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "statuspropertywidget.h"
#include <QLabel>
namespace
campvis
{
const
char
*
StatusPropertyWidget
::
baseStyle
=
"text-align: center; padding: 1px; font-weight: bold;"
;
StatusPropertyWidget
::
StatusPropertyWidget
(
StatusProperty
*
property
,
DataContainer
*
dataContainer
/*= nullptr*/
,
QWidget
*
parent
/*= 0*/
)
:
AbstractPropertyWidget
(
property
,
false
,
dataContainer
,
parent
)
{
_statusLabel
=
new
QLabel
(
this
);
_statusLabel
->
setText
(
QString
::
fromStdString
(
property
->
getValue
().
string
));
_statusLabel
->
setStyleSheet
(
getStyleFromStatusType
(
property
->
getValue
().
status
));
_statusLabel
->
setMinimumWidth
(
100
);
_statusLabel
->
setMaximumWidth
(
100
);
_statusLabel
->
setAlignment
(
Qt
::
AlignCenter
);
addWidget
(
new
QWidget
(
this
),
1
);
//spacer item to force right-alignment
addWidget
(
_statusLabel
,
0
);
//_statusLabel->setStyleSheet();
}
StatusPropertyWidget
::~
StatusPropertyWidget
()
{
}
void
StatusPropertyWidget
::
updateWidgetFromProperty
()
{
StatusProperty
*
prop
=
static_cast
<
StatusProperty
*>
(
_property
);
QString
qs
=
QString
::
fromStdString
(
prop
->
getValue
().
string
);
_statusLabel
->
setText
(
qs
);
_statusLabel
->
setStyleSheet
(
getStyleFromStatusType
(
prop
->
getValue
().
status
));
}
QString
StatusPropertyWidget
::
getStyleFromStatusType
(
Status
::
StatusType
type
)
const
{
switch
(
type
)
{
case
Status
::
UNKNOWN
:
return
QString
(
"color: black; background-color: grey; border: 1px solid black;"
)
+
baseStyle
;
case
Status
::
OK
:
return
QString
(
"color: black; background-color: green; border: 1px solid darkgreen;"
)
+
baseStyle
;
case
Status
::
WARNING
:
return
QString
(
"color: black; background-color: orange; border: 1px solid darkorange;"
)
+
baseStyle
;
case
Status
::
CRITICAL
:
return
QString
(
"color: black; background-color: red; border: 1px solid darkred; text-align: center; padding: 2px;"
)
+
baseStyle
;
default:
return
QString
(
"color: black; background-color: white; border: 1px solid grey;"
)
+
baseStyle
;
}
};
}
\ No newline at end of file
application/gui/properties/statuspropertywidget.h
0 → 100644
View file @
53765b39
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef STATUSPROPERTYWIDGET_H__
#define STATUSPROPERTYWIDGET_H__
#include "application/gui/properties/abstractpropertywidget.h"
#include "application/gui/properties/propertywidgetfactory.h"
#include "core/properties/statusproperty.h"
namespace
campvis
{
/**
* Widget for a StringProperty
*/
class
StatusPropertyWidget
:
public
AbstractPropertyWidget
{
Q_OBJECT
;
public:
/**
* Creates a new PropertyWidget for the property \a property.
* \param property The property the widget shall handle
* \param dataContainer DataContainer to use (optional), defaults to nullptr.
* \param parent Parent Qt widget
*/
StatusPropertyWidget
(
StatusProperty
*
property
,
DataContainer
*
dataContainer
=
nullptr
,
QWidget
*
parent
=
0
);
/**
* Destructor
*/
virtual
~
StatusPropertyWidget
();
protected:
/**
* Gets called when the property has changed, so that widget can update its state.
*/
virtual
void
updateWidgetFromProperty
();
private:
static
const
char
*
baseStyle
;
QString
getStyleFromStatusType
(
Status
::
StatusType
type
)
const
;
QLabel
*
_statusLabel
;
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
template
class
PropertyWidgetRegistrar
<
StatusPropertyWidget
,
StatusProperty
>;
}
#endif // STATUSPROPERTYWIDGET_H__
core/properties/allproperties.h
View file @
53765b39
...
...
@@ -34,5 +34,6 @@
#include "core/properties/optionproperty.h"
#include "core/properties/stringproperty.h"
#include "core/properties/transferfunctionproperty.h"
#include "core/properties/statusproperty.h"
#endif // ALLPROPERTIES_H__
\ No newline at end of file
core/properties/statusproperty.cpp
0 → 100644
View file @
53765b39
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "statusproperty.h"
namespace
campvis
{
const
std
::
string
StatusProperty
::
loggerCat_
=
"CAMPVis.core.datastructures.StatusProperty"
;
StatusProperty
::
StatusProperty
(
const
std
::
string
&
name
,
const
std
::
string
&
title
,
const
Status
&
value
)
:
GenericProperty
<
Status
>
(
name
,
title
,
value
)
{
}
StatusProperty
::~
StatusProperty
()
{
}
}
core/properties/statusproperty.h
0 → 100644
View file @
53765b39
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef STATUSPROPERTY_H__
#define STATUSPROPERTY_H__
#include "core/properties/genericproperty.h"
#include <string>
#include <tuple>
namespace
campvis
{
// simple class to store status as a combination of string and type
struct
Status
{
public:
/// Enumeration of the possible status types
enum
StatusType
{
UNKNOWN
,
OK
,
WARNING
,
CRITICAL
};
Status
(
std
::
string
string_arg
,
StatusType
status_arg
)
:
string
(
string_arg
)
,
status
(
status_arg
)
{};
bool
operator
==
(
const
Status
&
rhs
)
{
return
status
==
rhs
.
status
&&
string
==
rhs
.
string
;
};
bool
operator
!=
(
const
Status
&
rhs
)
{
return
status
!=
rhs
.
status
||
string
!=
rhs
.
string
;
};
std
::
string
string
;
StatusType
status
;
};
class
CAMPVIS_CORE_API
StatusProperty
:
public
GenericProperty
<
Status
>
{
public:
/**
* Creates a new StatusProperty
* \param name Property name (unchangable!)
* \param title Property title (e.g. used for GUI)
* \param value Initial value
*/
StatusProperty
(
const
std
::
string
&
name
,
const
std
::
string
&
title
,
const
Status
&
value
=
Status
(
std
::
string
(
""
),
Status
::
UNKNOWN
));
/**
* Virtual Destructor
**/
virtual
~
StatusProperty
();
// convenience setter
void
setStatus
(
std
::
string
str
,
Status
::
StatusType
status
)
{
setValue
(
Status
(
str
,
status
));
};
protected:
static
const
std
::
string
loggerCat_
;
};
}
#endif // STATUSPROPERTY_H__
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment