Simple Nano Circuit 0.0.2
WireObject.h
1#ifndef _WireObject_H_
2#define _WireObject_H_
3
4#include <SDL.h>
5
6#include "BaseElectronObject.h"
7#include "NetlistManagerClass.h"
8#include "NetlistClass.h"
9
11class FootPinNode;
12
14{
15 private:
16 struct Color
17 {
18 uint8_t red;
19 uint8_t green;
20 uint8_t blue;
21 uint8_t alpha;
22 };
23
24 enum class DrawingLineStage
25 {
26 NotYet = 0,
27 FirstPointSelected,
28 TwoPointsAllSelected,
29 };
30
31 // 定义线条的颜色
32 const Color innerSolidLineColor = {0x00, 0x00, 0x00, 0xFF};
33 const Color solidLineColor = {0xCC, 0xCC, 0xCC, 0x99};
34 const Color solidPositiveLineColor = {0x00, 0xCC, 0x00, 0x99}; // 正电压
35 const Color solidNegativeLineColor = {0xCC, 0x00, 0x00, 0x99}; // 负电压
36
37 const Color firstLineCanColor = {0x33, 0x66, 0x99, 0x33};
38 const Color secondLineCanColor = {0x33, 0x66, 0x99, 0x11};
39 const Color cursorPointCanColor = {0x00, 0xFF, 0x00, 0xFF};
40
41 const Color firstLineForbiddenColor = {0xFF, 0x00, 0x00, 0x33};
42 const Color secondLineForbiddenColor = {0x33, 0x66, 0x99, 0x11};
43 const Color cursorPointForbiddenColor = {0xFF, 0x00, 0x00, 0xFF};
44
45 void DrawSnLine( SDL_Point , SDL_Point , WireObject::Color );
46 void drawCursorPoint( SDL_Point , WireObject::Color );
47
48 void renderingLinesAndCursor(WireObject::Color , WireObject::Color , WireObject::Color );
49
50 struct StoreData
51 {
52 ICType id;
53 SDL_Point startPos;
54 SDL_Point endPos;
55 };
56 StoreData storeData;
57
58 public:
59 // 线条的粗细程度
60 const int lineBorder = 4;
61
62 SDL_Point startPos;
63 SDL_Point endPos;
64 SDL_Point mousePos;
65
66 FootPinNode* startPin = nullptr;
67 FootPinNode* endPin = nullptr;
68
69 WireObject::DrawingLineStage drawingLineStage = WireObject::DrawingLineStage::NotYet;
70
74
75 WireObject(const unsigned char*, AsgardClass*);
76
77 const ICType getType() const override {return ICType::Wire;}
78
79 void Drawing() override;
80 void Drawing(BaseElectronObject::RendererEffective ) override;
81
82 BaseElectronObject* processClickEvent( SDL_Point& ) override;
83 BaseElectronObject* deepDuplicateSelf() override;
84
85 void processKeyEvent( int ) override;
86
87 bool isDrawing();
88 void resetToDrawNewLine();
89
90 SDL_Rect getLocationRect() override;
91
92 NetlistManagerClass::BindResult bindNetlist();
93
94 bool havePopupWindow() override {return false;}
95 const char* popupWindowName() const override {return "";}
96 void CreateImGuiForm() override {return;};
97
99
100 bool isPinOnSegment( FootPinNode* );
101 bool isPointOnSegment( SDL_Point );
102
103 NetlistClass* attachedNet = nullptr;
104 void setNetlist( NetlistClass* _nl) {this->attachedNet = _nl;};
105
106 const double getCurrent();
107 SDL_Point SDL_middlePoint();
108
109 void pinInvalidNotify(FootPinNode*);
110 void setCurrentNotify(FootPinNode*);
111
112 void saveToFile(std::ofstream&) override;
113
114 void processMouseMotion(const SDL_Point&) override;
115
116 void DrawingElectronAnimate(SDL_Point, SDL_Point);
117 double currentPositionOffset = 0;
118};
119
120#endif
Definition: AsgardClass.h:17
Definition: BaseElectronObject.h:13
Definition: FootPinNode.h:15
Definition: NetlistClass.h:19
Definition: PlacementManagerClass.h:18
Definition: WireObject.h:14
void beSplitedToMultiSubLines(FootPinNode *)
Definition: WireObject.cpp:346
NetlistManagerClass::BindResult bindNetlist()
wire自身向 netlistManager 申请进行网络绑定
Definition: WireObject.cpp:341
BaseElectronObject * processClickEvent(SDL_Point &) override
Definition: WireObject.cpp:250