Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CAMP
campvis-public
Commits
4ac8964c
Commit
4ac8964c
authored
Oct 12, 2014
by
Hossain Mahmud
Browse files
probably only except transferfunction
Conflicts: scripting/CMakeLists.txt
parent
a5c6a2e7
Changes
22
Hide whitespace changes
Inline
Side-by-side
scripting/CMakeLists.txt
View file @
4ac8964c
...
...
@@ -12,11 +12,15 @@ INCLUDE(${SWIG_USE_FILE})
FILE
(
GLOB CampvisScriptingSources
*.cpp
glue/*.cpp
luagen/*.cpp
luagen/properties/*.cpp
)
FILE
(
GLOB CampvisScriptingHeaders
*.h
glue/*.h
luagen/*.h
luagen/properties/*.h
)
IF
(
WIN32
)
...
...
@@ -123,4 +127,9 @@ ADD_LIBRARY(campvis-scripting ${CampvisSharedStaticModulesFix}
)
ADD_DEPENDENCIES
(
campvis-scripting
${
CampvisLuaModules
}
)
TARGET_LINK_LIBRARIES
(
campvis-scripting campvis-core campvis-modules cgt
${
CampvisGlobalExternalLibs
}
)
TARGET_LINK_LIBRARIES
(
campvis-scripting campvis-core campvis-modules tgt
${
CampvisGlobalExternalLibs
}
)
IF
(
CAMPVIS_GROUP_SOURCE_FILES
)
DEFINE_SOURCE_GROUPS_FROM_SUBDIR
(
CampvisScriptingSources
${
CampvisHome
}
""
)
DEFINE_SOURCE_GROUPS_FROM_SUBDIR
(
CampvisScriptingHeaders
${
CampvisHome
}
""
)
ENDIF
()
scripting/glue/regularluatable.cpp
View file @
4ac8964c
#include "regularluatable.h"
// Add property luas to ensure build
// TODO: find a better way
#include "scripting/luagen/properties/boolpropertylua.h"
#include "scripting/luagen/properties/buttonpropertylua.h"
#include "scripting/luagen/properties/floatpropertylua.h"
#include "scripting/luagen/properties/intpropertylua.h"
#include "scripting/luagen/properties/optionpropertylua.h"
#include "scripting/luagen/properties/stringpropertylua.h"
#include "scripting/luagen/properties/camerapropertylua.h"
#include "scripting/luagen/properties/colorpropertylua.h"
#include "scripting/luagen/properties/datanamepropertylua.h"
#include "scripting/luagen/properties/metapropertylua.h"
#include "scripting/luagen/properties/propertycollectionlua.h"
namespace
campvis
{
...
...
scripting/luagen/properties/abstractpropertylua.cpp
View file @
4ac8964c
...
...
@@ -30,7 +30,7 @@ namespace campvis {
:
_property
(
property
)
,
_dataContainer
(
dataContainer
)
{
_ignorePropertyUpdates
=
0
;
//
_ignorePropertyUpdates = 0;
}
AbstractPropertyLua
::~
AbstractPropertyLua
()
{
...
...
scripting/luagen/properties/abstractpropertylua.h
View file @
4ac8964c
...
...
@@ -63,7 +63,7 @@ namespace campvis {
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
;
//
tbb::atomic<int> _ignorePropertyUpdates;
};
}
...
...
scripting/luagen/properties/boolpropertylua.cpp
View file @
4ac8964c
...
...
@@ -36,9 +36,8 @@ namespace campvis {
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
());
ret
+=
"getProperty(
\"
"
+
_property
->
getName
()
+
"
\"
):setValue("
+
StringUtils
::
toString
(
static_cast
<
BoolProperty
*>
(
_property
)
->
getValue
()
)
+
")"
;
return
ret
;
}
}
\ No newline at end of file
scripting/luagen/properties/camerapropertylua.cpp
View file @
4ac8964c
...
...
@@ -22,45 +22,52 @@
//
// ================================================================================================
#include "cameraproperty
widget
.h"
#include "cameraproperty
lua
.h"
#include <QGridLayout>
#include <QLabel>
#include "core/tools/stringutils.h"
namespace
campvis
{
CameraPropertyWidget
::
CameraPropertyWidget
(
CameraProperty
*
property
,
DataContainer
*
dataContainer
,
QWidget
*
parent
/*= 0*/
)
:
AbstractPropertyWidget
(
property
,
true
,
dataContainer
,
parent
)
,
_lblCameraPosition
(
0
)
,
_lblLookDirection
(
0
)
,
_lblUpVector
(
0
)
CameraPropertyLua
::
CameraPropertyLua
(
CameraProperty
*
property
,
DataContainer
*
dataContainer
)
:
AbstractPropertyLua
(
property
,
true
,
dataContainer
)
{
_widget
=
new
QWidget
(
this
);
QGridLayout
*
gridLayout
=
new
QGridLayout
(
_widget
);
_widget
->
setLayout
(
gridLayout
);
_lblCameraPosition
=
new
QLabel
(
"Position: "
,
_widget
);
gridLayout
->
addWidget
(
_lblCameraPosition
,
0
,
0
);
_lblFocusPosition
=
new
QLabel
(
"Focus: "
,
_widget
);
gridLayout
->
addWidget
(
_lblFocusPosition
,
1
,
0
);
_lblLookDirection
=
new
QLabel
(
"Look Direction: "
,
_widget
);
gridLayout
->
addWidget
(
_lblLookDirection
,
2
,
0
);
_lblUpVector
=
new
QLabel
(
"Up Vector: "
,
_widget
);
gridLayout
->
addWidget
(
_lblUpVector
,
3
,
0
);
addWidget
(
_widget
);
updateWidgetFromProperty
();
}
CameraProperty
Widget
::~
CameraProperty
Widget
()
{
CameraProperty
Lua
::~
CameraProperty
Lua
()
{
}
void
CameraPropertyWidget
::
updateWidgetFromProperty
()
{
CameraProperty
*
prop
=
static_cast
<
CameraProperty
*>
(
_property
);
_lblCameraPosition
->
setText
(
"Position: "
+
QString
::
fromStdString
(
StringUtils
::
toString
(
prop
->
getValue
().
getPosition
())));
_lblFocusPosition
->
setText
(
"Focus: "
+
QString
::
fromStdString
(
StringUtils
::
toString
(
prop
->
getValue
().
getFocus
())));
_lblLookDirection
->
setText
(
"Look Direction: "
+
QString
::
fromStdString
(
StringUtils
::
toString
(
prop
->
getValue
().
getLook
())));
_lblUpVector
->
setText
(
"Up Vector: "
+
QString
::
fromStdString
(
StringUtils
::
toString
(
prop
->
getValue
().
getUpVector
())));
//void CameraPropertyLua::updateLuaFromProperty() {
// CameraProperty* prop = static_cast<CameraProperty*>(_property);
// _lblCameraPosition->setText("Position: " + QString::fromStdString(StringUtils::toString(prop->getValue().getPosition())));
// _lblFocusPosition->setText("Focus: " + QString::fromStdString(StringUtils::toString(prop->getValue().getFocus())));
// _lblLookDirection->setText("Look Direction: " + QString::fromStdString(StringUtils::toString(prop->getValue().getLook())));
// _lblUpVector->setText("Up Vector: " + QString::fromStdString(StringUtils::toString(prop->getValue().getUpVector())));
//}
std
::
string
CameraPropertyLua
::
getLuaScript
()
{
std
::
string
ret
=
""
;
tgt
::
Camera
cam
=
static_cast
<
CameraProperty
*>
(
_property
)
->
getValue
();
tgt
::
vec3
pos
=
cam
.
getPosition
();
tgt
::
vec3
focus
=
cam
.
getFocus
();
tgt
::
vec3
up
=
cam
.
getUpVector
();
float
fovy
=
cam
.
getFovy
();
float
ratio
=
cam
.
getRatio
();
float
distn
=
cam
.
getNearDist
();
float
distf
=
cam
.
getFarDist
();
int
pm
=
cam
.
getProjectionMode
();
ret
+=
"getProperty(
\"
"
+
_property
->
getName
()
+
"
\"
):setValue(tgt.Camera("
+
"tgt.vec3("
+
StringUtils
::
toString
(
pos
.
x
)
+
","
+
StringUtils
::
toString
(
pos
.
y
)
+
","
+
StringUtils
::
toString
(
pos
.
z
)
+
")"
+
","
+
"tgt.vec3("
+
StringUtils
::
toString
(
focus
.
x
)
+
","
+
StringUtils
::
toString
(
focus
.
y
)
+
","
+
StringUtils
::
toString
(
focus
.
z
)
+
")"
+
","
+
"tgt.vec3("
+
StringUtils
::
toString
(
up
.
x
)
+
","
+
StringUtils
::
toString
(
up
.
y
)
+
","
+
StringUtils
::
toString
(
up
.
z
)
+
")"
+
","
+
StringUtils
::
toString
(
fovy
)
+
","
+
StringUtils
::
toString
(
ratio
)
+
","
+
StringUtils
::
toString
(
distn
)
+
","
+
StringUtils
::
toString
(
distf
)
+
","
+
StringUtils
::
toString
(
pm
)
+
"))"
;
//ret = "-- If required need to implement lua interface for tgt:Camera";
return
ret
;
}
}
\ No newline at end of file
scripting/luagen/properties/camerapropertylua.h
View file @
4ac8964c
...
...
@@ -22,45 +22,38 @@
//
// ================================================================================================
#ifndef CAMERAPROPERTY
WIDGET
_H__
#define CAMERAPROPERTY
WIDGET
_H__
#ifndef CAMERAPROPERTY
LUA
_H__
#define CAMERAPROPERTY
LUA
_H__
#include "
application/gui/properties/
abstractproperty
widget
.h"
#include "
application/gui/properties/
property
widget
factory.h"
#include "abstractproperty
lua
.h"
#include "property
lua
factory.h"
#include "core/properties/cameraproperty.h"
class
QLabel
;
namespace
campvis
{
/**
*
Widget
for a Camera.
*
Lua
for a Camera.
* For now just offering read-access.
*/
class
CameraPropertyWidget
:
public
AbstractPropertyWidget
{
Q_OBJECT
;
class
CameraPropertyLua
:
public
AbstractPropertyLua
{
public:
/**
* Creates a new CameraProperty
Widget
for the property \a property.
* \param property The property the
widget
shall handle
* Creates a new CameraProperty
Lua
for the property \a property.
* \param property The property the
lua
shall handle
* \param dataContainer DataContainer to use (optional), defaults to nullptr.
* \param parent Parent Qt
widget
* \param parent Parent Qt
lua
*/
CameraProperty
Widget
(
CameraProperty
*
property
,
DataContainer
*
dataContainer
,
QWidget
*
parent
=
0
);
CameraProperty
Lua
(
CameraProperty
*
property
,
DataContainer
*
dataContainer
);
/**
* Destructor
*/
virtual
~
CameraProperty
Widget
();
virtual
~
CameraProperty
Lua
();
protected:
/**
* Gets called when the property has changed, so that widget can update its state.
*/
virtual
void
updateWidgetFromProperty
();
std
::
string
getLuaScript
();
private:
QWidget
*
_widget
;
QLabel
*
_lblCameraPosition
;
QLabel
*
_lblFocusPosition
;
QLabel
*
_lblLookDirection
;
...
...
@@ -69,8 +62,8 @@ namespace campvis {
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
template
class
Property
Widget
Registrar
<
CameraProperty
Widget
,
CameraProperty
>;
template
class
Property
Lua
Registrar
<
CameraProperty
Lua
,
CameraProperty
>;
}
#endif // CAMERAPROPERTY
WIDGET
_H__
#endif // CAMERAPROPERTY
LUA
_H__
scripting/luagen/properties/colorpropertylua.cpp
View file @
4ac8964c
...
...
@@ -22,46 +22,25 @@
//
// ================================================================================================
#include "colorproperty
widget
.h"
#include "colorproperty
lua
.h"
#include "core/properties/colorproperty.h"
#include "core/tools/stringutils.h"
namespace
campvis
{
ColorPropertyWidget
::
ColorPropertyWidget
(
ColorProperty
*
property
,
DataContainer
*
dataContainer
,
QWidget
*
parent
/*= 0*/
)
:
AbstractPropertyWidget
(
property
,
false
,
dataContainer
,
parent
)
//, _lblColorPicker(0)
,
_colorPicker
(
0
)
ColorPropertyLua
::
ColorPropertyLua
(
ColorProperty
*
property
,
DataContainer
*
dataContainer
)
:
AbstractPropertyLua
(
property
,
false
,
dataContainer
)
{
//_lblColorPicker = new QLabel("Change color: ", this);
_colorPicker
=
new
ColorPickerWidget
(
QtColorTools
::
toQColor
(
property
->
getValue
()),
this
);
addWidget
(
_colorPicker
);
//connect(_colorPicker, SIGNAL(valueChanged(tgt::vec4)), this, SLOT(onColorChanged(tgt::vec4)));
connect
(
_colorPicker
,
SIGNAL
(
colorChanged
(
const
QColor
&
)),
this
,
SLOT
(
onColorChanged
(
const
QColor
&
)));
}
ColorPropertyWidget
::~
ColorPropertyWidget
()
{
}
void
ColorPropertyWidget
::
updateWidgetFromProperty
()
{
_colorPicker
->
blockSignals
(
true
);
const
tgt
::
vec4
val
=
static_cast
<
ColorProperty
*>
(
_property
)
->
getValue
();
_colorPicker
->
setColor
(
QtColorTools
::
toQColor
(
tgt
::
vec4
(
val
.
x
*
255
,
val
.
y
*
255
,
val
.
z
*
255
,
val
.
w
*
255
)));
_colorPicker
->
blockSignals
(
false
);
}
void
ColorPropertyWidget
::
onColorChanged
(
const
QColor
&
value
)
{
++
_ignorePropertyUpdates
;
ColorProperty
*
prop
=
static_cast
<
ColorProperty
*>
(
_property
);
tgt
::
vec4
val
=
QtColorTools
::
toTgtColor
(
_colorPicker
->
color
());
prop
->
setValue
(
tgt
::
vec4
(
val
.
x
/
val
.
w
,
val
.
y
/
val
.
w
,
val
.
z
/
val
.
w
,
1
));
--
_ignorePropertyUpdates
;
ColorPropertyLua
::~
ColorPropertyLua
()
{
}
void
ColorPropertyWidget
::
onPropertyMinMaxChanged
(
const
AbstractProperty
*
property
)
{
if
(
_ignorePropertyUpdates
==
0
)
emit
s_propertyChanged
(
property
);
std
::
string
ColorPropertyLua
::
getLuaScript
()
{
tgt
::
vec4
value
=
static_cast
<
ColorProperty
*>
(
_property
)
->
getValue
();
std
::
string
ret
=
""
;
ret
+=
"getProperty(
\"
"
+
_property
->
getName
()
+
"
\"
):setValue(tgt.vec4("
+
StringUtils
::
toString
(
value
.
x
)
+
", "
+
StringUtils
::
toString
(
value
.
y
)
+
", "
+
StringUtils
::
toString
(
value
.
z
)
+
", "
+
StringUtils
::
toString
(
value
.
w
)
+
"))"
;
return
ret
;
}
}
scripting/luagen/properties/colorpropertylua.h
View file @
4ac8964c
...
...
@@ -22,63 +22,42 @@
//
// ================================================================================================
#ifndef COLORPROPERTY
WIDGET
_H__
#define COLORPROPERTY
WIDGET
_H__
#ifndef COLORPROPERTY
LUA
_H__
#define COLORPROPERTY
LUA
_H__
#include "application/gui/adjusterwidgets/doubleadjusterwidget.h"
#include "application/gui/properties/abstractpropertywidget.h"
#include "application/gui/properties/propertywidgetfactory.h"
#include "abstractpropertylua.h"
#include "propertyluafactory.h"
#include "core/properties/floatingpointproperty.h"
#include "core/properties/colorproperty.h"
#include "application/gui/qtcolortools.h"
namespace
campvis
{
/**
*
Widget
for a ColorProperty
*
Lua
for a ColorProperty
*/
class
ColorPropertyWidget
:
public
AbstractPropertyWidget
{
Q_OBJECT
class
ColorPropertyLua
:
public
AbstractPropertyLua
{
public:
/**
* Creates a new FloatProperty
Widget
for the property \a property.
* \param property The property the
widget
shall handle
* Creates a new FloatProperty
Lua
for the property \a property.
* \param property The property the
lua
shall handle
* \param dataContainer DataContainer to use (optional), defaults to nullptr.
* \param parent Parent Qt
widget
* \param parent Parent Qt
lua
*/
ColorProperty
Widget
(
ColorProperty
*
property
,
DataContainer
*
dataContainer
,
QWidget
*
parent
=
0
);
ColorProperty
Lua
(
ColorProperty
*
property
,
DataContainer
*
dataContainer
);
/**
* Destructor
*/
virtual
~
ColorPropertyWidget
();
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
onColorChanged
(
const
QColor
&
);
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
);
//QLabel *_lblColorPicker;
ColorPickerWidget
*
_colorPicker
;
///< color picker widget allowing to change color
virtual
~
ColorPropertyLua
();
std
::
string
getLuaScript
();
};
// ================================================================================================
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
template
class
Property
Widget
Registrar
<
ColorProperty
Widget
,
ColorProperty
>;
template
class
Property
Lua
Registrar
<
ColorProperty
Lua
,
ColorProperty
>;
}
#endif // COLORPROPERTY
WIDGET
_H__
#endif // COLORPROPERTY
LUA
_H__
scripting/luagen/properties/datanamepropertylua.cpp
View file @
4ac8964c
...
...
@@ -22,92 +22,23 @@
//
// ================================================================================================
#include "datanameproperty
widget
.h"
#include "datanameproperty
lua
.h"
#include "core/datastructures/datacontainer.h"
#include "core/properties/datanameproperty.h"
#include <QComboBox>
#include <QLineEdit>
#include "core/tools/stringutils.h"
namespace
campvis
{
DataNamePropertyWidget
::
DataNamePropertyWidget
(
DataNameProperty
*
property
,
DataContainer
*
dc
,
QWidget
*
parent
/*= 0*/
)
:
AbstractPropertyWidget
(
property
,
false
,
dc
,
parent
)
,
_lineEdit
(
0
)
,
_combobox
(
0
)
DataNamePropertyLua
::
DataNamePropertyLua
(
DataNameProperty
*
property
,
DataContainer
*
dc
)
:
AbstractPropertyLua
(
property
,
false
,
dc
)
{
if
(
property
->
getAccessInfo
()
==
DataNameProperty
::
READ
)
{
_combobox
=
new
QComboBox
(
this
);
_combobox
->
setEditable
(
true
);
if
(
dc
!=
0
)
{
std
::
vector
<
std
::
pair
<
std
::
string
,
DataHandle
>
>
tmp
=
dc
->
getDataHandlesCopy
();
QStringList
sl
;
for
(
size_t
i
=
0
;
i
<
tmp
.
size
();
++
i
)
sl
.
append
(
QString
::
fromStdString
(
tmp
[
i
].
first
));
_combobox
->
addItems
(
sl
);
dc
->
s_dataAdded
.
connect
(
this
,
&
DataNamePropertyWidget
::
onDataAdded
);
connect
(
this
,
SIGNAL
(
s_dataAddedQt
(
const
QString
&
,
QtDataHandle
)),
this
,
SLOT
(
onDataAddedQt
(
const
QString
&
,
QtDataHandle
)));
setCurrentComboBoxText
(
QString
::
fromStdString
(
property
->
getValue
()));
}
addWidget
(
_combobox
);
connect
(
_combobox
,
SIGNAL
(
editTextChanged
(
const
QString
&
)),
this
,
SLOT
(
onTextChanged
(
const
QString
&
)));
}
else
{
_lineEdit
=
new
QLineEdit
(
this
);
_lineEdit
->
setText
(
QString
::
fromStdString
(
property
->
getValue
()));
addWidget
(
_lineEdit
);
connect
(
_lineEdit
,
SIGNAL
(
textChanged
(
const
QString
&
)),
this
,
SLOT
(
onTextChanged
(
const
QString
&
)));
}
}
DataNamePropertyWidget
::~
DataNamePropertyWidget
()
{
if
(
_dataContainer
!=
0
&&
static_cast
<
DataNameProperty
*>
(
_property
)
->
getAccessInfo
()
==
DataNameProperty
::
READ
)
_dataContainer
->
s_dataAdded
.
disconnect
(
this
);
DataNamePropertyLua
::~
DataNamePropertyLua
()
{
}
void
DataNamePropertyWidget
::
updateWidgetFromProperty
()
{
DataNameProperty
*
prop
=
static_cast
<
DataNameProperty
*>
(
_property
);
QString
qs
=
QString
::
fromStdString
(
prop
->
getValue
());
if
(
prop
->
getAccessInfo
()
==
DataNameProperty
::
READ
)
{
_combobox
->
blockSignals
(
true
);
setCurrentComboBoxText
(
qs
);
_combobox
->
blockSignals
(
false
);
}
else
if
(
_lineEdit
->
text
()
!=
qs
)
{
_lineEdit
->
blockSignals
(
true
);
_lineEdit
->
setText
(
qs
);
_lineEdit
->
blockSignals
(
false
);
}
}
void
DataNamePropertyWidget
::
setCurrentComboBoxText
(
const
QString
&
text
)
{
int
idx
=
_combobox
->
findText
(
text
);
if
(
idx
!=
-
1
)
_combobox
->
setCurrentIndex
(
idx
);
else
_combobox
->
setEditText
(
text
);
std
::
string
DataNamePropertyLua
::
getLuaScript
()
{
const
std
::
string
value
=
static_cast
<
DataNameProperty
*>
(
_property
)
->
getValue
();
std
::
string
ret
=
""
;
ret
+=
"getProperty(
\"
"
+
_property
->
getName
()
+
"
\"
):setValue(
\"
"
+
value
+
"
\"
)"
;
return
ret
;
}
void
DataNamePropertyWidget
::
onTextChanged
(
const
QString
&
text
)
{
DataNameProperty
*
prop
=
static_cast
<
DataNameProperty
*>
(
_property
);
++
_ignorePropertyUpdates
;
prop
->
setValue
(
text
.
toStdString
());
--
_ignorePropertyUpdates
;
}
void
DataNamePropertyWidget
::
onDataAdded
(
std
::
string
key
,
DataHandle
dh
)
{
emit
s_dataAddedQt
(
QString
::
fromStdString
(
key
),
dh
);
}
void
DataNamePropertyWidget
::
onDataAddedQt
(
const
QString
&
key
,
QtDataHandle
dh
)
{
if
(
_combobox
->
findText
(
key
)
==
-
1
)
{
_combobox
->
addItem
(
key
);
}
}
}
scripting/luagen/properties/datanamepropertylua.h
View file @
4ac8964c
...
...
@@ -22,14 +22,12 @@
//
// ================================================================================================
#ifndef DATANAMEPROPERTY
WIDGET
_H__
#define DATANAMEPROPERTY
WIDGET
_H__
#ifndef DATANAMEPROPERTY
LUA
_H__
#define DATANAMEPROPERTY
LUA
_H__
#include "sigslot/sigslot.h"
#include "core/properties/datanameproperty.h"
#include "application/gui/qtdatahandle.h"
#include "application/gui/properties/abstractpropertywidget.h"
#include "application/gui/properties/propertywidgetfactory.h"
#include "abstractpropertylua.h"
#include "propertyluafactory.h"
class
QComboBox
;
class
QLineEdit
;
...
...
@@ -40,58 +38,28 @@ namespace campvis {
class
DataHandle
;
/**
*
Widget
for a DataNameProperty
*
Lua
for a DataNameProperty
*/
class
DataNamePropertyWidget
:
public
AbstractPropertyWidget
{
Q_OBJECT
class
DataNamePropertyLua
:
public
AbstractPropertyLua
{
public:
/**
* Creates a new Property
Widget
for the property \a property.
* \param property The property the
widget
shall handle
* Creates a new Property
Lua
for the property \a property.
* \param property The property the
lua
shall handle
* \param dc DataContainer this property uses to populate the combo box (may be 0).
* \param parent Parent Qt
widget
* \param parent Parent Qt
lua
*/
DataNameProperty
Widget
(
DataNameProperty
*
property
,
DataContainer
*
dc
,
QWidget
*
parent
=
0
);
DataNameProperty
Lua
(
DataNameProperty
*
property
,
DataContainer
*
dc
);
/**
* Destructor
*/
virtual
~
DataNamePropertyWidget
();
protected:
/**
* Gets called when the property has changed, so that widget can update its state.
*/
virtual
void
updateWidgetFromProperty
();
void
onDataAdded
(
std
::
string
key
,
DataHandle
dh
);
private
slots
:
void
onTextChanged
(
const
QString
&
text
);
void
onDataAddedQt
(
const
QString
&
key
,
QtDataHandle
dh
);
signals:
void
s_dataAddedQt
(
const
QString
&
key
,
QtDataHandle
dh
);
private:
/**
* Set the combo box's current text to the provided value.
*
* If \c text can already be found in the combo box, the corresponding item is made active. Otherwise, \c text
* is set as the contents of the combo box's text edit.
*
* \param text text to be set in the combo box
*/
void
setCurrentComboBoxText
(
const
QString
&
text
);
QLineEdit
*
_lineEdit
;
QComboBox
*
_combobox
;
virtual
~
DataNamePropertyLua
();
std
::
string
getLuaScript
();
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
template
class
Property
Widget
Registrar
<
DataNameProperty
Widget
,
DataNameProperty
,
10
>;
template
class
Property
Lua
Registrar
<
DataNameProperty
Lua
,
DataNameProperty
,
10
>;
}
#endif // DATANAMEPROPERTY
WIDGET
_H__
#endif // DATANAMEPROPERTY
LUA
_H__
scripting/luagen/properties/floatpropertylua.cpp
View file @
4ac8964c
...
...
@@ -37,9 +37,8 @@ namespace campvis {
std
::
string
FloatPropertyLua
::
getLuaScript
()
{
std
::
string
ret
=
""
;
ret
+=
"getProperty(
\"
"
+
_property
->
getName
()
+
"
\"
):setValue("
+
StringUtils
::
toString
(
static_cast
<
FloatProperty
*>
(
_property
)
->
getValue
()
)
+
")"
;
std
::
printf
(
ret
.
c_str
());
ret
+=
"getProperty(
\"
"
+
_property
->
getName
()
+
"
\"
):setValue("
+
StringUtils
::
toString
(
static_cast
<
FloatProperty
*>
(
_property
)
->
getValue
()
)
+
")"
;
return
ret
;
}
}
scripting/luagen/properties/floatpropertylua.h
View file @
4ac8964c
...
...
@@ -127,8 +127,6 @@ namespace campvis {
std
::
string
campvis
::
VecPropertyLua
<
SIZE
>::
getLuaScript
()
{
std
::
string
ret
=
"-- NOT IMPLEMENTED VecProperty"
;
//ret += "getProperty(" + _property->getName() + "):setValue(" + StringUtils::toString<bool>( static_cast<BoolProperty*>(_property)->getValue() ) + ")";
std
::
printf
(
ret
.
c_str
());
return
ret
;
}
// ================================================================================================
...
...
@@ -145,8 +143,6 @@ namespace campvis {
std
::
string
ret
=
""
;
ret
+=
"getProperty(
\"
"
+
_property
->
getName
()
+
"
\"
):setValue(tgt.vec2("
+
StringUtils
::
toString
(
value
.
x
)
+
", "
+
StringUtils
::
toString
(
value
.
y
)
+
"))"
;
std
::
printf
(
ret
.
c_str
());
return
ret
;
}
};
...
...
@@ -162,11 +158,9 @@ namespace campvis {