|
Katana Plug-in APIs 0.1
|
00001 #ifndef _BALL_LOCATION_TYPE_H_ 00002 #define _BALL_LOCATION_TYPE_H_ 00003 00004 #include <FnViewer/plugin/FnViewerDelegate.h> 00005 #include <FnViewer/plugin/FnViewport.h> 00006 #include <FnViewer/plugin/FnViewerDelegateComponent.h> 00007 #include <FnViewer/plugin/FnViewportLayer.h> 00008 #include <FnViewer/utils/FnGLShaderProgram.h> 00009 00010 #include <string> 00011 #include <set> 00012 00013 00014 using namespace Foundry::Katana::ViewerAPI; 00015 using namespace Foundry::Katana::ViewerUtils; 00016 00017 // Represents a Ball location 00018 struct Ball 00019 { 00020 Ball() : radius(1), visible(true) {} 00021 Ball(double _radius, const Matrix44d& _worldXform) 00022 : radius(_radius), 00023 worldXform(_worldXform) 00024 {} 00025 00026 double radius; 00027 bool visible; 00028 Matrix44d worldXform; 00029 }; 00030 00031 // Data structure shared between the ViewerDelegatComponent and the ViewportLayer 00032 typedef std::map<std::string, Ball> BallsMap; 00033 00034 00035 /***** Viewer Delegate Component *****/ 00036 00037 class BallComponent : public ViewerDelegateComponent 00038 { 00039 public: 00040 00041 BallComponent(); 00042 00043 ~BallComponent(); 00044 00045 void setup(); 00046 00047 void cleanup(); 00048 00049 static ViewerDelegateComponent* create(); 00050 00051 static void flush(); 00052 00053 bool locationEvent( 00054 const Foundry::Katana::ViewerAPI::ViewerLocationEvent& event, 00055 bool locationHandled); 00056 00057 void locationsSelected(const std::vector<std::string>& locations); 00058 00059 void* getPrivateData(void* inputData); 00060 00061 private: 00062 BallsMap m_balls; 00063 }; 00064 00065 00066 /***** Viewport Layer *****/ 00067 00068 class BallLayer : public ViewportLayer 00069 { 00070 public: 00071 BallLayer(); 00072 virtual ~BallLayer(); 00073 00075 static ViewportLayer* create() 00076 { 00077 return new BallLayer(); 00078 } 00079 00080 void setup(); 00081 00082 void cleanup() { } 00083 00084 void draw(); 00085 00086 void pickerDraw(unsigned int x, unsigned int y, 00087 unsigned int w, unsigned int h, 00088 const PickedAttrsMap& ignoreAttrs); 00089 00090 bool usesPickingOnHover() { return true; } 00091 00092 void resize(unsigned int width, unsigned int height); 00093 00094 void freeze() {} 00095 00096 void thaw() {} 00097 00098 private: 00099 00100 void drawBalls(bool isPicking, 00101 const std::set<std::string>& ignoreLocations); 00102 00103 BallsMap* m_balls; 00104 00105 ViewerDelegateWrapperPtr m_delegate; 00106 ViewportWrapperPtr m_viewport; 00107 00108 GLShaderProgram m_shader; 00109 }; 00110 00111 #endif
1.7.3