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
2388727d
Commit
2388727d
authored
Oct 24, 2014
by
Christian Schulte zu Berge
Browse files
Updated Lua bindings to new camera API.
refs #141
parent
3c921952
Changes
10
Hide whitespace changes
Inline
Side-by-side
core/bindings/campvis.i
View file @
2388727d
...
...
@@ -6,8 +6,6 @@
%
{
#
include
"core/datastructures/abstractdata.h"
#
include
"core/datastructures/imagedata.h"
#
include
"core/eventhandlers/trackballnavigationeventlistener.h"
#
include
"core/properties/cameraproperty.h"
#
include
"core/properties/genericproperty.h"
#
include
"core/properties/numericproperty.h"
#
include
"core/properties/floatingpointproperty.h"
...
...
@@ -137,16 +135,6 @@ namespace campvis {
%
template
(
FloatProperty
)
FloatingPointProperty
<
float
>
;
typedef
FloatingPointProperty
<
float
>
FloatProperty
;
/* CameraProperty */
%
template
(
GenericProperty_Camera
)
GenericProperty
<
cgt
::
Camera
>
;
class
CameraProperty
:
public
GenericProperty
<
cgt
::
Camera
>
{
public
:
CameraProperty
(
const
std
::
string&
name
,
const
std
::
string&
title
,
cgt
::
Camera
cam
=
cgt
::
Camera
())
;
virtual
~
CameraProperty
()
;
}
;
/* TFGeometry1D */
%
nodefaultctor
TFGeometry1D
;
...
...
@@ -269,12 +257,12 @@ namespace campvis {
/* Downcast the return value of HasPropertyCollection::getProperty to appropriate subclass */
%
factory
(
AbstractProperty
*
campvis
::
HasPropertyCollection
::
getProperty
,
campvis
::
FloatProperty
,
campvis
::
IVec2Property
,
campvis
::
TransferFunctionProperty
,
campvis
::
DataNameProperty
,
campvis
::
StringProperty
,
campvis
::
CameraProperty
)
;
campvis
::
DataNameProperty
,
campvis
::
StringProperty
)
;
/* Downcast the return value of HasPropertyCollection::getNestedProperty to appropriate subclass */
%
factory
(
AbstractProperty
*
campvis
::
HasPropertyCollection
::
getNestedProperty
,
campvis
::
FloatProperty
,
campvis
::
IVec2Property
,
campvis
::
TransferFunctionProperty
,
campvis
::
DataNameProperty
,
campvis
::
StringProperty
,
campvis
::
CameraProperty
)
;
campvis
::
DataNameProperty
,
campvis
::
StringProperty
)
;
/* HasPropertyCollection */
...
...
@@ -339,20 +327,6 @@ namespace campvis {
explicit
VisualizationProcessor
(
IVec2Property
*
viewportSizeProp
)
;
~
VisualizationProcessor
()
;
}
;
/* TrackballNavigationEventListener */
class
TrackballNavigationEventListener
:
public
cgt
::
EventListener
{
public
:
TrackballNavigationEventListener
(
CameraProperty
*
cameraProperty
,
IVec2Property
*
viewportSizeProp
)
;
virtual
~
TrackballNavigationEventListener
()
;
void
addLqModeProcessor
(
VisualizationProcessor
*
vp
)
;
void
removeLqModeProcessor
(
VisualizationProcessor
*
vp
)
;
void
reinitializeCamera
(
const
IHasWorldBounds
*
hwb
)
;
void
reinitializeCamera
(
const
cgt
::
Bounds&
worldBounds
)
;
}
;
}
...
...
core/datastructures/cameradata.h
View file @
2388727d
...
...
@@ -38,7 +38,7 @@ namespace campvis {
/**
* Data object storing camera data.
*/
class
CameraData
:
public
AbstractData
{
class
CAMPVIS_CORE_API
CameraData
:
public
AbstractData
{
public:
/**
* Constructor, creating a new CameraData object initialized by \a camera.
...
...
core/properties/numericproperty.h
View file @
2388727d
...
...
@@ -340,7 +340,7 @@ namespace campvis {
template
<
typename
T
>
void
campvis
::
NumericProperty
<
T
>::
unlock
()
{
if
(
NumericPropertyTraits
<
T
,
std
::
numeric_limits
<
T
>::
is_specialized
>::
isNan
(
_backBuffer
)
&&
NumericPropertyTraits
<
T
,
std
::
numeric_limits
<
T
>::
is_specialized
>::
isNan
(
_value
))
if
(
NumericPropertyTraits
<
T
,
std
::
numeric_limits
<
T
>::
is_specialized
>::
isNan
(
this
->
_backBuffer
)
&&
NumericPropertyTraits
<
T
,
std
::
numeric_limits
<
T
>::
is_specialized
>::
isNan
(
this
->
_value
))
AbstractProperty
::
unlock
();
else
GenericProperty
<
T
>::
unlock
();
...
...
ext/cgt/bindings/cgt.i
View file @
2388727d
...
...
@@ -2,6 +2,7 @@
%
include
"stdint.i"
%
{
#
include
"ext/cgt/camera.h"
#
include
"ext/cgt/navigation/navigation.h"
#
include
"ext/cgt/vector.h"
#
include
"ext/cgt/event/eventlistener.h"
%
}
...
...
@@ -92,4 +93,12 @@ namespace cgt {
virtual
~
Camera
()
;
}
;
class
IHasCamera
{
public
:
virtual
~
IHasCamera
()
;
virtual
Camera
*
getCamera
()
=
0
;
virtual
void
update
()
=
0
;
}
;
}
ext/cgt/shadermanager.cpp
View file @
2388727d
...
...
@@ -445,7 +445,8 @@ bool ShaderObject::rebuildFromFile() {
const
string
Shader
::
loggerCat_
(
"cgt.Shader.Shader"
);
Shader
::
Shader
()
:
isLinked_
(
false
)
:
id_
(
0
)
,
isLinked_
(
false
)
,
ignoreError_
(
false
)
{
id_
=
glCreateProgram
();
...
...
modules/base/bindings/base.i
View file @
2388727d
%
module
base
%
include
std_string
.
i
%
import
"ext/cgt/bindings/cgt.i"
%
import
"core/bindings/campvis.i"
%
{
#
include
"core/pipeline/autoevaluationpipeline.h"
#
include
"core/pipeline/visualizationprocessor.h"
#
include
"modules/base/processors/lightsourceprovider.h"
#
include
"modules/base/processors/trackballcameraprovider.h"
%
}
...
...
@@ -17,4 +19,24 @@ namespace campvis {
const
std
::
string
getName
()
const
;
}
;
class
TrackballCameraProvider
:
public
AbstractProcessor
,
public
cgt
::
EventListener
{
public
:
TrackballCameraProvider
(
IVec2Property
*
canvasSize
)
;
virtual
~
TrackballCameraProvider
()
;
const
std
::
string
getName
()
const
;
void
addLqModeProcessor
(
VisualizationProcessor
*
vp
)
;
void
removeLqModeProcessor
(
VisualizationProcessor
*
vp
)
;
void
reinitializeCamera
(
const
cgt
::
Bounds&
worldBounds
)
;
%
immutable
;
campvis
::
DataNameProperty
p_image
;
%
mutable
;
}
;
}
%
luacode
{
print
(
"Module campvis-base loaded"
)
}
modules/base/processors/trackballcameraprovider.h
View file @
2388727d
...
...
@@ -46,7 +46,7 @@ namespace campvis {
/**
* Generates CameraData objects.
*/
class
TrackballCameraProvider
:
public
CameraProvider
,
public
cgt
::
EventListener
,
public
cgt
::
IHasCamera
{
class
TrackballCameraProvider
:
public
CameraProvider
,
public
cgt
::
EventListener
,
public
cgt
::
IHasCamera
{
public:
/// Trackball automation mode
enum
AutomationMode
{
...
...
modules/io/bindings/cvio.i
View file @
2388727d
...
...
@@ -14,6 +14,11 @@ namespace campvis {
public
:
AbstractImageReader
()
;
~
AbstractImageReader
()
;
%
immutable
;
campvis
::
StringProperty
p_url
;
campvis
::
DataNameProperty
p_targetImageID
;
%
mutable
;
}
;
class
MhdImageReader
:
public
AbstractImageReader
{
...
...
@@ -22,10 +27,9 @@ namespace campvis {
~
MhdImageReader
()
;
const
std
::
string
getName
()
const
;
%
immutable
;
campvis
::
StringProperty
p_url
;
campvis
::
DataNameProperty
p_targetImageID
;
%
mutable
;
}
;
}
%
luacode
{
print
(
"Module campvis-io loaded"
)
}
modules/vis/bindings/vis.i
View file @
2388727d
...
...
@@ -10,6 +10,17 @@
namespace
campvis
{
/*
* As of version 2.0.12, SWIG still has trouble when a default argument is initialised using the
* `new` keyword. The `default` typemap provides a reasonable workaround.
*/
%
typemap
(
default
)
campvis
::
SliceRenderProcessor
*
slicerenderer
{
$
1
=
new
campvis
::
SliceExtractor
(
0
)
;
}
%
typemap
(
default
)
campvis
::
RaycastingProcessor
*
raycaster
{
$
1
=
new
campvis
::
SimpleRaycaster
(
0
)
;
}
class
VolumeExplorer
:
public
VisualizationProcessor
,
public
cgt
::
EventListener
{
public
:
VolumeExplorer
(
campvis
::
IVec2Property
*
viewportSizeProp
)
;
...
...
@@ -23,14 +34,6 @@ namespace campvis {
%
mutable
;
}
;
/*
* As of version 2.0.12, SWIG still has trouble when a default argument is initialised using the
* `new` keyword. The `default` typemap provides a reasonable workaround.
*/
%
typemap
(
default
)
campvis
::
RaycastingProcessor
*
raycaster
{
$
1
=
new
campvis
::
SimpleRaycaster
(
0
)
;
}
class
VolumeRenderer
:
public
VisualizationProcessor
{
public
:
VolumeRenderer
(
campvis
::
IVec2Property
*
viewportSizeProp
,
campvis
::
RaycastingProcessor
*
raycaster
)
;
...
...
@@ -39,9 +42,12 @@ namespace campvis {
const
std
::
string
getName
()
const
;
%
immutable
;
campvis
::
CameraProperty
p_camera
;
campvis
::
DataNameProperty
p_inputVolume
;
campvis
::
DataNameProperty
p_outputImage
;
%
mutable
;
}
;
}
%
luacode
{
print
(
"Module campvis-vis loaded"
)
}
modules/vis/pipelines/volumerendererdemo.lua
View file @
2388727d
...
...
@@ -7,38 +7,40 @@ require("preprocessing")
pipeline
=
campvis
.
newPipeline
(
"VolumeRendererDemoLua"
)
function
pipeline
:
ctor
()
self
.
camera
=
campvis
.
CameraProperty
(
"camera"
,
"Camera"
)
self
.
addProperty
(
instance
,
self
.
camera
)
local
canvas_size
=
self
.
getProperty
(
instance
,
"CanvasSize"
)
self
.
lsp
=
base
.
LightSourceProvider
()
self
.
addProcessor
(
instance
,
self
.
lsp
)
self
.
tcp
=
base
.
TrackballCameraProvider
(
canvas_size
)
self
.
addProcessor
(
instance
,
self
.
tcp
)
self
.
image_reader
=
cvio
.
MhdImageReader
()
self
.
addProcessor
(
instance
,
self
.
image_reader
)
local
canvas_size
=
self
.
getProperty
(
instance
,
"CanvasSize"
)
self
.
vr
=
vis
.
VolumeRenderer
(
canvas_size
)
self
.
addProcessor
(
instance
,
self
.
vr
)
self
.
trackballEH
=
campvis
.
TrackballNavigationEventListener
(
self
.
camera
,
canvas_size
)
self
.
t
rackballEH
:
addLqModeProcessor
(
self
.
vr
)
-- alternative 1 to automatically adjust the camera to the data
self
.
t
cp
:
addLqModeProcessor
(
self
.
vr
)
self
.
addEventListenerToBack
(
instance
,
self
.
t
rackballEH
)
self
.
addEventListenerToBack
(
instance
,
self
.
t
cp
)
end
function
pipeline
:
init
()
self
.
camera
:
addSharedProperty
(
self
.
vr
.
p_camera
)
self
.
vr
.
p_outputImage
:
setValue
(
"combine"
)
self
.
getProperty
(
instance
,
"renderTargetID"
):
setValue
(
"combine"
)
self
.
image_reader
.
p_url
:
setValue
(
campvis
.
SOURCE_DIR
..
"/modules/vis/sampledata/smallHeart.mhd"
)
self
.
image_reader
.
p_targetImageID
:
setValue
(
"reader.output"
)
self
.
image_reader
.
p_targetImageID
:
addSharedProperty
(
self
.
vr
.
p_inputVolume
)
self
.
image_reader
.
p_targetImageID
:
addSharedProperty
(
self
.
tcp
.
p_image
)
-- alternative 2 to automatically adjust the camera to the data
local
callback
=
function
(
arg
)
local
data_container
=
self
.
getDataContainer
(
instance
)
local
img_data
=
data_container
:
getData
(
self
.
image_reader
.
p_targetImageID
:
getValue
()):
getData
()
self
.
t
rackballEH
:
reinitializeCamera
(
img_data
)
self
.
t
cp
:
reinitializeCamera
(
img_data
:
getWorldBounds
()
)
end
self
.
image_reader
.
s_validated
:
connect
(
callback
)
...
...
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