The VgPoint object can be associated with a layer within the 3D view. When the associated layer is visible, so to will the VgPoint . The VgPoint is located at a specified geographical position and is represented as a textured square.
To use a VgPoint , one must first create it (using VgEngine::VgInstanceFactory::instantiate ) and then associate it with a layer (using setLayer).
- Note
- One should not have any references to VgPoint when the viewer instance is destroyed, otherwise it will crash if your reference is deallocated after the viewer.
...
VgApplication::VgIApplication* mVgApplication;
Vg3DModule::VgPointDescriptor lPointDesc;
...
VgEngine::VgRefPtr< Vg3DModule::VgPoint > lPoint = mVgApplication->editEngine()->editInstanceFactory()->instantiate(lPointDesc);
const VgEngine::VgLayerManager::LayerList& lLayers = mVgApplication->editEngine()->editLayerManager()->getLayers();
VgEngine::VgRefPtr< VgEngine::VgLayer > lLayer = lLayers.at(0);
lPoint->setLayer(lLayer);
lPoint->setVisible(false);
bool lIsVisible = lPoint->isVisible();
lPoint->setLayer(NULL);
lPoint = NULL;
Subclassing
It's possible to subclass VgPoint in order to add custom data. This is demonstrated by the following code snippet:
class MyPoint : public Vg3DModule::VgPoint
{
public:
MyPoint(VgEngine::VgRefPtr< Vg3DModule::VgPoint >& pPoint, const std::string& pName)
: mPoint(pPoint)
, mName(pName)
{}
virtual ~MyPoint()
{
mPoint = NULL;
}
virtual Vg3DModule::VgIGeometryType
getType ()
const
{
return mPoint->getType();
}
virtual const Vg3DModule::VgPointDescriptor& getDescriptor () const
{
return mPoint->getDescriptor();
}
VgEngine::VgRefPtr< Vg3DModule::VgPoint > getPoint () const
{
return mPoint;
}
const std::string& getName () const
{
return mName;
}
private:
VgEngine::VgRefPtr< Vg3DModule::VgPoint > mPoint;
const std::string mName;
};
Once the Point is created, it can be wrapped by MyPoint and associated with a layer.
...
VgApplication::VgIApplication* mVgApplication;
Vg3DModule::VgPointDescriptor lPointDesc;
...
VgEngine::VgRefPtr< Vg3DModule::VgPoint > lPoint = mApplication->editEngine()->editInstanceFactory()->instantiate(lPointDescr);
MyPoint* lMyPoint = new MyPoint(lPoint.get());
lMyPoint->getPoint()->setLayer(lLayerName);
- Version
- 2.0