-
Notifications
You must be signed in to change notification settings - Fork 0
/
orthogonal_alignment.cpp
106 lines (86 loc) · 4 KB
/
orthogonal_alignment.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
/*******************************************************************************
# Macro Name: orthogonal_alignment.cpp #
# Purpose: Uses basepoints to move objects to align orthogonally #
# #
# Contact: Support@eda-solutions.com #
# #
# Please use this script at your own discretion and responsbility. Eventhough #
# This script was tested and passed the QA criteria to meet the intended #
# specifications and behaviors upon request, the user remains the primary #
# responsible for the sanity of the results produced by the script. #
# The user is always advised to check the imported design and make sure the #
# correct data is present. #
# #
# For further support or questions, please e-mail support@eda-solutions.com #
################################################################################
# --------------------------
# Installation:-
# --------------------------
# --------------------------
# Usage:-
# --------------------------
# --------------------------
# Notes:
# This script is bound to the hotkey Ctrl + 1 for Horizontal alignment, Ctrl + 2 for Vertical alignment.
# The first aspect must already be selected and have the curser over where the first base point should be.
# --------------------------
################################################################################
* Revision History:
* 4 Sept 2023 Generated by L-Edit
*
* Please note this macro is generated as an example and the user takes full
* responsibility in using it in the final design.
*******************************************************************************/
#include <cstdlib>
#include <cstdarg>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#define EXCLUDE_LEDIT_LEGACY_UPI
#include <ldata.h>
extern "C" {
int UPI_Entry_Point(void);
void VertBP(void);
void HorzBP(void);
}
void MoveBP(bool bVert)
{
LCell pCell = LCell_GetVisible(); //Gets selected cell
if (!pCell) { //Check if a cell is open
LDialog_MsgBox("No active open cell, please open a cell first.");
return;
}
if (!LSelection_GetList()) { //Check if there is an object selected
LDialog_MsgBox("Nothing is selected. Please select an object first.");
return;
}
LApp_SetBasePointMode(LTRUE); //Changed to basepoint mode
LPoint pt0 = LCursor_GetPositionEx99(LTRUE,LFALSE, bVert?"V-alignment: select first aspect":"H-alignment: select first aspect"); //Gets the current curser position
LCell_SetBasePoint(pCell, pt0.x, pt0.y); //Sets the basepoint of the first aspect
LSelection_Cut(); //Cuts the selection and saves to clipboard
LCell_SetBasePoint(pCell,0,0);
LApp_SetBasePointMode(LTRUE); //Base point mode on
LPoint pt1 = LCursor_GetPositionEx99(LTRUE,LTRUE,bVert?"V-alignment: select second aspect":"H-alignment: select second aspect"); //Coords of the aspect of the second object
LCell_SetBasePoint(pCell, bVert?pt0.x:pt1.x, bVert?pt1.y:pt0.y); //Setting the base point to achieve alignment
LSelection_Paste(); //Pastes the first aspect aligned orthogonally with the second aspect
LApp_SetBasePointMode(LFALSE); //Base point mode off
//if (pt1.x == WORLD_INVALID)
// return;
LDisplay_Refresh();
}
void VertBP(void)
{
MoveBP(true);
}
void HorzBP(void)
{
MoveBP(false);
}
int UPI_Entry_Point(void)
{
LMacro_BindToMenuAndHotKey_v9_30("Tools", "Ctrl+1", "Horizontal BasePoint Move", "HorzBP", NULL /*hotkey category*/); //Binds to key
LMacro_BindToMenuAndHotKey_v9_30("Tools", "Ctrl+2", "Vertical BasePoint Move", "VertBP", NULL /*hotkey category*/); //Binds to key
return 1;
}