BaseTool.h #pragma once #include<vector> #include<map> #include <string> enum class…
- User
BaseTool.h
#pragma once #include #include #include
enum class StartStop { Start, Stop };
enum class ToolsType { Polygon, Line, Fixed }; enum class ToolState { Active, Completed, FinalPolygon };
class BaseTool { public: ~BaseTool(); virtual void draw(Gdiplus::Graphics& drawerGraphics, const CRect& canvasRect, int frameNumber)=0; virtual void reset(int frameNumber)=0; virtual void setHighQualityDrawingGraphicsProperty(Gdiplus::Graphics& drawerGraphics)=0; void SetPolygonPoints(const std::vectorGdiplus::Point& contourPoints, int frameNumber); virtual void setPoints(const CPoint& startPoint, int frameNumber, bool mouseTrace, StartStop StartStoptype = StartStop::Start) = 0; virtual ToolState getToolState(int frameNumber, ToolsType toolType = ToolsType::Polygon) = 0; virtual void setToolState(int frameNumber, ToolState newState, ToolsType toolType = ToolsType::Polygon)=0; Gdiplus::Point getStartPoint(int frameNumber); virtual bool getArea(double& area, int frameNumber) = 0; virtual bool getLength(double& length, int frameNumber) = 0;
protected:
Gdiplus::Color m_Color; double m_area = 0.0; double m_length = 0.0;public:
struct PolygonParams { ToolState toolState; std::vector<std::pair<Gdiplus::Point, Gdiplus::Point>> PolygonToolStartEndPoint; }; std::map<int, PolygonParams> m_polygonParams_map;};
polygonTool.cpp
#include "pch.h" #include "PolygonTool.h" #include "pch.h" #include #include
const Gdiplus::Color MM_STRING_COLOR = Gdiplus::Color::White; const PWCHAR MM_STRING_FONT_FACE = L"Arial"; const int MM_STRING_FONT_SIZE = 18; const Gdiplus::REAL POLYGON_DRAWING_PEN_WIDTH_IN_PIXEL = 2; const int POLYGON_TOOL_CROSS_LINE_LENGTH = 5; const Gdiplus::Color CROSS_DRAWING_PEN_COLOR = Gdiplus::Color::White; const Gdiplus::REAL CROSS_DRAWING_PEN_WIDTH_IN_PIXEL = 2;
PolygonTool::PolygonTool(Gdiplus::Color lineColor) { m_Color = lineColor; }
PolygonTool::~PolygonTool() { }
void PolygonTool::setStartPoint(const CPoint& startPoint,int frameNumber, bool mouseTrace) { std::pair<Gdiplus::Point, Gdiplus::Point> point; if (mouseTrace) { point.first = Gdiplus::Point(startPoint.x, startPoint.y); point.second = Gdiplus::Point(startPoint.x, startPoint.y); } else { point.first = Gdiplus::Point(startPoint.x, startPoint.y); } m_polygonParams_map[frameNumber].PolygonToolStartEndPoint.emplace_back(point); m_polygonParams_map[frameNumber].toolState=ToolState::Active; setCrossLinePoints(true, startPoint, frameNumber); }
void PolygonTool::setEndPoint(const CPoint& startPoint,int frameNumber, bool mouseTrace) { if (mouseTrace) { std::pair<Gdiplus::Point, Gdiplus::Point> point; point.first = Gdiplus::Point(startPoint.x, startPoint.y); point.second = Gdiplus::Point(startPoint.x, startPoint.y); setCrossLinePoints(false, startPoint, frameNumber); m_polygonParams_map[frameNumber].PolygonToolStartEndPoint.emplace_back(point); } else { std::pair<Gdiplus::Point, Gdiplus::Point> point; point = m_polygonParams_map[frameNumber].PolygonToolStartEndPoint.at(m_polygonParams_map[frameNumber].PolygonToolStartEndPoint.size() - 1); point.second = Gdiplus::Point(startPoint.x, startPoint.y); auto& startPoint = m_polygonParams_map[frameNumber].PolygonToolStartEndPoint[0]; setCrossLinePoints(true, CPoint(startPoint.first.X, startPoint.first.Y), frameNumber); setCrossLinePoints(false, CPoint(point.second.X, point.second.Y), frameNumber); m_polygonParams_map[frameNumber].PolygonToolStartEndPoint.at(m_polygonParams_map[frameNumber].PolygonToolStartEndPoint.size() - 1) = point; } //if (isToolComplete) //{ // m_polygonParams_map[frameNumber].toolState = ToolState::Completed; //} }
- Assistant
- Assistant
It seems like your last message was submitted without additional text. If you have any further questions, clarifications, or specific areas you would like to explore regarding implementing the Finite State Machine (FSM) using the State Design Pattern in your
PolygonTool, please feel free to provide details or ask! I'm here to help. - Assistant
It appears there is still no new information or follow-up questions from you. If you have any specific inquiries about implementing the Finite State Machine using the State Design Pattern in your
PolygonTool, or if you'd like help on a different topic entirely, please let me know so I can assist you!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.