Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
The container registry cleanup task is now completed and the registry can be used normally.
Open sidebar
CAMP
campvis-public
Commits
6a514c27
Commit
6a514c27
authored
Oct 11, 2014
by
Hossain Mahmud
Browse files
initial properties
parent
2393c045
Changes
18
Hide whitespace changes
Inline
Side-by-side
scripting/luagen/properties/abstractpropertylua.cpp
0 → 100644
View file @
6a514c27
// ================================================================================================
//
// 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
"abstractpropertylua.h"
#include
"core/properties/abstractproperty.h"
namespace
campvis
{
AbstractPropertyLua
::
AbstractPropertyLua
(
AbstractProperty
*
property
,
bool
displayBoxed
,
DataContainer
*
dataContainer
)
:
_property
(
property
)
,
_dataContainer
(
dataContainer
)
{
_ignorePropertyUpdates
=
0
;
}
AbstractPropertyLua
::~
AbstractPropertyLua
()
{
}
}
scripting/luagen/properties/abstractpropertylua.h
0 → 100644
View file @
6a514c27
// ================================================================================================
//
// 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 ABSTRACTPROPERTYLUA_H__
#define ABSTRACTPROPERTYLUA_H__
#include
"sigslot/sigslot.h"
#include
"tbb/atomic.h"
#include
<QBoxLayout>
#include
<QLabel>
namespace
campvis
{
class
AbstractProperty
;
class
DataContainer
;
/**
* Abstract base class for property widgets.
*/
class
AbstractPropertyLua
:
public
sigslot
::
has_slots
{
public:
/**
* Creates a new PropertyWidget for the property \a property.
*
* If displayBoxed is true, the widget is displayed vertically in a QGroupBox.
*
* \param property The property the widget shall handle.
* \param displayBoxed Should the widget be displayed in a group box?
* \param dataContainer DataContainer to use (optional), defaults to nullptr. However, some derived classed might need a valid pointer here!
* \param parent Parent Qt widget, defaults to nullptr.
*/
AbstractPropertyLua
(
AbstractProperty
*
property
,
bool
displayBoxed
=
false
,
DataContainer
*
dataContainer
=
nullptr
);
/**
* Destructor
*/
virtual
~
AbstractPropertyLua
();
public:
virtual
std
::
string
getLuaScript
()
=
0
;
protected:
AbstractProperty
*
_property
;
///< The property this widget handles
DataContainer
*
_dataContainer
;
///< DataContainer to use (e.g. to populate GUI), may be 0!
/// Semaphore acts as flag whether the widget shall ignore incoming signals from properties being updated.
tbb
::
atomic
<
int
>
_ignorePropertyUpdates
;
};
}
#endif // ABSTRACTPROPERTYLUA_H__
scripting/luagen/properties/boolpropertylua.cpp
0 → 100644
View file @
6a514c27
// ================================================================================================
//
// 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
"boolpropertylua.h"
#include
"core/tools/stringutils.h"
namespace
campvis
{
BoolPropertyLua
::
BoolPropertyLua
(
BoolProperty
*
property
,
DataContainer
*
dataContainer
)
:
AbstractPropertyLua
(
property
,
false
,
dataContainer
)
{
}
BoolPropertyLua
::~
BoolPropertyLua
()
{
}
std
::
string
BoolPropertyLua
::
getLuaScript
()
{
std
::
string
ret
=
""
;
ret
+=
"getProperty("
+
_property
->
getName
()
+
"):setValue("
+
StringUtils
::
toString
<
bool
>
(
static_cast
<
BoolProperty
*>
(
_property
)
->
getValue
()
)
+
")"
;
std
::
printf
(
ret
.
c_str
());
return
ret
;
}
}
\ No newline at end of file
scripting/luagen/properties/boolpropertylua.h
0 → 100644
View file @
6a514c27
// ================================================================================================
//
// 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 BOOLPROPERTYLUA_H__
#define BOOLPROPERTYLUA_H__
#include
"scripting/luagen/properties/abstractpropertylua.h"
#include
"scripting/luagen/properties/propertyluafactory.h"
#include
"core/properties/genericproperty.h"
namespace
campvis
{
/**
* Widget for a IntProperty
*/
class
BoolPropertyLua
:
public
AbstractPropertyLua
{
public:
/**
* Creates a new BoolPropertyLua for the property \a property.
* \param property The property the widget shall handle
* \param parent Parent Qt widget
*/
BoolPropertyLua
(
BoolProperty
*
property
,
DataContainer
*
dataContainer
=
nullptr
);
/**
* Destructor
*/
virtual
~
BoolPropertyLua
();
std
::
string
getLuaScript
();
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
template
class
PropertyLuaRegistrar
<
BoolPropertyLua
,
BoolProperty
>;
}
#endif // BOOLPROPERTYLUA_H__
scripting/luagen/properties/buttonpropertylua.cpp
0 → 100644
View file @
6a514c27
// ================================================================================================
//
// 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
"buttonpropertywidget.h"
#include
<QPushButton>
namespace
campvis
{
ButtonPropertyWidget
::
ButtonPropertyWidget
(
ButtonProperty
*
property
,
DataContainer
*
dataContainer
,
QWidget
*
parent
/*= 0*/
)
:
AbstractPropertyWidget
(
property
,
false
,
dataContainer
,
parent
)
,
_button
(
0
)
{
_button
=
new
QPushButton
(
QString
::
fromStdString
(
property
->
getTitle
()),
this
);
connect
(
_button
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
onButtonClicked
(
bool
)));
addWidget
(
_button
);
}
ButtonPropertyWidget
::~
ButtonPropertyWidget
()
{
}
void
ButtonPropertyWidget
::
updateWidgetFromProperty
()
{
}
void
ButtonPropertyWidget
::
onButtonClicked
(
bool
)
{
ButtonProperty
*
bp
=
static_cast
<
ButtonProperty
*>
(
_property
);
bp
->
click
();
}
}
\ No newline at end of file
scripting/luagen/properties/buttonpropertylua.h
0 → 100644
View file @
6a514c27
// ================================================================================================
//
// 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 BUTTONPROPERTYWIDGET_H__
#define BUTTONPROPERTYWIDGET_H__
#include
"application/gui/properties/abstractpropertywidget.h"
#include
"application/gui/properties/propertywidgetfactory.h"
#include
"core/properties/buttonproperty.h"
class
QPushButton
;
namespace
campvis
{
/**
* Widget for a Camera.
* For now just offering read-access.
*/
class
ButtonPropertyWidget
:
public
AbstractPropertyWidget
{
Q_OBJECT
;
public:
/**
* Creates a new ButtonPropertyWidget for the property \a property.
* \param property The property the widget shall handle
* \param parent Parent Qt widget
*/
ButtonPropertyWidget
(
ButtonProperty
*
property
,
DataContainer
*
dataContainer
=
nullptr
,
QWidget
*
parent
=
0
);
/**
* Destructor
*/
virtual
~
ButtonPropertyWidget
();
protected:
/**
* Gets called when the property has changed, so that widget can update its state.
*/
virtual
void
updateWidgetFromProperty
();
protected
slots
:
void
onButtonClicked
(
bool
);
private:
QPushButton
*
_button
;
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
template
class
PropertyWidgetRegistrar
<
ButtonPropertyWidget
,
ButtonProperty
>;
}
#endif // BUTTONPROPERTYWIDGET_H__
scripting/luagen/properties/floatpropertylua.cpp
0 → 100644
View file @
6a514c27
// ================================================================================================
//
// 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
"floatpropertywidget.h"
namespace
campvis
{
FloatPropertyWidget
::
FloatPropertyWidget
(
FloatProperty
*
property
,
DataContainer
*
dataContainer
,
QWidget
*
parent
/*= 0*/
)
:
AbstractPropertyWidget
(
property
,
false
,
dataContainer
,
parent
)
,
_adjuster
(
0
)
{
_adjuster
=
new
DoubleAdjusterWidget
();
_adjuster
->
setMinimum
(
property
->
getMinValue
());
_adjuster
->
setMaximum
(
property
->
getMaxValue
());
_adjuster
->
setDecimals
(
property
->
getDecimals
());
_adjuster
->
setSingleStep
(
property
->
getStepValue
());
_adjuster
->
setValue
(
property
->
getValue
());
addWidget
(
_adjuster
);
connect
(
_adjuster
,
SIGNAL
(
valueChanged
(
double
)),
this
,
SLOT
(
onAdjusterValueChanged
(
double
)));
property
->
s_minMaxChanged
.
connect
(
this
,
&
FloatPropertyWidget
::
onPropertyMinMaxChanged
);
property
->
s_stepChanged
.
connect
(
this
,
&
FloatPropertyWidget
::
onPropertyStepChanged
);
property
->
s_decimalsChanged
.
connect
(
this
,
&
FloatPropertyWidget
::
onPropertyDecimalsChanged
);
}
FloatPropertyWidget
::~
FloatPropertyWidget
()
{
FloatProperty
*
property
=
static_cast
<
FloatProperty
*>
(
_property
);
property
->
s_minMaxChanged
.
disconnect
(
this
);
property
->
s_stepChanged
.
disconnect
(
this
);
property
->
s_decimalsChanged
.
disconnect
(
this
);
}
void
FloatPropertyWidget
::
updateWidgetFromProperty
()
{
FloatProperty
*
prop
=
static_cast
<
FloatProperty
*>
(
_property
);
_adjuster
->
blockSignals
(
true
);
_adjuster
->
setValue
(
prop
->
getValue
());
_adjuster
->
setMinimum
(
prop
->
getMinValue
());
_adjuster
->
setMaximum
(
prop
->
getMaxValue
());
_adjuster
->
setSingleStep
(
prop
->
getStepValue
());
_adjuster
->
setDecimals
(
prop
->
getDecimals
());
_adjuster
->
blockSignals
(
false
);
}
void
FloatPropertyWidget
::
onAdjusterValueChanged
(
double
value
)
{
++
_ignorePropertyUpdates
;
FloatProperty
*
prop
=
static_cast
<
FloatProperty
*>
(
_property
);
prop
->
setValue
(
value
);
--
_ignorePropertyUpdates
;
}
void
FloatPropertyWidget
::
onPropertyMinMaxChanged
(
const
AbstractProperty
*
property
)
{
if
(
_ignorePropertyUpdates
==
0
)
emit
s_propertyChanged
(
property
);
}
void
FloatPropertyWidget
::
onPropertyStepChanged
(
const
AbstractProperty
*
property
)
{
if
(
_ignorePropertyUpdates
==
0
)
emit
s_propertyChanged
(
property
);
}
void
FloatPropertyWidget
::
onPropertyDecimalsChanged
(
const
AbstractProperty
*
property
)
{
if
(
_ignorePropertyUpdates
==
0
)
emit
s_propertyChanged
(
property
);
}
}
scripting/luagen/properties/floatpropertylua.h
0 → 100644
View file @
6a514c27
// ================================================================================================
//
// 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 FLOATPROPERTYWIDGET_H__
#define FLOATPROPERTYWIDGET_H__
#include
"application/gui/adjusterwidgets/doubleadjusterwidget.h"
#include
"application/gui/properties/abstractpropertywidget.h"
#include
"application/gui/properties/propertywidgetfactory.h"
#include
"core/properties/floatingpointproperty.h"
namespace
campvis
{
/**
* Widget for a FloatProperty
*/
class
FloatPropertyWidget
:
public
AbstractPropertyWidget
{
Q_OBJECT
public:
/**
* Creates a new FloatPropertyWidget 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
*/
FloatPropertyWidget
(
FloatProperty
*
property
,
DataContainer
*
dataContainer
,
QWidget
*
parent
=
0
);
/**
* Destructor
*/
virtual
~
FloatPropertyWidget
();
protected:
/**
* Gets called when the property has changed, so that widget can update its state.
*/
virtual
void
updateWidgetFromProperty
();
private
slots
:
/// Slot getting called when the adjuster's value changes
void
onAdjusterValueChanged
(
double
value
);
private:
/// Slot getting called when the property's min or max value has changed, so that the widget can be updated.
virtual
void
onPropertyMinMaxChanged
(
const
AbstractProperty
*
property
);
/// Slot getting called when the property's step value has changed, so that the widget can be updated.
virtual
void
onPropertyStepChanged
(
const
AbstractProperty
*
property
);
/**
* Slot getting called when the number of significant decimal places of the property has
* changed, so that the widget can be updated.
*/
virtual
void
onPropertyDecimalsChanged
(
const
AbstractProperty
*
property
);
DoubleAdjusterWidget
*
_adjuster
;
///< Widget allowing the user to change the property's value
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
template
class
PropertyWidgetRegistrar
<
FloatPropertyWidget
,
FloatProperty
>;
// ================================================================================================
namespace
{
template
<
size_t
SIZE
>
struct
VecPropertyWidgetTraits
{};
template
<
>
struct
VecPropertyWidgetTraits
<
2
>
{
typedef
Vec2Property
PropertyType
;
typedef
tgt
::
vec2
BaseType
;
};
template
<
>
struct
VecPropertyWidgetTraits
<
3
>
{
typedef
Vec3Property
PropertyType
;
typedef
tgt
::
vec3
BaseType
;
};
template
<
>
struct
VecPropertyWidgetTraits
<
4
>
{
typedef
Vec4Property
PropertyType
;
typedef
tgt
::
vec4
BaseType
;
};
}
// ================================================================================================
/**
* Generic base class for Vec property widgets.
* Unfortunately Q_OBJECT and templates do not fit together, so we an additional level of
* indirection helps as usual...
*/
template
<
size_t
SIZE
>
class
VecPropertyWidget
:
public
AbstractPropertyWidget
{
public:
enum
{
size
=
SIZE
};
typedef
typename
VecPropertyWidgetTraits
<
SIZE
>::
PropertyType
PropertyType
;
/**
* Creates a new VecPropertyWidget for the property \a property.
* \param property The property the widget shall handle
* \param parent Parent Qt widget
*/
VecPropertyWidget
(
PropertyType
*
property
,
DataContainer
*
dataContainer
=
nullptr
,
QWidget
*
parent
=
0
);
/**
* Destructor
*/
virtual
~
VecPropertyWidget
();
protected:
/**
* Gets called when the property has changed, so that widget can update its state.
*/
virtual
void
updateWidgetFromProperty
();
void
onValueChangedImpl
();
/// Slot getting called when the property's min or max value has changed, so that the widget can be updated.
virtual
void
onPropertyMinMaxChanged
(
const
AbstractProperty
*
property
);
/// Slot getting called when the property's step value has changed, so that the widget can be updated.
virtual
void
onPropertyStepChanged
(
const
AbstractProperty
*
property
);
/**
* Slot getting called when the number of significant decimal places of the property has
* changed, so that the widget can be updated.
*/
virtual
void
onPropertyDecimalsChanged
(
const
AbstractProperty
*
property
);
DoubleAdjusterWidget
*
_adjusters
[
size
];
};
// ================================================================================================
template
<
size_t
SIZE
>
campvis
::
VecPropertyWidget
<
SIZE
>::
VecPropertyWidget
(
PropertyType
*
property
,
DataContainer
*
dataContainer
,
QWidget
*
parent
/*= 0*/
)
:
AbstractPropertyWidget
(
property
,
true
,
dataContainer
,
parent
)
{
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
{
_adjusters
[
i
]
=
new
DoubleAdjusterWidget
();
_adjusters
[
i
]
->
setMinimum
(
property
->
getMinValue
()[
i
]);
_adjusters
[
i
]
->
setMaximum
(
property
->
getMaxValue
()[
i
]);
_adjusters
[
i
]
->
setDecimals
(
property
->
getDecimals
()[
i
]);
_adjusters
[
i
]
->
setSingleStep
(
property
->
getStepValue
()[
i
]);
_adjusters
[
i
]
->
setValue
(
property
->
getValue
()[
i
]);
addWidget
(
_adjusters
[
i
]);
}
property
->
s_minMaxChanged
.
connect
(
this
,
&
VecPropertyWidget
::
onPropertyMinMaxChanged
);
property
->
s_stepChanged
.
connect
(
this
,
&
VecPropertyWidget
::
onPropertyStepChanged
);