VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkParallelopipedRepresentation.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00033 #ifndef __vtkParallelopipedRepresentation_h 00034 #define __vtkParallelopipedRepresentation_h 00035 00036 #include "vtkInteractionWidgetsModule.h" // For export macro 00037 #include "vtkWidgetRepresentation.h" 00038 00039 class vtkActor; 00040 class vtkPlane; 00041 class vtkPoints; 00042 class vtkPolyData; 00043 class vtkPolyDataMapper; 00044 class vtkProperty; 00045 class vtkCellArray; 00046 class vtkTransform; 00047 class vtkHandleRepresentation; 00048 class vtkClosedSurfacePointPlacer; 00049 class vtkPlaneCollection; 00050 class vtkParallelopipedTopology; 00051 00052 class VTKINTERACTIONWIDGETS_EXPORT vtkParallelopipedRepresentation 00053 : public vtkWidgetRepresentation 00054 { 00055 public: 00057 static vtkParallelopipedRepresentation *New(); 00058 00060 00061 vtkTypeMacro(vtkParallelopipedRepresentation,vtkWidgetRepresentation); 00062 void PrintSelf(ostream& os, vtkIndent indent); 00064 00066 virtual void GetActors(vtkPropCollection *pc); 00067 00069 00077 virtual void PlaceWidget(double corners[8][3]); 00078 virtual void PlaceWidget(double bounds[6]); 00080 00082 00085 vtkSetMacro(InteractionState,int); 00087 00093 void GetBoundingPlanes( vtkPlaneCollection *pc ); 00094 00096 void GetPolyData(vtkPolyData *pd); 00097 00099 virtual double *GetBounds(); 00100 00102 00103 virtual void SetHandleProperty (vtkProperty *); 00104 virtual void SetHoveredHandleProperty (vtkProperty *); 00105 virtual void SetSelectedHandleProperty (vtkProperty *); 00106 vtkGetObjectMacro(HandleProperty, vtkProperty ); 00107 vtkGetObjectMacro(HoveredHandleProperty, vtkProperty ); 00108 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty ); 00110 00111 void SetHandleRepresentation(vtkHandleRepresentation *handle); 00112 vtkHandleRepresentation* GetHandleRepresentation(int index); 00113 00115 00117 void HandlesOn(); 00118 void HandlesOff(); 00120 00122 00124 vtkGetObjectMacro(FaceProperty,vtkProperty); 00125 vtkGetObjectMacro(SelectedFaceProperty,vtkProperty); 00127 00129 00131 vtkGetObjectMacro(OutlineProperty,vtkProperty); 00132 vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty); 00134 00137 virtual void BuildRepresentation(); 00138 00140 00141 virtual void ReleaseGraphicsResources(vtkWindow *w); 00142 virtual int RenderOverlay(vtkViewport *viewport); 00143 virtual int RenderOpaqueGeometry(vtkViewport *viewport); 00145 00148 virtual int ComputeInteractionState(int X, int Y, int modify=0); 00149 00150 //BTX - manage the state of the widget 00151 enum _InteractionState 00152 { 00153 Outside = 0, 00154 Inside, 00155 RequestResizeParallelopiped, 00156 RequestResizeParallelopipedAlongAnAxis, 00157 RequestChairMode, 00158 RequestTranslateParallelopiped, 00159 RequestScaleParallelopiped, 00160 RequestRotateParallelopiped, 00161 ResizingParallelopiped, 00162 ResizingParallelopipedAlongAnAxis, 00163 ChairMode, 00164 TranslatingParallelopiped, 00165 ScalingParallelopiped, 00166 RotatingParallelopiped 00167 }; 00168 //ETX 00169 00170 // Methods to manipulate the piped. 00171 virtual void Translate( double translation[3] ); 00172 virtual void Translate( int X, int Y ); 00173 virtual void Scale( int X, int Y ); 00174 00177 virtual void PositionHandles(); 00178 00180 00184 vtkSetMacro( MinimumThickness, double ); 00185 vtkGetMacro( MinimumThickness, double ); 00187 00188 protected: 00189 vtkParallelopipedRepresentation(); 00190 ~vtkParallelopipedRepresentation(); 00191 00193 void TranslatePoint( int n, const double motionVector[3] ); 00194 00197 void SetHandleHighlight( int handleIdx, vtkProperty *property ); 00198 00200 00202 void SetFaceHighlight( vtkCellArray * face, vtkProperty * ); 00203 void HighlightAllFaces(); 00204 void UnHighlightAllFaces(); 00206 00207 // Node can be a value within [0,7]. This will create a chair one one of 00208 // the handle corners. '0 < InitialChairDepth < 1' value dicates the starting 00209 // depth of the cavity. 00210 void UpdateChairAtNode( int node ); 00211 00212 // Removes any existing chairs. 00213 void RemoveExistingChairs(); 00214 00215 // Convenience method to get just the planes that define the parallelopiped. 00216 // If we aren't in chair mode, this will be the same as GetBoundingPlanes(). 00217 // If we are in chair mode, this will be the first 6 planes from amongst 00218 // those returned by "GetBoundingPlanes". 00219 // All planes have their normals pointing inwards. 00220 void GetParallelopipedBoundingPlanes( vtkPlaneCollection * pc ); 00221 00222 // Convenience method to edefine a plane passing through 3 points. 00223 void DefinePlane( vtkPlane *, double p[3][3]); 00224 00225 // Convenience method to edefine a plane passing through 3 pointIds of the 00226 // parallelopiped. The point Ids must like in the range [0,15], ie the 00227 // 15 points comprising the parallelopiped and the chair (also modelled 00228 // as a parallelopiped) 00229 void DefinePlane( vtkPlane *, vtkIdType, vtkIdType, vtkIdType); 00230 00231 vtkActor * HexActor; 00232 vtkPolyDataMapper * HexMapper; 00233 vtkPolyData * HexPolyData; 00234 vtkPoints * Points; 00235 vtkActor * HexFaceActor; 00236 vtkPolyDataMapper * HexFaceMapper; 00237 vtkPolyData * HexFacePolyData; 00238 00239 double LastEventPosition[2]; 00240 00241 // Cache the axis index used for face aligned resize. 00242 int LastResizeAxisIdx; 00243 00244 vtkHandleRepresentation * HandleRepresentation; 00245 vtkHandleRepresentation ** HandleRepresentations; 00246 int CurrentHandleIdx; 00247 int ChairHandleIdx; 00248 00249 00250 // When a chair is carved out for the first time, this is the initial 00251 // depth of the chair 00252 double InitialChairDepth; 00253 00254 vtkProperty * HandleProperty; 00255 vtkProperty * HoveredHandleProperty; 00256 vtkProperty * FaceProperty; 00257 vtkProperty * OutlineProperty; 00258 vtkProperty * SelectedHandleProperty; 00259 vtkProperty * SelectedFaceProperty; 00260 vtkProperty * SelectedOutlineProperty; 00261 vtkClosedSurfacePointPlacer * ChairPointPlacer; 00262 vtkParallelopipedTopology * Topology; 00263 double MinimumThickness; 00264 double AbsoluteMinimumThickness; 00265 00266 private: 00267 vtkParallelopipedRepresentation(const vtkParallelopipedRepresentation&); //Not implemented 00268 void operator=(const vtkParallelopipedRepresentation&); //Not implemented 00269 }; 00270 00271 #endif