You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

607 lines
20 KiB

3 years ago
11 years ago
11 years ago
11 years ago
6 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2013-2016 CERN
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * @author Maciej Suminski <maciej.suminski@cern.ch>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. #ifndef __PCB_ACTIONS_H
  27. #define __PCB_ACTIONS_H
  28. #include <layer_ids.h>
  29. #include <tool/tool_action.h>
  30. #include <tool/actions.h>
  31. enum class ZONE_MODE
  32. {
  33. ADD, ///< Add a new zone/keepout with fresh settings
  34. CUTOUT, ///< Make a cutout to an existing zone
  35. SIMILAR, ///< Add a new zone with the same settings as an existing one
  36. GRAPHIC_POLYGON
  37. };
  38. /**
  39. * Gather all the actions that are shared by tools.
  40. *
  41. * The instance of PCB_ACTIONS is created inside of #ACTION_MANAGER object that registers
  42. * the actions.
  43. */
  44. class PCB_ACTIONS : public ACTIONS
  45. {
  46. public:
  47. /**
  48. * Translate a layer ID into the action that switches to that layer.
  49. *
  50. * @param aLayerID is the layer to switch to
  51. * @return the action that will switch to the specified layer
  52. */
  53. static TOOL_ACTION* LayerIDToAction( PCB_LAYER_ID aLayerID );
  54. // Selection Tool
  55. /// Activation of the selection tool
  56. static TOOL_ACTION selectionActivate;
  57. /// Select a single item under the cursor position
  58. static TOOL_ACTION selectionCursor;
  59. /// Clear the current selection
  60. static TOOL_ACTION selectionClear;
  61. /// Select an item (specified as the event parameter).
  62. static TOOL_ACTION selectItem;
  63. static TOOL_ACTION unselectItem;
  64. static TOOL_ACTION reselectItem;
  65. /// Select a list of items (specified as the event parameter)
  66. static TOOL_ACTION selectItems;
  67. static TOOL_ACTION unselectItems;
  68. /// Sets selection to specified items, zooms to fit, if enabled
  69. static TOOL_ACTION syncSelection;
  70. /// Sets selection to specified items with connected nets, zooms to fit, if enabled
  71. static TOOL_ACTION syncSelectionWithNets;
  72. /// Run a selection menu to select from a list of items
  73. static TOOL_ACTION selectionMenu;
  74. /// Select tracks between junctions or expands an existing selection to pads or the
  75. /// entire connection.
  76. static TOOL_ACTION selectConnection;
  77. /// Removes all tracks from the selected items to the first pad
  78. static TOOL_ACTION unrouteSelected;
  79. /// Select all connections belonging to a single net.
  80. static TOOL_ACTION selectNet;
  81. /// Remove all connections belonging to a single net from the active selection
  82. static TOOL_ACTION deselectNet;
  83. /// Select unconnected footprints from ratsnest of selection
  84. static TOOL_ACTION selectUnconnected;
  85. /// Select and move nearest unconnected footprint from ratsnest of selection
  86. static TOOL_ACTION grabUnconnected;
  87. /// Select all components on sheet from Eeschema crossprobing.
  88. static TOOL_ACTION selectOnSheetFromEeschema;
  89. /// Select all components on the same sheet as the selected footprint.
  90. static TOOL_ACTION selectSameSheet;
  91. /// Select symbols/pins on schematic corresponding to selected footprints/pads.
  92. static TOOL_ACTION selectOnSchematic;
  93. /// Filter the items in the current selection (invokes dialog)
  94. static TOOL_ACTION filterSelection;
  95. /// move or drag an item
  96. static TOOL_ACTION move;
  97. /// move items one-by-one
  98. static TOOL_ACTION moveIndividually;
  99. /// move with a reference point
  100. static TOOL_ACTION moveWithReference;
  101. /// copy command with manual reference point selection
  102. static TOOL_ACTION copyWithReference;
  103. /// Rotation of selected objects
  104. static TOOL_ACTION rotateCw;
  105. static TOOL_ACTION rotateCcw;
  106. /// Flipping of selected objects
  107. static TOOL_ACTION flip;
  108. /// Mirroring of selected items
  109. static TOOL_ACTION mirrorH;
  110. static TOOL_ACTION mirrorV;
  111. /// Swapping of selected items
  112. static TOOL_ACTION swap;
  113. /// Pack and start moving selected footprints
  114. static TOOL_ACTION packAndMoveFootprints;
  115. // Compound Action Tool actions, e.g. Move Individually
  116. static TOOL_ACTION skip;
  117. /// Update selected tracks & vias to the current track & via dimensions
  118. static TOOL_ACTION changeTrackWidth;
  119. /// Fillet (i.e. adds an arc tangent to) all selected straight tracks by a user defined radius
  120. static TOOL_ACTION filletTracks;
  121. /// Fillet (i.e. adds an arc tangent to) all selected straight lines by a user defined radius
  122. static TOOL_ACTION filletLines;
  123. /// Chamfer (i.e. adds a straight line) all selected straight lines by a user defined setback
  124. static TOOL_ACTION chamferLines;
  125. /// Add "dogbone" corners to selected lines to allow routing with a cutter radius
  126. static TOOL_ACTION dogboneCorners;
  127. /// Connect selected shapes, possibly extending or cutting them, or adding extra geometry
  128. static TOOL_ACTION healShapes;
  129. /// Extend selected lines to meet at a point
  130. static TOOL_ACTION extendLines;
  131. /// Simplify polygon outlines
  132. static TOOL_ACTION simplifyPolygons;
  133. /// Create outset items from selection
  134. static TOOL_ACTION outsetItems;
  135. /// Merge multiple polygons into a single polygon
  136. static TOOL_ACTION mergePolygons;
  137. /// Subtract polygons from other polygons
  138. static TOOL_ACTION subtractPolygons;
  139. /// Intersection of multiple polygons
  140. static TOOL_ACTION intersectPolygons;
  141. /// Activation of the edit tool
  142. static TOOL_ACTION properties;
  143. /// Activation of the exact move tool
  144. static TOOL_ACTION moveExact;
  145. /// Activation of the duplication tool with incrementing (e.g. pad number)
  146. static TOOL_ACTION duplicateIncrement;
  147. /// Deleting a BOARD_ITEM
  148. static TOOL_ACTION remove;
  149. static TOOL_ACTION deleteFull;
  150. static TOOL_ACTION selectLayerPair;
  151. /// Break a single track into two segments at the cursor
  152. static TOOL_ACTION breakTrack;
  153. static TOOL_ACTION drag45Degree;
  154. static TOOL_ACTION dragFreeAngle;
  155. // Drawing Tool Activations
  156. static TOOL_ACTION drawLine;
  157. static TOOL_ACTION drawPolygon;
  158. static TOOL_ACTION drawRectangle;
  159. static TOOL_ACTION drawCircle;
  160. static TOOL_ACTION drawArc;
  161. static TOOL_ACTION drawBezier;
  162. static TOOL_ACTION placeReferenceImage;
  163. static TOOL_ACTION placeText;
  164. static TOOL_ACTION drawTextBox;
  165. static TOOL_ACTION drawTable;
  166. static TOOL_ACTION spacingIncrease;
  167. static TOOL_ACTION spacingDecrease;
  168. static TOOL_ACTION amplIncrease;
  169. static TOOL_ACTION amplDecrease;
  170. static TOOL_ACTION lengthTunerSettings;
  171. static TOOL_ACTION drawAlignedDimension;
  172. static TOOL_ACTION drawCenterDimension;
  173. static TOOL_ACTION drawRadialDimension;
  174. static TOOL_ACTION drawOrthogonalDimension;
  175. static TOOL_ACTION drawLeader;
  176. static TOOL_ACTION drawZone;
  177. static TOOL_ACTION drawVia;
  178. static TOOL_ACTION drawRuleArea;
  179. static TOOL_ACTION drawZoneCutout;
  180. static TOOL_ACTION drawSimilarZone;
  181. static TOOL_ACTION placeCharacteristics;
  182. static TOOL_ACTION placeStackup;
  183. static TOOL_ACTION placeFootprint;
  184. static TOOL_ACTION placeImportedGraphics;
  185. static TOOL_ACTION setAnchor;
  186. static TOOL_ACTION deleteLastPoint;
  187. static TOOL_ACTION closeOutline;
  188. /// Increase width of currently drawn line
  189. static TOOL_ACTION incWidth;
  190. /// Decrease width of currently drawn line
  191. static TOOL_ACTION decWidth;
  192. /// Switch posture when drawing arc
  193. static TOOL_ACTION arcPosture;
  194. /// Switch between dimension arrow directions
  195. static TOOL_ACTION changeDimensionArrows;
  196. /// Snapping controls
  197. static TOOL_ACTION magneticSnapActiveLayer;
  198. static TOOL_ACTION magneticSnapAllLayers;
  199. static TOOL_ACTION magneticSnapToggle;
  200. // Push and Shove Router Tool
  201. /// Activation of the Push and Shove router
  202. static TOOL_ACTION routeSingleTrack;
  203. /// Activation of the Push and Shove router (differential pair mode)
  204. static TOOL_ACTION routeDiffPair;
  205. static TOOL_ACTION tuneSingleTrack;
  206. static TOOL_ACTION tuneDiffPair;
  207. static TOOL_ACTION tuneSkew;
  208. static TOOL_ACTION routerUndoLastSegment;
  209. static TOOL_ACTION routerContinueFromEnd;
  210. static TOOL_ACTION routerAttemptFinish;
  211. static TOOL_ACTION routerRouteSelected;
  212. static TOOL_ACTION routerRouteSelectedFromEnd;
  213. static TOOL_ACTION routerAutorouteSelected;
  214. /// Activation of the Push and Shove settings dialogs
  215. static TOOL_ACTION routerSettingsDialog;
  216. static TOOL_ACTION routerDiffPairDialog;
  217. /// Actions to enable switching modes via hotkey assignments
  218. static TOOL_ACTION routerHighlightMode;
  219. static TOOL_ACTION routerShoveMode;
  220. static TOOL_ACTION routerWalkaroundMode;
  221. static TOOL_ACTION cycleRouterMode;
  222. /// Activation of the Push and Shove router (inline dragging mode)
  223. static TOOL_ACTION routerInlineDrag;
  224. /// Generator tool
  225. static TOOL_ACTION regenerateAllTuning;
  226. static TOOL_ACTION regenerateAll;
  227. static TOOL_ACTION regenerateSelected;
  228. static TOOL_ACTION regenerateItem;
  229. static TOOL_ACTION genStartEdit;
  230. static TOOL_ACTION genUpdateEdit;
  231. static TOOL_ACTION genPushEdit;
  232. static TOOL_ACTION genRevertEdit;
  233. static TOOL_ACTION genRemove;
  234. static TOOL_ACTION generatorsShowManager;
  235. // Point Editor
  236. static TOOL_ACTION pointEditorAddCorner;
  237. static TOOL_ACTION pointEditorRemoveCorner;
  238. static TOOL_ACTION pointEditorChamferCorner;
  239. static TOOL_ACTION pointEditorArcKeepCenter;
  240. static TOOL_ACTION pointEditorArcKeepEndpoint;
  241. static TOOL_ACTION pointEditorMoveCorner;
  242. static TOOL_ACTION pointEditorMoveMidpoint;
  243. // Group Tool
  244. static TOOL_ACTION groupProperties;
  245. static TOOL_ACTION pickNewGroupMember;
  246. // Placement Tool
  247. static TOOL_ACTION alignTop;
  248. static TOOL_ACTION alignBottom;
  249. static TOOL_ACTION alignLeft;
  250. static TOOL_ACTION alignRight;
  251. static TOOL_ACTION alignCenterX;
  252. static TOOL_ACTION alignCenterY;
  253. static TOOL_ACTION distributeHorizontallyCenters;
  254. static TOOL_ACTION distributeHorizontallyGaps;
  255. static TOOL_ACTION distributeVerticallyCenters;
  256. static TOOL_ACTION distributeVerticallyGaps;
  257. // Position Relative Tool
  258. static TOOL_ACTION positionRelative;
  259. static TOOL_ACTION positionRelativeInteractively;
  260. /// Selection of reference points/items
  261. static TOOL_ACTION selectItemInteractively;
  262. static TOOL_ACTION selectPointInteractively;
  263. // Display modes
  264. static TOOL_ACTION showRatsnest;
  265. static TOOL_ACTION ratsnestLineMode;
  266. static TOOL_ACTION netColorModeCycle;
  267. static TOOL_ACTION ratsnestModeCycle;
  268. static TOOL_ACTION trackDisplayMode;
  269. static TOOL_ACTION padDisplayMode;
  270. static TOOL_ACTION viaDisplayMode;
  271. static TOOL_ACTION zoneDisplayFilled;
  272. static TOOL_ACTION zoneDisplayOutline;
  273. static TOOL_ACTION zoneDisplayFractured;
  274. static TOOL_ACTION zoneDisplayTriangulated;
  275. static TOOL_ACTION zoneDisplayToggle;
  276. static TOOL_ACTION showPadNumbers;
  277. // Layer control
  278. static TOOL_ACTION layerTop;
  279. static TOOL_ACTION layerInner1;
  280. static TOOL_ACTION layerInner2;
  281. static TOOL_ACTION layerInner3;
  282. static TOOL_ACTION layerInner4;
  283. static TOOL_ACTION layerInner5;
  284. static TOOL_ACTION layerInner6;
  285. static TOOL_ACTION layerInner7;
  286. static TOOL_ACTION layerInner8;
  287. static TOOL_ACTION layerInner9;
  288. static TOOL_ACTION layerInner10;
  289. static TOOL_ACTION layerInner11;
  290. static TOOL_ACTION layerInner12;
  291. static TOOL_ACTION layerInner13;
  292. static TOOL_ACTION layerInner14;
  293. static TOOL_ACTION layerInner15;
  294. static TOOL_ACTION layerInner16;
  295. static TOOL_ACTION layerInner17;
  296. static TOOL_ACTION layerInner18;
  297. static TOOL_ACTION layerInner19;
  298. static TOOL_ACTION layerInner20;
  299. static TOOL_ACTION layerInner21;
  300. static TOOL_ACTION layerInner22;
  301. static TOOL_ACTION layerInner23;
  302. static TOOL_ACTION layerInner24;
  303. static TOOL_ACTION layerInner25;
  304. static TOOL_ACTION layerInner26;
  305. static TOOL_ACTION layerInner27;
  306. static TOOL_ACTION layerInner28;
  307. static TOOL_ACTION layerInner29;
  308. static TOOL_ACTION layerInner30;
  309. static TOOL_ACTION layerBottom;
  310. static TOOL_ACTION layerNext;
  311. static TOOL_ACTION layerPrev;
  312. static TOOL_ACTION layerAlphaInc;
  313. static TOOL_ACTION layerAlphaDec;
  314. static TOOL_ACTION layerToggle;
  315. static TOOL_ACTION layerPairPresetsCycle;
  316. // Group to link all actions that directly select layers
  317. static TOOL_ACTION_GROUP layerDirectSwitchActions();
  318. static TOOL_ACTION layerChanged; // notification
  319. static TOOL_ACTION flipBoard;
  320. // Track & via size control
  321. static TOOL_ACTION trackWidthInc;
  322. static TOOL_ACTION trackWidthDec;
  323. static TOOL_ACTION viaSizeInc;
  324. static TOOL_ACTION viaSizeDec;
  325. static TOOL_ACTION trackViaSizeChanged; // notification
  326. static TOOL_ACTION assignNetClass;
  327. // Zone actions
  328. static TOOL_ACTION zoneFill;
  329. static TOOL_ACTION zoneFillAll;
  330. static TOOL_ACTION zoneFillDirty;
  331. static TOOL_ACTION zoneUnfill;
  332. static TOOL_ACTION zoneUnfillAll;
  333. static TOOL_ACTION zoneMerge;
  334. /// Duplicate zone onto another layer
  335. static TOOL_ACTION zoneDuplicate;
  336. /// Scripting Actions
  337. static TOOL_ACTION pluginsShowFolder;
  338. // Global edit tool
  339. static TOOL_ACTION boardSetup;
  340. static TOOL_ACTION editTracksAndVias;
  341. static TOOL_ACTION editTextAndGraphics;
  342. static TOOL_ACTION editTeardrops;
  343. static TOOL_ACTION globalDeletions;
  344. static TOOL_ACTION cleanupTracksAndVias;
  345. static TOOL_ACTION cleanupGraphics;
  346. static TOOL_ACTION updateFootprint;
  347. static TOOL_ACTION updateFootprints;
  348. static TOOL_ACTION changeFootprint;
  349. static TOOL_ACTION changeFootprints;
  350. static TOOL_ACTION swapLayers;
  351. static TOOL_ACTION removeUnusedPads;
  352. static TOOL_ACTION importNetlist;
  353. static TOOL_ACTION importSpecctraSession;
  354. static TOOL_ACTION exportSpecctraDSN;
  355. static TOOL_ACTION generateGerbers;
  356. static TOOL_ACTION generateDrillFiles;
  357. static TOOL_ACTION generatePosFile;
  358. static TOOL_ACTION generateReportFile;
  359. static TOOL_ACTION generateIPC2581File;
  360. static TOOL_ACTION generateODBPPFile;
  361. static TOOL_ACTION generateD356File;
  362. static TOOL_ACTION generateBOM;
  363. static TOOL_ACTION runDRC;
  364. static TOOL_ACTION editFpInFpEditor;
  365. static TOOL_ACTION editLibFpInFpEditor;
  366. static TOOL_ACTION showLayersManager;
  367. static TOOL_ACTION showNetInspector;
  368. static TOOL_ACTION showPythonConsole;
  369. static TOOL_ACTION zonesManager;
  370. // Footprint editor tools
  371. // We don't use ACTION::new here because we need to distinguish between New Library
  372. // and New Footprint.
  373. static TOOL_ACTION newFootprint;
  374. // Create a new footprint using the Footprint Wizard
  375. static TOOL_ACTION createFootprint;
  376. static TOOL_ACTION editFootprint;
  377. static TOOL_ACTION duplicateFootprint;
  378. static TOOL_ACTION renameFootprint;
  379. static TOOL_ACTION deleteFootprint;
  380. static TOOL_ACTION cutFootprint;
  381. static TOOL_ACTION copyFootprint;
  382. static TOOL_ACTION pasteFootprint;
  383. static TOOL_ACTION importFootprint;
  384. static TOOL_ACTION exportFootprint;
  385. static TOOL_ACTION footprintProperties;
  386. static TOOL_ACTION defaultPadProperties;
  387. static TOOL_ACTION checkFootprint;
  388. /// Activation of the drawing tool (placing a PAD)
  389. static TOOL_ACTION placePad;
  390. static TOOL_ACTION explodePad;
  391. static TOOL_ACTION recombinePad;
  392. /// Tool for quick pad enumeration
  393. static TOOL_ACTION enumeratePads;
  394. /// Tool for creating an array of objects
  395. static TOOL_ACTION createArray;
  396. /// Display footprint graphics as outlines
  397. static TOOL_ACTION graphicsOutlines;
  398. /// Display texts as lines
  399. static TOOL_ACTION textOutlines;
  400. // Pad tools
  401. /// Copy the selected pad's settings to the board design settings
  402. static TOOL_ACTION copyPadSettings;
  403. /// Copy the default pad settings to the selected pad
  404. static TOOL_ACTION applyPadSettings;
  405. /// Copy the current pad's settings to other pads in the footprint or on the board
  406. static TOOL_ACTION pushPadSettings;
  407. // Microwave tools
  408. static TOOL_ACTION microwaveCreateGap;
  409. static TOOL_ACTION microwaveCreateStub;
  410. static TOOL_ACTION microwaveCreateStubArc;
  411. static TOOL_ACTION microwaveCreateFunctionShape;
  412. static TOOL_ACTION microwaveCreateLine;
  413. // Constrained drawing
  414. static TOOL_ACTION toggleHV45Mode;
  415. // Locking
  416. static TOOL_ACTION toggleLock;
  417. static TOOL_ACTION lock;
  418. static TOOL_ACTION unlock;
  419. // Grouping
  420. static TOOL_ACTION group;
  421. static TOOL_ACTION ungroup;
  422. static TOOL_ACTION removeFromGroup;
  423. static TOOL_ACTION groupEnter;
  424. static TOOL_ACTION groupLeave;
  425. // Miscellaneous
  426. static TOOL_ACTION selectionTool;
  427. static TOOL_ACTION pickerTool;
  428. static TOOL_ACTION measureTool;
  429. static TOOL_ACTION drillOrigin;
  430. static TOOL_ACTION drillResetOrigin;
  431. static TOOL_ACTION drillSetOrigin;
  432. static TOOL_ACTION appendBoard;
  433. static TOOL_ACTION showEeschema;
  434. static TOOL_ACTION boardStatistics;
  435. static TOOL_ACTION boardReannotate;
  436. static TOOL_ACTION repairBoard;
  437. static TOOL_ACTION repairFootprint;
  438. static TOOL_ACTION inspectClearance;
  439. static TOOL_ACTION inspectConstraints;
  440. static TOOL_ACTION diffFootprint;
  441. static TOOL_ACTION showFootprintAssociations;
  442. // Appearance controls
  443. static TOOL_ACTION clearHighlight; // Turns off highlight and resets previous highlight
  444. static TOOL_ACTION highlightNet; // Highlights a net by code (cross-probe highlight)
  445. static TOOL_ACTION toggleLastNetHighlight; // Toggles between current and previous highlight
  446. static TOOL_ACTION toggleNetHighlight; // Toggles between highlight off and highlight on
  447. static TOOL_ACTION highlightNetSelection; // Turns on highlight and takes net from selection
  448. static TOOL_ACTION highlightItem; // Select component via cross-probe
  449. // Ratsnest
  450. static TOOL_ACTION hideNetInRatsnest;
  451. static TOOL_ACTION showNetInRatsnest;
  452. static TOOL_ACTION localRatsnestTool;
  453. static TOOL_ACTION hideLocalRatsnest;
  454. static TOOL_ACTION updateLocalRatsnest;
  455. /// Find an item
  456. static TOOL_ACTION find;
  457. /// Find an item and start moving
  458. static TOOL_ACTION getAndPlace;
  459. static TOOL_ACTION autoplaceOffboardComponents;
  460. static TOOL_ACTION autoplaceSelectedComponents;
  461. // convert tool
  462. static TOOL_ACTION convertToPoly;
  463. static TOOL_ACTION convertToZone;
  464. static TOOL_ACTION convertToKeepout;
  465. static TOOL_ACTION convertToLines;
  466. static TOOL_ACTION convertToArc;
  467. static TOOL_ACTION convertToTracks;
  468. /// Drag and drop
  469. static TOOL_ACTION ddAppendBoard;
  470. static TOOL_ACTION ddImportFootprint;
  471. static TOOL_ACTION repeatLayout;
  472. static TOOL_ACTION generatePlacementRuleAreas;
  473. };
  474. class PCB_EVENTS
  475. {
  476. public:
  477. // These are functions that access the underlying event because the event constructor
  478. // needs the ACTION::cancelInteractive action, so we must
  479. /// Hotkey feedback
  480. static const TOOL_EVENT& SnappingModeChangedByKeyEvent();
  481. static const TOOL_EVENT& LayerPairPresetChangedByKeyEvent();
  482. };
  483. #endif