model.h
static SoDragPointDragger ** draggers = NULL;
...
class Model : public SoQtExaminerViewer
{
public:
Model
( QWidget *parent
= NULL,
const char *name
=NULL,
const SbBool embed
=TRUE);
~Model(void);
struct dragcb_data;
static void dragger_moved(void * data, SoDragger * dragger);
void setDefaultScene();
...
-----------
model.cpp
#include <model.h>
Model
::Model( QWidget *parent,
const char * name,
const SbBool embed
) : SoQtExaminerViewer( parent, name, embed, SoQtFullViewer::BUILD_ALL, SoQtViewer::BROWSER, TRUE)
{
...
struct Model::dragcb_data {
unsigned int idx;
};
void Model::dragger_moved(void * data, SoDragger * dragger)
{
SoDragPointDragger * dpd = (SoDragPointDragger *)dragger;
struct dragcb_data * cbdata = (struct dragcb_data *)data;
SbVec3f v = dpd->translation.getValue();
ctrlpts->point.set1Value(cbdata->idx, v[0], v[1], v[2]);
}
void Model::setDefaultScene(void) {
...
struct dragcb_data * data = new struct dragcb_data;
data->idx = i;
dpd->addMotionCallback(dragger_moved, data);
dpd->translation.setValue(pts[i]);
root->addChild(dpd);
...
}
model.h
static SoDragPointDragger ** draggers = NULL;
...
class Model : public SoQtExaminerViewer
{
public:
Model( QWidget *parent = NULL, const char *name=NULL, const SbBool embed=TRUE);
~Model(void);
struct dragcb_data;
static void dragger_moved(void * data, SoDragger * dragger);
void setDefaultScene();
...
-----------
model.cpp
#include <model.h>
Model::Model( QWidget *parent, const char * name, const SbBool embed)
: SoQtExaminerViewer( parent, name, embed, SoQtFullViewer::BUILD_ALL, SoQtViewer::BROWSER, TRUE)
{
...
struct Model::dragcb_data {
unsigned int idx;
};
void Model::dragger_moved(void * data, SoDragger * dragger)
{
SoDragPointDragger * dpd = (SoDragPointDragger *)dragger;
struct dragcb_data * cbdata = (struct dragcb_data *)data;
SbVec3f v = dpd->translation.getValue();
ctrlpts->point.set1Value(cbdata->idx, v[0], v[1], v[2]);
}
void Model::setDefaultScene(void) {
...
struct dragcb_data * data = new struct dragcb_data;
data->idx = i;
dpd->addMotionCallback(dragger_moved, data);
dpd->translation.setValue(pts[i]);
root->addChild(dpd);
...
}
To copy to clipboard, switch view to plain text mode
Bookmarks