[vtkusers] Why cannot I build and run a subclass of vtkInteractorStyleTrackballActor in the debug mode?

Jesse Kinross-Smith Jesse.Kinross-Smith at bentley.com
Wed Mar 21 20:15:04 EDT 2018


Ooh.. one I can answer as I've done this!

I think you're missing the line:

vtkStandardNewMacro(InteractorStyle2);

in your CPP file.

This will create the overloaded New() for you.

Jesse
--
Jesse Kinross-Smith
Senior Software Engineer - BSW
Bentley Systems, Fremantle

-----Original Message-----
From: vtkusers [mailto:vtkusers-bounces at vtk.org] On Behalf Of pnt1614
Sent: Thursday, 22 March 2018 7:38 AM
To: vtkusers at vtk.org
Subject: [vtkusers] Why cannot I build and run a subclass of vtkInteractorStyleTrackballActor in the debug mode?

I use the following code (VTK and MFC) to drag a point to a new position.
After click a "picking" button, I use the middle mouse button to move pick and move a point. I can build and run the release mode, but I cannot build in the debug mode because of an error. Is there anyone experienced this problem? Please help me. Thank you.

The error messages are
"Error (active)      no instance of overloaded "InteractorStyle2::operator
new" matches the argument list

Error   C2660   'vtkObject::operator new': function does not take 3
arguments"


This my C++ code:
class InteractorStyle2 : public vtkInteractorStyleTrackballActor {
public:
  static InteractorStyle2* New();
  vtkTypeMacro(InteractorStyle2, vtkInteractorStyleTrackballActor);

  InteractorStyle2()
  {
    this->Move = false;
    this->PointPicker = vtkSmartPointer<vtkPointPicker>::New();

    // Setup ghost glyph
    vtkSmartPointer<vtkPoints> points =
        vtkSmartPointer<vtkPoints>::New();
    points->InsertNextPoint(0, 0, 0);
    this->MovePolyData = vtkSmartPointer<vtkPolyData>::New();
    this->MovePolyData->SetPoints(points);
    this->MoveGlyphFilter = vtkSmartPointer<vtkVertexGlyphFilter>::New();
    this->MoveGlyphFilter->SetInputData(this->MovePolyData);
    this->MoveGlyphFilter->Update();

    this->MoveMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
   
this->MoveMapper->SetInputConnection(this->MoveGlyphFilter->GetOutputPor
this->MoveMapper->t());

    this->MoveActor = vtkSmartPointer<vtkActor>::New();
    this->MoveActor->SetMapper(this->MoveMapper);
    this->MoveActor->VisibilityOff();
    this->MoveActor->GetProperty()->SetPointSize(10);
    this->MoveActor->GetProperty()->SetColor(1, 0, 0);
  }

  void OnMouseMove()
  {
    if (!this->Move)
        return;

    vtkInteractorStyleTrackballActor::OnMouseMove();
  }

  void OnMiddleButtonUp()
  {
    this->EndPan();

    this->Move = false;
    this->MoveActor->VisibilityOff(); // Turn off rendering a red point

    this->Data->GetPoints()->SetPoint(this->SelectedPoint,
this->MoveActor->GetPosition());
    this->Data->Modified();
    this->GetCurrentRenderer()->Render();
    this->GetCurrentRenderer()->GetRenderWindow()->Render();

  }
  void OnMiddleButtonDown()
  {
    // Get the selected point
    int x = this->Interactor->GetEventPosition()[0];
    int y = this->Interactor->GetEventPosition()[1];
    this->FindPokedRenderer(x, y);

    this->PointPicker->Pick(this->Interactor->GetEventPosition()[0],
        this->Interactor->GetEventPosition()[1],
        0,  // always zero.
       
this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer())
this->Interactor->;

    if (this->PointPicker->GetPointId() >= 0)
    {
        this->StartPan();
        this->MoveActor->VisibilityOn(); // turn on rendering a red point
        this->Move = true;
        this->SelectedPoint = this->PointPicker->GetPointId();

        std::cout << "Dragging point " << this->SelectedPoint << std::endl;

        double p[3];
        this->Data->GetPoint(this->SelectedPoint, p);
        std::cout << "p: " << p[0] << " " << p[1] << " " << p[2] << std::endl;
        this->MoveActor->SetPosition(p);

        this->GetCurrentRenderer()->AddActor(this->MoveActor);
        this->InteractionProp = this->MoveActor;
    }
  }

  vtkPolyData* Data;
  vtkPolyData* GlyphData;

  vtkSmartPointer<vtkPolyDataMapper> MoveMapper;
  vtkSmartPointer<vtkActor> MoveActor;
  vtkSmartPointer<vtkPolyData> MovePolyData;
  vtkSmartPointer<vtkVertexGlyphFilter> MoveGlyphFilter;

  vtkSmartPointer<vtkPointPicker> PointPicker;

  bool Move;
  vtkIdType SelectedPoint;
};
vtkStandardNewMacro(InteractorStyle2); // error occurs in the debug mode

//....
void CvtkMFCDlgExDlg::OnBnClickedButtonPicking()
{       
  vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
  points->InsertNextPoint(0, 0, 0);
  points->InsertNextPoint(1, 0, 0);
  points->InsertNextPoint(2, 0, 0);

  vtkSmartPointer<vtkPolyData> input = vtkSmartPointer<vtkPolyData>::New();
  input->SetPoints(points);

  vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter = vtkSmartPointer<vtkVertexGlyphFilter>::New();

  glyphFilter->SetInputData(input);
  glyphFilter->Update();

  // Create a mapper and actor
  vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
  mapper->SetInputConnection(glyphFilter->GetOutputPort());

  vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
  actor->SetMapper(mapper);
  actor->GetProperty()->SetPointSize(10);

  // Visualize
  vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();

  renderer->AddActor(actor);

  m_vtkWindow->AddRenderer(renderer);
  m_vtkWindow->Render();

  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = m_vtkWindow->GetInteractor();

  vtkSmartPointer<InteractorStyle2> style = vtkSmartPointer<InteractorStyle2>::New();
  renderWindowInteractor->SetInteractorStyle(style);

  style->Data = input;
}



--
Sent from: https://urldefense.proofpoint.com/v2/url?u=http-3A__vtk.1045678.n5.nabble.com_VTK-2DUsers-2Df1224199.html&d=DwICAg&c=hmGTLOph1qd_VnCqj81HzEWkDaxmYdIWRBdoFggzhj8&r=QPUyrnKdkaGJHD0OTha3x09u1N6qkcvUsRW8n2fg59E&m=HsDAM8uSamf6yLdv9u0Y3Bz8y1PqEyqlwZRYTwGdEgY&s=NIAFIEDf5L0rrSS86V_zdoKoe8nSLZjmBd89F5-L2C8&e=
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at https://urldefense.proofpoint.com/v2/url?u=http-3A__www.kitware.com_opensource_opensource.html&d=DwICAg&c=hmGTLOph1qd_VnCqj81HzEWkDaxmYdIWRBdoFggzhj8&r=QPUyrnKdkaGJHD0OTha3x09u1N6qkcvUsRW8n2fg59E&m=HsDAM8uSamf6yLdv9u0Y3Bz8y1PqEyqlwZRYTwGdEgY&s=dW8JORvscqn4ODNxJQnnrv7jq-oXxJ8MLWe-GRPAvy8&e=

Please keep messages on-topic and check the VTK FAQ at: https://urldefense.proofpoint.com/v2/url?u=http-3A__www.vtk.org_Wiki_VTK-5FFAQ&d=DwICAg&c=hmGTLOph1qd_VnCqj81HzEWkDaxmYdIWRBdoFggzhj8&r=QPUyrnKdkaGJHD0OTha3x09u1N6qkcvUsRW8n2fg59E&m=HsDAM8uSamf6yLdv9u0Y3Bz8y1PqEyqlwZRYTwGdEgY&s=HU0mKy-Jfjc1gWcLXUUtQsJGJnByhOKyRCcZBuFxCII&e=

Search the list archives at: https://urldefense.proofpoint.com/v2/url?u=http-3A__markmail.org_search_-3Fq-3Dvtkusers&d=DwICAg&c=hmGTLOph1qd_VnCqj81HzEWkDaxmYdIWRBdoFggzhj8&r=QPUyrnKdkaGJHD0OTha3x09u1N6qkcvUsRW8n2fg59E&m=HsDAM8uSamf6yLdv9u0Y3Bz8y1PqEyqlwZRYTwGdEgY&s=347P0Va3uvBfYPTHeJ1Bx1Wmt9oMUUDvFb1FNoSvVyw&e=

Follow this link to subscribe/unsubscribe:
https://urldefense.proofpoint.com/v2/url?u=https-3A__vtk.org_mailman_listinfo_vtkusers&d=DwICAg&c=hmGTLOph1qd_VnCqj81HzEWkDaxmYdIWRBdoFggzhj8&r=QPUyrnKdkaGJHD0OTha3x09u1N6qkcvUsRW8n2fg59E&m=HsDAM8uSamf6yLdv9u0Y3Bz8y1PqEyqlwZRYTwGdEgY&s=mJn5y0rmdBLoVkg_ZmwWWO4bfTnqD6uo09EV4I0FBTE&e=


More information about the vtkusers mailing list