Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# Hybrid/vtkLineWidget.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkLineWidget.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00094 #ifndef __vtkLineWidget_h
    00095 #define __vtkLineWidget_h
    00096
    00097 #include "vtk3DWidget.h"
    00098 #include "vtkLineSource.h" // For passing calls to it
    00099
    00100 class vtkActor;
    00101 class vtkPolyDataMapper;
    00102 class vtkPoints;
    00103 class vtkPolyData;
    00104 class vtkProp;
    00105 class vtkProperty;
    00106 class vtkSphereSource;
    00107 class vtkCellPicker;
    00108 class vtkPointWidget;
    00109 class vtkPWCallback;
    00110 class vtkPW1Callback;
    00111 class vtkPW2Callback;
    00112
    00113 class VTK_HYBRID_EXPORT vtkLineWidget : public vtk3DWidget
    00114 {
    00115 public:
    00117   static vtkLineWidget *New();
    00118
    00119   vtkTypeRevisionMacro(vtkLineWidget,vtk3DWidget);
    00120   void PrintSelf(ostream& os, vtkIndent indent);
    00121
    00123
    00124   virtual void SetEnabled(int);
    00125   virtual void PlaceWidget(float bounds[6]);
    00126   void PlaceWidget()
    00127     {this->Superclass::PlaceWidget();}
    00128   void PlaceWidget(float xmin, float xmax, float ymin, float ymax,
    00129                    float zmin, float zmax)
    00130     {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
    00132
    00134
    00135   void SetResolution(int r)
    00136     { this->LineSource->SetResolution(r); }
    00137   int GetResolution()
    00138     { return this->LineSource->GetResolution(); }
    00140
    00142
    00143   void SetPoint1(float x, float y, float z);
    00144   void SetPoint1(float x[3])
    00145     {this->SetPoint1(x[0], x[1], x[2]); }
    00146   float* GetPoint1()
    00147     {return this->LineSource->GetPoint1();}
    00148   void GetPoint1(float xyz[3])
    00149     {this->LineSource->GetPoint1(xyz);}
    00151
    00153
    00154   void SetPoint2(float x, float y, float z);
    00155   void SetPoint2(float x[3])
    00156     {this->SetPoint2(x[0], x[1], x[2]);}
    00157   float* GetPoint2()
    00158     {return this->LineSource->GetPoint2();}
    00159   void GetPoint2(float xyz[3])
    00160     {this->LineSource->GetPoint2(xyz);}
    00162
    00164
    00168   vtkSetClampMacro(Align, int, XAxis, None);
    00169   vtkGetMacro(Align, int);
    00170   void SetAlignToXAxis() { this->SetAlign(XAxis); }
    00171   void SetAlignToYAxis() { this->SetAlign(YAxis); }
    00172   void SetAlignToZAxis() { this->SetAlign(ZAxis); }
    00173   void SetAlignToNone()  { this->SetAlign(None); }
    00175
    00177
    00181   vtkSetMacro(ClampToBounds,int);
    00182   vtkGetMacro(ClampToBounds,int);
    00183   vtkBooleanMacro(ClampToBounds,int);
    00185
    00191   void GetPolyData(vtkPolyData *pd);
    00192
    00194
    00197   vtkGetObjectMacro(HandleProperty,vtkProperty);
    00198   vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
    00200
    00202
    00204   vtkGetObjectMacro(LineProperty,vtkProperty);
    00205   vtkGetObjectMacro(SelectedLineProperty,vtkProperty);
    00207
    00208 protected:
    00209   vtkLineWidget();
    00210   ~vtkLineWidget();
    00211
    00212 //BTX - manage the state of the widget
    00213   friend class vtkPWCallback;
    00214
    00215   int State;
    00216   enum WidgetState
    00217   {
    00218     Start=0,
    00219     MovingHandle,
    00220     MovingLine,
    00221     Scaling,
    00222     Outside
    00223   };
    00224 //ETX
    00225
    00226   //handles the events
    00227   static void ProcessEvents(vtkObject* object,
    00228                             unsigned long event,
    00229                             void* clientdata,
    00230                             void* calldata);
    00231
    00232   // ProcessEvents() dispatches to these methods.
    00233   void OnLeftButtonDown();
    00234   void OnLeftButtonUp();
    00235   void OnMiddleButtonDown();
    00236   void OnMiddleButtonUp();
    00237   void OnRightButtonDown();
    00238   void OnRightButtonUp();
    00239   virtual void OnMouseMove();
    00240
    00241   // controlling ivars
    00242   int Align;
    00243
    00244 //BTX
    00245   enum AlignmentState {
    00246     XAxis,
    00247     YAxis,
    00248     ZAxis,
    00249     None
    00250   };
    00251 //ETX
    00252
    00253   // the line
    00254   vtkActor          *LineActor;
    00255   vtkPolyDataMapper *LineMapper;
    00256   vtkLineSource     *LineSource;
    00257   void HighlightLine(int highlight);
    00258
    00259   // glyphs representing hot spots (e.g., handles)
    00260   vtkActor          **Handle;
    00261   vtkPolyDataMapper **HandleMapper;
    00262   vtkSphereSource   **HandleGeometry;
    00263
    00264   void BuildRepresentation();
    00265   virtual void SizeHandles();
    00266   void HandlesOn(double length);
    00267   void HandlesOff();
    00268   int HighlightHandle(vtkProp *prop); //returns cell id
    00269   void HighlightHandles(int highlight);
    00270
    00271   // Do the picking
    00272   vtkCellPicker *HandlePicker;
    00273   vtkCellPicker *LinePicker;
    00274   vtkActor *CurrentHandle;
    00275   float LastPosition[3];
    00276   void  SetLinePosition(float x[3]);
    00277
    00278   // Methods to manipulate the hexahedron.
    00279   void Scale(double *p1, double *p2, int X, int Y);
    00280
    00281   // Initial bounds
    00282   int   ClampToBounds;
    00283   void  ClampPosition(float x[3]);
    00284   int   InBounds(float x[3]);
    00285
    00286   // Properties used to control the appearance of selected objects and
    00287   // the manipulator in general.
    00288   vtkProperty *HandleProperty;
    00289   vtkProperty *SelectedHandleProperty;
    00290   vtkProperty *LineProperty;
    00291   vtkProperty *SelectedLineProperty;
    00292   void CreateDefaultProperties();
    00293
    00294   void GenerateLine();
    00295
    00296   // Methods for managing the point widgets used to control the endpoints
    00297   vtkPointWidget *PointWidget;
    00298   vtkPointWidget *PointWidget1;
    00299   vtkPointWidget *PointWidget2;
    00300   vtkPWCallback  *PWCallback;
    00301   vtkPW1Callback *PW1Callback;
    00302   vtkPW2Callback *PW2Callback;
    00303   vtkPointWidget *CurrentPointWidget;
    00304   void EnablePointWidget();
    00305   void DisablePointWidget();
    00306   int ForwardEvent(unsigned long event);
    00307
    00308 private:
    00309   vtkLineWidget(const vtkLineWidget&);  //Not implemented
    00310   void operator=(const vtkLineWidget&);  //Not implemented
    00311 };
    00312
    00313 #endif