vtkCard.h

Go to the documentation of this file.
00001 /*=auto=========================================================================
00002 
00003   Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
00004 
00005   See Doc/copyright/copyright.txt
00006   or http://www.slicer.org/copyright/copyright.txt for details.
00007 
00008   Program:   3D Slicer
00009   Module:    $RCSfile: vtkCard.h,v $
00010   Date:      $Date: 2006/05/26 19:59:41 $
00011   Version:   $Revision: 1.3 $
00012 
00013 =========================================================================auto=*/
00014 /*===========================================================
00015 
00016 Authors: Michael McKenna, David Small, Steve Pieper.
00017     Small Design Firm, Inc.,
00018     in association with Isomics, Inc.,
00019     and Partners Health Care.  MA, USA.
00020     June, 2004
00021 
00022 ===========================================================*/
00023 
00024 
00025 // .NAME vtkCard - create a "card" that hold text and image elements.
00026 // .SECTION Description
00027 
00028 
00029 #ifndef __vtkCard_h
00030 #define __vtkCard_h
00031 
00032 
00033 #include "vtkObject.h"
00034 #include "vtkTexture.h"
00035 #include "vtkFollower.h"
00036 #include "vtkCollection.h"
00037 #include "vtkRenderer.h"
00038 
00039 #include "simpleVectors.h"
00040 
00041 #include "vtkQueryAtlasWin32Header.h"
00042 
00043 
00044 class vtkTextureText;
00045 class vtkFollower;
00046 class vtkRectangle;
00047 class vtkCamera;
00048 class vtkActor;
00049 class vtkLineSource;
00050 
00051 
00052 #define VTK_TEXT_CARD_EDGE_COUNT (8)
00053 
00054 
00055 class VTK_QUERYATLAS_EXPORT vtkCard : public vtkObject 
00056 {
00057 public:
00058     void PrintSelf(ostream& os, vtkIndent indent);
00059     vtkTypeRevisionMacro(vtkCard,vtkObject);
00060 
00061     // Description:
00062     // Manage a set of vtkTextureText objects with a surrounding rectangle-box.
00063     static vtkCard *New();
00064 
00065     vtkGetObjectMacro(MainText, vtkTextureText);  
00066     void SetMainText(vtkTextureText *t);
00067 
00068     vtkGetObjectMacro(Box, vtkFollower);  
00069     vtkGetObjectMacro(BoxRectangle, vtkRectangle);  
00070 
00071     vtkGetMacro(BorderWidth, vtkFloatingPointType);  
00072     vtkGetMacro(BoxEdgeWidth, vtkFloatingPointType);  
00073     vtkGetMacro(BoxEdgeBias, vtkFloatingPointType);  
00074     vtkGetMacro(BoxDistanceZ, vtkFloatingPointType);  
00075 
00076     void SetBorderWidth(vtkFloatingPointType b);
00077     void SetBoxEdgeWidth(vtkFloatingPointType b);
00078     void SetBoxEdgeBias(vtkFloatingPointType b);
00079     void SetBoxDistanceZ(vtkFloatingPointType d);
00080 
00081     vtkGetMacro(UseBoxEdge, bool);
00082     void SetUseBoxEdge(bool b);
00083 
00084     vtkGetMacro(UseTexturedBoxEdge, bool);
00085     void SetUseTexturedBoxEdge(bool b);
00086 
00087 
00088     // TODO - These default value methods should be a static method
00089     vtkGetMacro(DefaultBoxDistanceZ, vtkFloatingPointType);
00090     vtkSetMacro(DefaultBoxDistanceZ, vtkFloatingPointType);
00091 
00092     vtkGetMacro(DefaultBorderWidth, vtkFloatingPointType);
00093     vtkSetMacro(DefaultBorderWidth, vtkFloatingPointType);
00094 
00095     vtkGetMacro(DefaultBoxEdgeWidth, vtkFloatingPointType);
00096     vtkSetMacro(DefaultBoxEdgeWidth, vtkFloatingPointType);
00097 
00098     vtkGetMacro(DefaultUseBoxEdge, bool);
00099     vtkSetMacro(DefaultUseBoxEdge, bool);
00100 
00101     vtkGetMacro(DefaultBoxEdgeBias, vtkFloatingPointType);
00102     vtkSetMacro(DefaultBoxEdgeBias, vtkFloatingPointType);
00103 
00104     static vtkFloatingPointType DefaultBoxColor[3];
00105     vtkFloatingPointType BoxColor[3];
00106 
00107     static vtkFloatingPointType DefaultBoxEdgeColor[3];
00108     vtkFloatingPointType BoxEdgeColor[3];
00109 
00110     static void SetDefaultBoxColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b);
00111     void SetBoxColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b);
00112 
00113     static void SetDefaultBoxEdgeColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b);
00114     void SetBoxEdgeColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b);
00115 
00116     // TODO - add methods for GetBoxColor, GetDefaultBoxColor, GetBoxEdgeColor, GetDefaultBoxEdgeColor
00117     // TODO - add methods for SetXXColor using vtkFloatingPointType[3]
00118 
00119 
00120     vtkFollower *CreateBox();
00121     vtkFollower *UpdateBox();
00122     void CreateBoxEdge();
00123     void RemoveBoxEdge();
00124 
00125     vtkGetMacro(BoxWidthMinimum, vtkFloatingPointType);
00126     vtkSetMacro(BoxWidthMinimum, vtkFloatingPointType);
00127     vtkGetMacro(BoxHeightMinimum, vtkFloatingPointType);
00128     vtkSetMacro(BoxHeightMinimum, vtkFloatingPointType);
00129 
00130 
00131     void SetPosition(vtkFloatingPointType x, vtkFloatingPointType y, vtkFloatingPointType z);
00132     void SetPosition (vtkFloatingPointType _arg[3]);
00133 
00134     //void SetPositionOffset(vtkFloatingPointType x, vtkFloatingPointType y, vtkFloatingPointType z);
00135     void AddPositionOffset(vtkFloatingPointType x, vtkFloatingPointType y, vtkFloatingPointType z);
00136 
00137 
00138     void SetOffsetActorAndMarker(vtkActor *a, vtkFloatingPointType markerX, vtkFloatingPointType markerY, vtkFloatingPointType markerZ, 
00139                                           vtkFloatingPointType offX, vtkFloatingPointType offY, vtkFloatingPointType offZ);
00140     void SetOffsetActorAndMarker(vtkActor *a, vtkActor *m, vtkFloatingPointType offX, vtkFloatingPointType offY, vtkFloatingPointType offZ);
00141     void SetOffsetActorAndMarker(vtkActor *a, vtkActor *m, vtkFloatingPointType off[3]);    
00142     void UpdateOffsetActorAndMarker();
00143 
00144     //BTX
00145     void GetPosition (vtkFloatingPointType data[3]);
00146     //ETX
00147 
00148     void SetScale(vtkFloatingPointType s);
00149 
00150     void Center();
00151     void CenterOffset();
00152 
00153     // Description:
00154     // Call Modified() if a text property, such as position, size, text, etc. has changed.
00155     // The box will then be updated.
00156     void Modified();
00157 
00158     void SetOthersVisibility(bool v);
00159     void OthersVisibilityOn();
00160     void OthersVisibilityOff();
00161     vtkGetMacro(OthersVisibility, bool);
00162 
00163     void SetVisibility(bool v);
00164     void SetOpacityBase(vtkFloatingPointType o);
00165 
00166     void SetCamera(vtkCamera *cam);
00167 
00168 
00169     // used mostly so that we can resort the card rendering order
00170     void RemoveActors(vtkRenderer *r);
00171     void RemoveActors();
00172     void AddActors(vtkRenderer *r);
00173     void AddActors();
00174 
00175 
00176     vtkCollection *GetOtherTexts();
00177 
00178 
00179     vtkActor *CreateLine(vtkFloatingPointType x, vtkFloatingPointType y, vtkFloatingPointType z);
00180 
00181     void SetLinePoint1(vtkFloatingPointType x, vtkFloatingPointType y, vtkFloatingPointType z);
00182     void SetLinePoint1Local(vtkFloatingPointType x, vtkFloatingPointType y, vtkFloatingPointType z);
00183     void SetLinePoint2(vtkFloatingPointType x, vtkFloatingPointType y, vtkFloatingPointType z);
00184 
00185     vtkGetObjectMacro(LineActor, vtkActor);
00186     vtkGetObjectMacro(LineSource, vtkLineSource);
00187 
00188     vtkGetObjectMacro(Texture, vtkTexture);
00189     vtkSetObjectMacro(Texture, vtkTexture);
00190 
00191     vtkGetObjectMacro(Renderer, vtkRenderer);
00192     vtkSetObjectMacro(Renderer, vtkRenderer);
00193 
00194     vtkGetMacro(LevelNum, int);
00195     vtkSetMacro(LevelNum, int);
00196    
00197     vtkGetMacro(LevelX, vtkFloatingPointType);
00198     vtkSetMacro(LevelX, vtkFloatingPointType);
00199    
00200     void SetDim(bool d);
00201 
00202     //vtkFollower *ImageFollower;
00203     //vtkGetObjectMacro(ImageFollower, vtkFollower);
00204     //vtkSetObjectMacro(ImageFollower, vtkFollower);
00205 
00206     // macro wasn't working?
00207     //vtkGetObjectMacro(ImageFollowers, vtkCollection *);
00208     vtkCollection *GetImageFollowers();
00209     vtkCollection *GetImageRectangles();
00210 
00211     static char *LoadString(char *filename);
00212 
00213 
00214 protected:
00215     vtkCard();
00216     ~vtkCard();
00217 
00218     vtkTextureText *MainText;
00219     vtkFollower *Box;
00220     vtkRectangle *BoxRectangle;
00221 
00222     // NOTE - using a hardcoded edge count
00223     vtkFollower *BoxEdge[VTK_TEXT_CARD_EDGE_COUNT];
00224     vtkRectangle *BoxEdgeRectangle[VTK_TEXT_CARD_EDGE_COUNT];
00225 
00226     static bool DefaultUseBoxEdge;
00227     bool UseBoxEdge;
00228     bool UseTexturedBoxEdge;
00229     int BoxEdgeCount;
00230 
00231     vtkFloatingPointType BoxWidthMinimum;
00232     vtkFloatingPointType BoxHeightMinimum;
00233 
00234     vtkActor *OffsetActor;
00235     vtkActor *OffsetMarker;
00236 //BTX
00237     Vector3D<vtkFloatingPointType> OffsetVector;
00238     Vector3D<vtkFloatingPointType> OffsetMarkerVector;
00239 //ETX
00240 
00241     vtkFloatingPointType UnscaledBorderWidth;
00242     vtkFloatingPointType BorderWidth;
00243     vtkFloatingPointType UnscaledBoxEdgeWidth;
00244     vtkFloatingPointType BoxEdgeWidth;
00245     vtkFloatingPointType UnscaledBoxEdgeBias;
00246     vtkFloatingPointType BoxEdgeBias;
00247     vtkFloatingPointType UnscaledBoxDistanceZ;
00248     vtkFloatingPointType BoxDistanceZ;
00249 
00250     vtkFloatingPointType ScaleFactor;
00251 
00252     static vtkFloatingPointType DefaultBoxDistanceZ;
00253     static vtkFloatingPointType DefaultBorderWidth;
00254     static vtkFloatingPointType DefaultBoxEdgeWidth;
00255     static vtkFloatingPointType DefaultBoxEdgeBias;
00256 
00257     bool OthersVisibility;
00258 
00259     vtkCollection *OtherTexts;
00260 
00261     // NOTE - The ImageFollower and it's Rectangle must be added in the same order
00262     // TODO - make an object to hold the two together - could add the Follower to Rectangle for convenience
00263     vtkCollection *ImageFollowers;
00264     vtkCollection *ImageRectangles;
00265 
00266     vtkActor *LineActor;
00267     //Vector3D LineEnd;
00268     vtkLineSource *LineSource;
00269 
00270     // make mostly transparent - used with SortCommand, so that objects in front of a selected object don't obscure.
00271     bool Dim;
00272 
00273     vtkFloatingPointType BoxOpacity;
00274     vtkFloatingPointType TextOpacity;
00275 
00276     vtkTexture *Texture;
00277 
00278     vtkRenderer *Renderer;
00279 
00280     // An extra paramater, e.g. Card Num, or some other parameter - used with BIRNCards.
00281     int LevelNum;
00282     vtkFloatingPointType LevelX;
00283 
00284 
00285 private:
00286     vtkCard(const vtkCard&);  // Not implemented.
00287     void operator=(const vtkCard&);  // Not implemented.
00288 };
00289 
00290 #endif
00291 
00292 

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1