-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLOGITOOL.CPP
2195 lines (1658 loc) · 57 KB
/
LOGITOOL.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Logitool.cpp - implementation for Drawing tools
//
// Copyright (C) 1993-1994 George Mills and Softronics, Inc. Corporation
// All rights reserved.
//
#include "stdafx.h"
/////////////////////////////////////////////////////////////////////////////
// CLogiTool implementation
CPtrList CLogiTool::c_tools;
// Add each tool to the pool of tools
static CSelectTool selectTool;
static CANDGateTool andgateTool;
static CXORGateTool xorgateTool;
static CORGateTool orgateTool;
static CINVERTGateTool invertgateTool;
static CTristateGateTool tristategateTool;
static CBusGateTool busgateTool;
static COscillatorGateTool oscillatorgateTool;
static CClockGateTool clockgateTool;
static CTimerGateTool timergateTool;
static CLedGateTool ledgateTool;
static CSwitchGateTool switchgateTool;
static CSelectGateTool selectgateTool;
static CBuzzerGateTool buzzergateTool;
static CNULLGateTool nullgateTool;
static CLed7GateTool led7gateTool;
static CAsciidisplayGateTool asciidisplaygateTool;
static CAsciikeyboardGateTool asciikeyboardgateTool;
static CGroundGateTool groundgateTool;
static CPlusGateTool plusgateTool;
static CReadfileGateTool readfilegateTool;
static CSignalreceiverGateTool signalreceivergateTool;
static CSignalsenderGateTool signalsendergateTool;
static CAnalyzeGateTool analyzegateTool;
static CSoundwaveGateTool soundwavegateTool;
static CWritefileGateTool writefilegateTool;
static CFlipflopGateTool flipflopgateTool;
static CKeypadGateTool keypadgateTool;
static CBitmapGateTool bitmapgateTool;
static CCounterGateTool countergateTool;
static CRandomGateTool randomgateTool;
static CBreakGateTool breakgateTool;
static CBitbucketGateTool bitbucketgateTool;
static CNetworkGateTool networkgateTool;
static CRobotGateTool robotgateTool;
static CMemoryGateTool memorygateTool;
static CTapedriveGateTool tapedrivegateTool;
static CMuxGateTool muxgateTool;
static CAluGateTool alugateTool;
static CWireTool wireTool;
static CTextTool textTool;
CPoint CLogiTool::c_down;
UINT CLogiTool::c_nDownFlags;
CPoint CLogiTool::c_last;
LogiShape CLogiTool::c_LogiShape = selector;
CLogiTool::CLogiTool(LogiShape LogiShape)
{
m_LogiShape = LogiShape;
c_tools.AddTail(this);
}
void CLogiTool::OnAutoScroll(CLogiView* /*pView*/, const CPoint& /*point*/, BOOL /*bBefore*/)
{
}
CLogiTool* CLogiTool::FindTool(LogiShape LogiShape)
{
POSITION pos = c_tools.GetHeadPosition();
while (pos != NULL)
{
CLogiTool* pTool = (CLogiTool*)c_tools.GetNext(pos);
if (pTool->m_LogiShape == LogiShape) return pTool;
}
return NULL;
}
void CLogiTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
pView->SetCapture();
c_nDownFlags = nFlags;
c_down = point;
pView->ClientToDoc(c_down);
c_last = c_down;
}
void CLogiTool::OnLButtonDblClk(CLogiView * /*pView*/, UINT, const CPoint& /*point*/)
{
}
void CLogiTool::OnLButtonUp(CLogiView* pView, UINT, const CPoint& point)
{
ReleaseCapture();
CPoint c_downt = c_down;
pView->DocToClient(c_downt);
if (point == c_downt) c_LogiShape = selector;
}
void CLogiTool::OnRButtonDown(CLogiView * /*pView*/, UINT, const CPoint& /*point*/)
{
}
void CLogiTool::OnMouseMove(CLogiView* pView, UINT /*nFlags*/, const CPoint& point)
{
c_last = point;
pView->ClientToDoc(c_last);
}
BOOL CLogiTool::OnSetCursor(CLogiView* /*pView*/, CWnd* /*pWnd*/, UINT /*nHitTest*/, UINT /*message*/)
{
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
return TRUE;
}
void CLogiTool::OnCancel()
{
c_LogiShape = selector;
}
////////////////////////////////////////////////////////////////////////////
// CResizeTool
enum SelectMode
{
none,
netSelect,
move,
size
}
;
SelectMode selectMode = none;
int nDragHandle;
CPoint lastPoint;
CSelectTool::CSelectTool() : CLogiTool(selector)
{
m_bUserMove = FALSE;
}
void CSelectTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
ASSERT(m_prevPositions.IsEmpty());
int io = -1;
CPoint local = point;
pView->ClientToDoc(local);
CLogiObj* pObj;
selectMode = none;
CLogiGate* pGateObj;
// If simulation is running then perform action
if ((pView->GetDocument()->m_bKeepGoing) || (pView->GetDocument()->m_bPause))
{
pGateObj = (CLogiGate*)pView->GetDocument()->ObjectAt(local, pView->m_iPage);
// If probe is enabled then check if we are on a gate
if (pView->GetDocument()->m_uProbe != 0)
{
// If we hit a gate check if we hit a node
if (pGateObj != NULL)
{
pGateObj = (CLogiGate*) pView->GetDocument()->ObjectAtContact(local, &io, pView->m_iPage);
if ((pGateObj) && (pGateObj->Node[io] != pView->GetDocument()->m_pAnodeNULL))
{
pView->GetDocument()->pAnodeProbe = pGateObj->Node[io];
pView->GetDocument()->UpdateProbe();
}
}
}
else
{
if (pGateObj != NULL)
{
if (pGateObj->IsKindOf(RUNTIME_CLASS(CLogiGate)))
{
CPoint local2 = local;
local2 -= pGateObj->m_position.TopLeft();
// Queue the Mouse Message
pView->GetDocument()->MouseMessageQueue.AddTail(new AMouseMessage(pGateObj, pView, TRUE, local2));
}
}
}
m_cpDownPoint = local;
pView->SetCapture();
return;
}
// See if the click was on an object, select and start move if so
if (selectMode == none)
{
pObj = pView->GetDocument()->ObjectAt(local, pView->m_iPage);
if (pObj != NULL)
{
pGateObj = (CLogiGate*)pView->GetDocument()->ObjectAtContact(local, &io, pView->m_iPage);
if ((pGateObj) && (pGateObj->Node[io]))
{
selectMode = move;
m_bUserMove = TRUE; // positions to be saved for undo/redo
// select all connected wires
if ((nFlags & MK_SHIFT) == 0) pView->Select(NULL);
for (auto it = pGateObj->Wire[io].begin(), end = pGateObj->Wire[io].end(); it != end; ++it)
{
CLogiWire* CurrentWire = (CLogiWire*) *it;
pView->Select(CurrentWire, TRUE);
}
}
else
{
selectMode = move;
m_bUserMove = TRUE; // positions to be saved for undo/redo
if (!pView->IsSelected(pObj))
{
pView->Select(pObj, (nFlags & MK_SHIFT) != 0);
}
else
{
if ((nFlags & MK_SHIFT) != 0)
{
pView->Deselect(pObj);
}
}
// Ctrl+Click clones the selection...
if ((nFlags & MK_CONTROL) != 0) pView->CloneSelection();
}
}
}
// Click on background, start a net-selection
if (selectMode == none)
{
if ((nFlags & MK_SHIFT) == 0) pView->Select(NULL);
selectMode = netSelect;
CClientDC dc(pView);
CRect rect(point.x, point.y, point.x, point.y);
rect.NormalizeRect();
// do DP->LP->DP conversion to avoid rounding error
pView->ClientToDoc(rect);
pView->DocToClient(rect);
dc.DrawFocusRect(rect);
}
lastPoint = local;
CLogiTool::OnLButtonDown(pView, nFlags, point);
}
void CSelectTool::OnLButtonDblClk(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint local = point;
pView->ClientToDoc(local);
CLogiGate* pGateObj;
// If simulation is running then perform action
if ((pView->GetDocument()->m_bKeepGoing) || (pView->GetDocument()->m_bPause))
{
pGateObj = (CLogiGate*)pView->GetDocument()->ObjectAt(m_cpDownPoint, pView->m_iPage);
if (pGateObj != NULL)
{
if (pGateObj->IsKindOf(RUNTIME_CLASS(CLogiGate)))
{
CPoint local2 = local;
local2 -= pGateObj->m_position.TopLeft();
// We still seem to get a single down and up so just add one more pair
pView->GetDocument()->MouseMessageQueue.AddTail(new AMouseMessage(pGateObj, pView, FALSE, local2));
pView->GetDocument()->MouseMessageQueue.AddTail(new AMouseMessage(pGateObj, pView, TRUE, local2));
}
}
return;
}
// "Normal" DblClk opens properties
if (pView->m_selection.GetCount() == 1) ((CLogiObj*)pView->m_selection.GetHead())->OnOpen(pView);
CLogiTool::OnLButtonDblClk(pView, nFlags, point);
}
void CSelectTool::OnLButtonUp(CLogiView* pView, UINT nFlags, const CPoint& point)
{
POSITION pos;
// Save any stored positions of objects moved for undo/redo
if (!m_prevPositions.IsEmpty())
{
pView->GetDocument()->m_undo.BeginTransaction("Move");
for (pos = m_prevPositions.GetHeadPosition(); pos != NULL; )
{
CPreviousPosition *pPrev = (CPreviousPosition *) m_prevPositions.GetNext(pos);
pView->GetDocument()->m_undo.PushMove(pPrev->m_pLogiObj, pPrev->m_rect);
delete pPrev;
}
pView->GetDocument()->m_undo.EndTransaction("Move");
m_prevPositions.RemoveAll();
}
m_bUserMove = FALSE; // no longer moving
CPoint local = point;
pView->ClientToDoc(local);
CLogiGate* pGateObj;
// If simulation is running then perform action
if ((pView->GetDocument()->m_bKeepGoing) || (pView->GetDocument()->m_bPause))
{
if (pView->GetDocument()->m_uProbe != 0)
{
pView->GetDocument()->m_uProbe = IDC_PROBE_NULL;
SetCursor(AfxGetApp()->LoadCursor(pView->GetDocument()->m_uProbe));
}
else
{
pGateObj = (CLogiGate*)pView->GetDocument()->ObjectAt(m_cpDownPoint, pView->m_iPage);
if (pGateObj != NULL)
{
if (pGateObj->IsKindOf(RUNTIME_CLASS(CLogiGate)))
{
CPoint local2 = m_cpDownPoint;
local2 -= pGateObj->m_position.TopLeft();
// Queue the Mouse Message
pView->GetDocument()->MouseMessageQueue.AddTail(new AMouseMessage(pGateObj, pView, FALSE, local2));
}
}
}
ReleaseCapture();
return;
}
if (pView->GetCapture() == pView)
{
if (selectMode == netSelect)
{
CClientDC dc(pView);
CPoint c_lastt = c_last;
CPoint c_downt = c_down;
pView->DocToClient(c_lastt);
pView->DocToClient(c_downt);
CRect rect(c_downt.x, c_downt.y, c_lastt.x, c_lastt.y);
rect.NormalizeRect();
dc.DrawFocusRect(rect);
CRect rect2(c_down.x, c_down.y, c_last.x, c_last.y);
rect2.NormalizeRect();
pView->SelectWithinRect(rect2, pView->m_iPage, TRUE);
}
else if (selectMode != none)
{
pView->GetDocument()->UpdateAllViews(pView);
}
}
OnMouseMove(pView, nFlags, point);
CLogiTool::OnLButtonUp(pView, nFlags, point);
}
void CSelectTool::OnRButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CMenu menu;
RECT ViewRect;
if (!pView->GetDocument()->m_bKeepGoing && !pView->GetDocument()->m_bPause)
{
VERIFY(menu.LoadMenu(IDR_OBJECT_POPUP));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pView->GetWindowRect(&ViewRect);
// Use AfxGetMainWnd(), not pView, so that OnUpdate is called to
// enable/disable the menu items as needed.
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, ViewRect.left+point.x, ViewRect.top+point.y, AfxGetMainWnd());
CLogiTool::OnRButtonDown(pView, nFlags, point);
}
}
void CSelectTool::OnMouseMove(CLogiView* pView, UINT nFlags, const CPoint& point)
{
if (pView->GetDocument()->m_uProbe != 0)
{
SetCursor(AfxGetApp()->LoadCursor(pView->GetDocument()->m_uProbe));
return;
}
if (pView->GetCapture() != pView)
{
if (c_LogiShape == selector) CLogiTool::OnMouseMove(pView, nFlags, point);
return;
}
if (selectMode == netSelect)
{
if (!pView->IsAutoScrolling())
{
CClientDC dc(pView);
CPoint c_lastt = c_last;
CPoint c_downt = c_down;
pView->DocToClient(c_lastt);
pView->DocToClient(c_downt);
CRect rect(c_downt.x, c_downt.y, c_lastt.x, c_lastt.y);
rect.NormalizeRect();
dc.DrawFocusRect(rect);
// do DP->LP->DP conversion to avoid rounding error
CPoint pt = point;
pView->ClientToDoc(pt);
pView->DocToClient(pt);
rect.SetRect(c_downt.x, c_downt.y, pt.x, pt.y);
rect.NormalizeRect();
dc.DrawFocusRect(rect);
CLogiTool::OnMouseMove(pView, nFlags, point);
}
return;
}
CPoint local = point;
pView->ClientToDoc(local);
// Offset position if snap to grid mode is on
BOOL bSnapToGrid = pView->GetDocument()->GetSnapToGrid();
// If drawing single wire, do not snap it
if (selectMode == move || selectMode == size)
if (pView->m_selection.GetCount() == 1)
if (((CLogiObj *) pView->m_selection.GetHead())->m_Logishape == wire)
bSnapToGrid = FALSE;
CPoint grid = pView->GetDocument()->GetGridSizes();
if (bSnapToGrid)
local -= CPoint(local.x % grid.x - c_down.x % grid.x,
local.y % grid.y - c_down.y % grid.y);
CPoint delta = (CPoint)(local - lastPoint);
// If not internal move and first call to move since mouse button
// down, then store positions of objects before move for undo/redo.
BOOL bSavePositions = m_bUserMove && m_prevPositions.IsEmpty();
if (selectMode == move)
{
POSITION pos = pView->m_selection.GetHeadPosition();
while (pos != NULL)
{
CLogiObj* pObj = (CLogiObj*)pView->m_selection.GetNext(pos);
if (pObj->m_Logishape != wire)
{
CRect position = pObj->m_position;
if (bSavePositions)
m_prevPositions.AddTail(new CPreviousPosition(pObj, position));
// Before moving, ensure that the item is aligned
// with the grid if Snap to Grid mode is in use
if (bSnapToGrid)
position -= CPoint(position.left % grid.x, position.top % grid.y);
position += delta;
pObj->MoveTo(position, pView);
}
}
}
else if (nDragHandle != 0)
{
POSITION pos = pView->m_selection.GetHeadPosition();
while (pos != NULL)
{
CLogiObj* pObj = (CLogiObj*)pView->m_selection.GetNext(pos);
pObj->MoveHandleTo(nDragHandle, local, pView);
}
}
lastPoint = local;
c_last = point;
pView->ClientToDoc(c_last);
if (c_LogiShape == selector) CLogiTool::OnMouseMove(pView, nFlags, point);
}
BOOL CSelectTool::OnSetCursor(CLogiView* pView, CWnd* /*pWnd*/, UINT /*nHitTest*/, UINT /*message*/)
{
if (pView->GetDocument()->m_uProbe != 0)
SetCursor(AfxGetApp()->LoadCursor(pView->GetDocument()->m_uProbe));
else
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
return TRUE;
}
void CSelectTool::OnAutoScroll(CLogiView* pView, const CPoint& point, BOOL bBefore)
{
if (selectMode == netSelect)
{
CClientDC dc(pView);
CPoint c_lastt = c_last;
CPoint c_downt = c_down;
pView->DocToClient(c_lastt);
pView->DocToClient(c_downt);
if (bBefore)
{
CRect rect(c_downt.x, c_downt.y, c_lastt.x, c_lastt.y);
rect.NormalizeRect();
dc.DrawFocusRect(rect);
}
else
{
// do DP->LP->DP conversion to avoid rounding error conversion to avoid rounding error
CPoint pt = point;
pView->ClientToDoc(pt);
pView->DocToClient(pt);
CRect rect(c_downt.x, c_downt.y, pt.x, pt.y);
rect.NormalizeRect();
dc.DrawFocusRect(rect);
c_last = point;
pView->ClientToDoc(c_last);
}
}
return;
}
////////////////////////////////////////////////////////////////////////////
// CGateTool
CGateTool::CGateTool(LogiShape nLogiShape) : CLogiTool(nLogiShape)
{
}
void CGateTool::OnLButtonDblClk(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CLogiTool::OnLButtonDblClk(pView, nFlags, point);
}
void CGateTool::OnLButtonUp(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint c_downt = c_down;
pView->DocToClient(c_downt);
if ((point == c_downt) && 0)
{
// Don't create empty objects...
CLogiObj *pObj = (CLogiObj*)pView->m_selection.GetTail();
pView->GetDocument()->Remove(pObj, FALSE);
delete pObj;
selectTool.OnLButtonDown(pView, nFlags, point); // try a select!
}
// When dropping a new gate unselect
pView->Select(NULL);
selectTool.OnLButtonUp(pView, nFlags, point);
}
void CGateTool::OnRButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CLogiTool::OnRButtonDown(pView, nFlags, point);
}
void CGateTool::OnMouseMove(CLogiView* pView, UINT nFlags, const CPoint& point)
{
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
selectTool.OnMouseMove(pView, nFlags, point);
}
BOOL CGateTool::OnSetCursor(CLogiView* /*pView*/, CWnd* /*pWnd*/, UINT /*nHitTest*/, UINT /*message*/)
{
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
return TRUE;
}
////////////////////////////////////////////////////////////////////////////
// CANDGateTool
CANDGateTool::CANDGateTool() : CGateTool(andgate)
{
}
void CANDGateTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint oldpoint = point;
oldpoint.x += BITX;
oldpoint.y -= BITY;
CLogiTool::OnLButtonDown(pView, nFlags, oldpoint);
CPoint local = oldpoint;
pView->ClientToDoc(local);
CLogiGate* pObj = new CLogiANDGate(CRect(local, CSize(BITX,-BITY)), "AND", pView->m_iPage, pView->GetDocument());
pView->GetDocument()->Add(pObj);
pView->Select(pObj);
selectMode = move;
nDragHandle = 8;
lastPoint = local;
OnMouseMove(pView, nFlags, point);
}
////////////////////////////////////////////////////////////////////////////
// CXORGateTool
CXORGateTool::CXORGateTool() : CGateTool(xorgate)
{
}
void CXORGateTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint oldpoint = point;
oldpoint.x += BITX;
oldpoint.y -= BITY;
CLogiTool::OnLButtonDown(pView, nFlags, oldpoint);
CPoint local = oldpoint;
pView->ClientToDoc(local);
CLogiGate* pObj = new CLogiXORGate(CRect(local, CSize(BITX,-BITY)), "XOR", pView->m_iPage, pView->GetDocument());
pView->GetDocument()->Add(pObj);
pView->Select(pObj);
selectMode = move;
nDragHandle = 8;
lastPoint = local;
OnMouseMove(pView, nFlags, point);
}
////////////////////////////////////////////////////////////////////////////
// CORGateTool
CORGateTool::CORGateTool() : CGateTool(orgate)
{
}
void CORGateTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint oldpoint = point;
oldpoint.x += BITX;
oldpoint.y -= BITY;
CLogiTool::OnLButtonDown(pView, nFlags, oldpoint);
CPoint local = oldpoint;
pView->ClientToDoc(local);
CLogiGate* pObj = new CLogiORGate(CRect(local, CSize(BITX,-BITY)), "OR", pView->m_iPage, pView->GetDocument());
pView->GetDocument()->Add(pObj);
pView->Select(pObj);
selectMode = move;
nDragHandle = 8;
lastPoint = local;
OnMouseMove(pView, nFlags, point);
}
////////////////////////////////////////////////////////////////////////////
// CINVERTGateTool
CINVERTGateTool::CINVERTGateTool() : CGateTool(invertgate)
{
}
void CINVERTGateTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint oldpoint = point;
oldpoint.x += BITX;
oldpoint.y -= BITY;
CLogiTool::OnLButtonDown(pView, nFlags, oldpoint);
CPoint local = oldpoint;
pView->ClientToDoc(local);
CLogiGate* pObj = new CLogiINVERTGate(CRect(local, CSize(BITX,-BITY)), "INVERT", pView->m_iPage, pView->GetDocument());
pView->GetDocument()->Add(pObj);
pView->Select(pObj);
selectMode = move;
nDragHandle = 8;
lastPoint = local;
OnMouseMove(pView, nFlags, point);
}
////////////////////////////////////////////////////////////////////////////
// CTristateGateTool
CTristateGateTool::CTristateGateTool() : CGateTool(tristategate)
{
}
void CTristateGateTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint oldpoint = point;
oldpoint.x += BITX;
oldpoint.y -= BITY;
CLogiTool::OnLButtonDown(pView, nFlags, oldpoint);
CPoint local = oldpoint;
pView->ClientToDoc(local);
CLogiGate* pObj = new CLogiTristateGate(CRect(local, CSize(BITX,-BITY)), "TRISTATE", pView->m_iPage, pView->GetDocument());
pView->GetDocument()->Add(pObj);
pView->Select(pObj);
selectMode = move;
nDragHandle = 8;
lastPoint = local;
OnMouseMove(pView, nFlags, point);
}
////////////////////////////////////////////////////////////////////////////
// CBusGateTool
CBusGateTool::CBusGateTool() : CGateTool(busgate)
{
}
void CBusGateTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint oldpoint = point;
oldpoint.x += BITX;
oldpoint.y -= BITY;
CLogiTool::OnLButtonDown(pView, nFlags, oldpoint);
CPoint local = oldpoint;
pView->ClientToDoc(local);
CLogiGate* pObj = new CLogiBusGate(CRect(local, CSize(BITX,-BITY)), "BUS", pView->m_iPage, pView->GetDocument());
pView->GetDocument()->Add(pObj);
pView->Select(pObj);
selectMode = move;
nDragHandle = 8;
lastPoint = local;
OnMouseMove(pView, nFlags, point);
}
////////////////////////////////////////////////////////////////////////////
// COscillatorGateTool
COscillatorGateTool::COscillatorGateTool() : CGateTool(oscillatorgate)
{
}
void COscillatorGateTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint oldpoint = point;
oldpoint.x += BITX;
oldpoint.y -= BITY;
CLogiTool::OnLButtonDown(pView, nFlags, oldpoint);
CPoint local = oldpoint;
pView->ClientToDoc(local);
CLogiGate* pObj = new CLogiOscillatorGate(CRect(local, CSize(BITX,-BITY)), "OSCILLATOR", pView->m_iPage, pView->GetDocument());
pView->GetDocument()->Add(pObj);
pView->Select(pObj);
selectMode = move;
nDragHandle = 8;
lastPoint = local;
OnMouseMove(pView, nFlags, point);
}
////////////////////////////////////////////////////////////////////////////
// CClockGateTool
CClockGateTool::CClockGateTool() : CGateTool(clockgate)
{
}
void CClockGateTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint oldpoint = point;
oldpoint.x += BITX;
oldpoint.y -= BITY;
CLogiTool::OnLButtonDown(pView, nFlags, oldpoint);
CPoint local = oldpoint;
pView->ClientToDoc(local);
CLogiGate* pObj = new CLogiClockGate(CRect(local, CSize(BITX,-BITY)), "CLOCK", pView->m_iPage, pView->GetDocument());
pView->GetDocument()->Add(pObj);
pView->Select(pObj);
selectMode = move;
nDragHandle = 8;
lastPoint = local;
OnMouseMove(pView, nFlags, point);
}
////////////////////////////////////////////////////////////////////////////
// CTimerGateTool
CTimerGateTool::CTimerGateTool() : CGateTool(timergate)
{
}
void CTimerGateTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint oldpoint = point;
oldpoint.x += BITX;
oldpoint.y -= BITY;
CLogiTool::OnLButtonDown(pView, nFlags, oldpoint);
CPoint local = oldpoint;
pView->ClientToDoc(local);
CLogiGate* pObj = new CLogiTimerGate(CRect(local, CSize(BITX,-BITY)), "TIMER", pView->m_iPage, pView->GetDocument());
pView->GetDocument()->Add(pObj);
pView->Select(pObj);
selectMode = move;
nDragHandle = 8;
lastPoint = local;
OnMouseMove(pView, nFlags, point);
}
////////////////////////////////////////////////////////////////////////////
// CLedGateTool
CLedGateTool::CLedGateTool() : CGateTool(ledgate)
{
}
void CLedGateTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint oldpoint = point;
oldpoint.x += BITX;
oldpoint.y -= BITY;
CLogiTool::OnLButtonDown(pView, nFlags, oldpoint);
CPoint local = oldpoint;
pView->ClientToDoc(local);
CLogiGate* pObj = new CLogiLedGate(CRect(local, CSize(BITX,-BITY)), "LED", pView->m_iPage, pView->GetDocument());
pView->GetDocument()->Add(pObj);
pView->Select(pObj);
selectMode = move;
nDragHandle = 8;
lastPoint = local;
OnMouseMove(pView, nFlags, point);
}
////////////////////////////////////////////////////////////////////////////
// CSwitchGateTool
CSwitchGateTool::CSwitchGateTool() : CGateTool(switchgate)
{
}
void CSwitchGateTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint oldpoint = point;
oldpoint.x += BITX;
oldpoint.y -= BITY;
CLogiTool::OnLButtonDown(pView, nFlags, oldpoint);
CPoint local = oldpoint;
pView->ClientToDoc(local);
CLogiGate* pObj = new CLogiSwitchGate(CRect(local, CSize(BITX,-BITY)), "SWITCH", pView->m_iPage, pView->GetDocument());
pView->GetDocument()->Add(pObj);
pView->Select(pObj);
selectMode = move;
nDragHandle = 8;
lastPoint = local;
OnMouseMove(pView, nFlags, point);
}
////////////////////////////////////////////////////////////////////////////
// CSelectGateTool
CSelectGateTool::CSelectGateTool() : CGateTool(selectgate)
{
}
void CSelectGateTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint oldpoint = point;
oldpoint.x += BITX;
oldpoint.y -= BITY;
CLogiTool::OnLButtonDown(pView, nFlags, oldpoint);
CPoint local = oldpoint;
pView->ClientToDoc(local);
CLogiGate* pObj = new CLogiSelectGate(CRect(local, CSize(BITX,-BITY)), "SELECT", pView->m_iPage, pView->GetDocument());
pView->GetDocument()->Add(pObj);
pView->Select(pObj);
selectMode = move;
nDragHandle = 8;
lastPoint = local;
OnMouseMove(pView, nFlags, point);
}
////////////////////////////////////////////////////////////////////////////
// CBuzzerGateTool
CBuzzerGateTool::CBuzzerGateTool() : CGateTool(buzzergate)
{
}
void CBuzzerGateTool::OnLButtonDown(CLogiView* pView, UINT nFlags, const CPoint& point)
{
CPoint oldpoint = point;
oldpoint.x += BITX;
oldpoint.y -= BITY;
CLogiTool::OnLButtonDown(pView, nFlags, oldpoint);
CPoint local = oldpoint;
pView->ClientToDoc(local);
CLogiGate* pObj = new CLogiBuzzerGate(CRect(local, CSize(BITX,-BITY)), "BUZZER", pView->m_iPage, pView->GetDocument());
pView->GetDocument()->Add(pObj);
pView->Select(pObj);
selectMode = move;
nDragHandle = 8;
lastPoint = local;
OnMouseMove(pView, nFlags, point);
}
////////////////////////////////////////////////////////////////////////////
// CNULLGateTool