在OSGEarth中绘制线,首先考虑osgEarth::Annotation::FeatureNode
。
功能描述如下:
1. 鼠标两次点击的点之间连线,为黄色的实线;
2. 最近一次点击的点和鼠标move到的点之间连线,为红色的虚线。
代码如下:drawline.h
class DrawLine : public HandleAdapter
{
public:
DrawLine(GraphicsView* view);
~DrawLine();
protected:
// 只需要经纬度
virtual void slotPicked(osg::Vec3d pos);
virtual void slotMoveing(osg::Vec3d pos);
virtual void slotRightHandle();
private:
// 实线的style,Node
osgEarth::Symbology::Style m_lineStyle;
osgEarth::Features::Feature* m_pFeature;
osgEarth::Annotation::FeatureNode* m_pFeatureNode;
// 虚线的style,Node
osgEarth::Symbology::Style m_stippleLineStyle;
osgEarth::Features::Feature* m_pStippleFeature;
osgEarth::Annotation::FeatureNode* m_pStippleFeatureNode;
std::vector<osg::Vec3d> m_vecPoint;
};
功能实现如下:drawline.cpp
DrawLine::DrawLine(GraphicsView* view)
: HandleAdapter(view)
{
m_pFeature = NULL;
m_pFeatu