<div dir="ltr"><div dir="ltr"><div dir="ltr"><font size="4">hi vtk guys:</font><div>   <font size="4"> I write a Point2DBubble view class in order to display attached world point at display coordinator, and the point will be seen whatever you operate the active camera in renderer. the codes is as following:</font></div><div><br></div><div>  // head file</div><div>   class VX_LOVELYBUBBLE_API Point2DBubble : public Bubble</div><div>{</div><div>    BUBBLE_DECL(Point2DBubble, Bubble)</div><div>public:</div><div>    void setAttachedPoint(const Point3& pt) { attachedpoint_ = pt; }</div><div>    const Point3& attachedPoint()const { return attachedpoint_; }</div><div>    Double_t radius() { return radius_; }</div><div>    Point2DBubble(const Point3& worldpt, Double_t radius);</div><div>    ~Point2DBubble();</div><div><br></div><div>private:</div><div>    bool onRenderEvent(vtkObject*, unsigned long, void*);</div><div>    void makeActors(RenderPane& pane);</div><div>    bool addToRenderPane(RenderPane& pane);</div><div>    void removeFromRenderPane(RenderPane& pane);</div><div>    Double_t radius_;</div><div>    Point3 attachedpoint_;</div><div>    std::map<vtkRenderer*, uInt32_t> rendererdict_;</div><div>};</div><div><br></div><div>//source file</div><div><div>#include "point2dbubble.h"</div><div>#include "vtkRenderer.h"</div><div>#include "vtkSphereSource.h"</div><div>#include "vtkPolyDataMapper2D.h"</div><div>#include "vtkCoordinate.h"</div><div>#include "vtkActor2D.h"</div><div>#include "vtkCommand.h"</div><div>#include "coordconv.h"</div><div>#include "renderpane.h"</div><div>VX_NAMESPACE_BEGIN</div><div><br></div><div>Point2DBubble::Point2DBubble(const Point3& worldpt, Double_t radius)</div><div>    :attachedpoint_(worldpt),</div><div>    radius_(radius)</div><div>{}</div><div><br></div><div>Point2DBubble::~Point2DBubble()</div><div>{}</div><div><br></div><div>bool Point2DBubble::addToRenderPane(RenderPane& pane)</div><div>{</div><div>    if(Bubble::addToRenderPane(pane)){</div><div>        vtkRenderer* ren = pane.getRenderer().GetPointer();</div><div>        rendererdict_[ren] = ren->AddObserver(vtkCommand::StartEvent, this, &Point2DBubble::onRenderEvent);</div><div>        return true;</div><div>    }</div><div>    return false;</div><div>}</div><div><br></div><div>void Point2DBubble::removeFromRenderPane(RenderPane& pane)</div><div>{</div><div>    Bubble::removeFromRenderPane(pane);</div><div>    vtkRenderer* ren = pane.getRenderer().GetPointer();</div><div>    auto it = rendererdict_.find(ren);</div><div>    if(it != rendererdict_.end()){</div><div>        ren->RemoveObserver(it->second);</div><div>        rendererdict_.erase(it);</div><div>    }</div><div>}</div><div><br></div><div>bool Point2DBubble::onRenderEvent(vtkObject* source, unsigned long eventid, void* data)</div><div>{</div><div>    vtkRenderer* ren = vtkRenderer::SafeDownCast(source);</div><div>    if(ren == nullptr)</div><div>        return false;    </div><div>    RenderPane* thepane = RenderPane::FindPane(ren);</div><div>    if(thepane == nullptr)</div><div>        return false;</div><div>    if(!checkConnective(*thepane))</div><div>        return false;</div><div>    Point3 displaypt = utils::WorldToDisplay(attachedpoint_, *ren);    </div><div>    vtkActor2DList actors = actor2d_collector_.getActors(thepane);</div><div>    actors[0]->SetDisplayPosition(displaypt[0], displaypt[1]);</div><div>    return true;</div><div>}</div><div><br></div><div>void Point2DBubble::makeActors(RenderPane& pane)</div><div>{</div><div>    vtkSmartPointer<vtkSphereSource> source = vtkSmartPointer<vtkSphereSource>::New();</div><div>    source->SetRadius(radius_);</div><div>    source->SetCenter(attachedpoint_);</div><div>    vtkSmartPointer<vtkCoordinate> coordinate = vtkSmartPointer<vtkCoordinate>::New();</div><div>    coordinate->SetCoordinateSystemToDisplay();    </div><div>    vtkSmartPointer<vtkPolyDataMapper2D> mapper2d = vtkSmartPointer<vtkPolyDataMapper2D>::New();</div><div>    mapper2d->SetTransformCoordinate(coordinate);</div><div>    mapper2d->SetInputConnection(source->GetOutputPort());</div><div>    vtkSmartPointer<vtkActor2D> actor2d = vtkSmartPointer<vtkActor2D>::New();</div><div>    actor2d->SetMapper(mapper2d);</div><div>    addPane2DActor(pane, newActor2DInfo(actor2d, "point2d"));</div><div>}</div></div><div>__________________________________________________________________________________________________________________________</div><div><br></div><div><font size="4">now the problem is : <font color="#ff0000">the Actor2D does not display at position calculated by WorldToDisplay, and it seems than the display point keep a certain display distance offset with right display point!</font></font></div><div><font size="4" color="#000000">develop environment: VS2015+VTK7.1.0+WIN10(64bit)</font></div><div><font size="4" color="#000000">I cannot solve this problem, please give me some advice! that's will be very appreciate for you! </font></div><div><font size="4" color="#000000"><br></font></div><div><br></div><div><font size="4" color="#000000"><br></font></div><div><font size="4" color="#000000"><br></font></div><div><br></div><div><br></div><div><br></div><div>   <br><div>        </div></div></div></div></div>