#ifndef _MESH_MESH_HPP_ #define _MESH_MESH_HPP_ #ifndef _COMMON_STDIO_HPP_ #include #endif #ifndef _COMMON_STRING_HPP_ #include #endif #ifndef _COMMON_WINDOW_HPP_ #include #endif #ifndef _COMMON_CALLBACK_HPP_ #include #endif #ifndef _COMMON_ARRAY_HPP_ #include #endif #ifndef _COMMON_PEN_HPP_ #include #endif #ifndef _MESH_SEGMENT_HPP_ #include #endif #ifndef _MESH_POLYPOINT_HPP_ #include #endif class GridMesh : public Array, public Window { public: enum GridShow{Show,NoShow}; GridMesh(HWND hParent,int width,int height,GridShow visibility=Show); ~GridMesh(void); void newMesh(WORD gridLines=GridLines); WORD saveMesh(String &pathFileName); WORD loadMesh(String &pathFileName); WORD retrieveMesh(Array &sourcePoints,Array &destPoints); WORD rowCols(void)const; WORD gridLines(void)const; WORD upgradeStatus(WORD retCode)const; // WORD isVisible(void)const; void showWindow(int visible=TRUE); void suspendMesh(WORD suspend); private: typedef LONG Index; enum Status{InActive,Active}; enum {IntersectionSegments=4}; enum {GridLines=8,MaxGridLines=16}; void registerClass(void); long WndProc(UINT message,WPARAM wParam,LPARAM lParam); void mouseUp(int x,int y); void mouseDown(int x,int y); void mouseMove(int x,int y); DWORD minDistance(const Segment &someSegment,const GDIPoint &mousePoint); WORD closestIntersection(Block &filterSegment,GDIPoint &mousePoint); WORD orderIntersection(Block &intersection); WORD isInBlock(Block &source,Segment &someSegment); void createMesh(WORD gridLines,Array &someSegmentVector); WORD retrieveMesh(Array &meshPoints,Array &meshSegments)const; void getBoundingRect(Block ¤tIntersection,Rect &boundingRect); void drawBoundingRect(const Rect &boundingRect); CallbackData::ReturnType createHandler(CallbackData &someCallbackData); CallbackData::ReturnType paintHandler(CallbackData &someCallbackData); CallbackData::ReturnType leftButtonUpHandler(CallbackData &someCallbackData); CallbackData::ReturnType leftButtonDownHandler(CallbackData &someCallbackData); CallbackData::ReturnType mouseMoveHandler(CallbackData &someCallbackData); CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData); void insertHandlers(void); void removeHandlers(void); Callback mCreateHandler; Callback mPaintHandler; Callback mLeftButtonUpHandler; Callback mLeftButtonDownHandler; Callback mMouseMoveHandler; Callback mDestroyHandler; Pen mDrawingPen; static char szClassName[]; static char szMenuName[]; Block mCurrentIntersection; int mGridLines; Status mStatus; String mVersionInfo; WORD mIsSuspended; HWND mhParent; HINSTANCE mhInstance; }; inline WORD GridMesh::gridLines(void)const { return mGridLines; } inline WORD GridMesh::rowCols(void)const { return mGridLines+2; } inline void GridMesh::suspendMesh(WORD suspend) { if(suspend)mIsSuspended=TRUE; else mIsSuspended=FALSE; } #endif