IvObjectDragger::IvObjectDragger(QtCoinViewerPtr viewer, ItemPtr pItem, float draggerScale, bool bAllowRotation) : IvDragger(viewer, pItem, draggerScale) { // create a root node for the dragger nodes _draggerRoot = new SoSeparator; ItemPtr selectedItem = GetSelectedItem(); selectedItem->GetIvRoot()->insertChild(_draggerRoot, 0); // create and size a transform box dragger and then add it to the scene graph _transformBox = new SoTransformBoxDragger; _transformBox->scaleFactor.setValue(_ab.extents.x * _scale, _ab.extents.y * _scale, _ab.extents.z * _scale); _transformBox->translation.setValue(_ab.pos.x, _ab.pos.y, _ab.pos.z); _toffset = selectedItem->GetTransform(); _draggerRoot->addChild(_transformBox); // disable the scaling part of the transform box _transformBox->setPart("scaler", NULL); // disable the rotation around the X and Z axes if (!bAllowRotation) { const char *rotators[2] = { "rotator1", "rotator3" }; for (int i = 0; i < 2; i++) _transformBox->setPart(rotators[i], NULL); } // get the material node that governs the color of the dragger and // note the dragger's normal color if (bAllowRotation) { SoRotateCylindricalDragger *rp = (SoRotateCylindricalDragger *)_transformBox->getPart("rotator1", false); SoSeparator *s = (SoSeparator *) rp->getPart("rotator", false); _draggerMaterial = (SoMaterial *) s->getChild(0); } else _draggerMaterial = new SoMaterial(); _normalColor = _draggerMaterial->diffuseColor[0]; // add a motion callback handler for the dragger _transformBox->addMotionCallback(_MotionHandler, this); UpdateDragger(); }