FreeCAD
1# /***************************************************************************
2# * Copyright (c) 2023 David Friedli <david[at]friedli-be.ch> *
3# * *
4# * This file is part of FreeCAD. *
5# * *
6# * FreeCAD is free software: you can redistribute it and/or modify it *
7# * under the terms of the GNU Lesser General Public License as *
8# * published by the Free Software Foundation, either version 2.1 of the *
9# * License, or (at your option) any later version. *
10# * *
11# * FreeCAD is distributed in the hope that it will be useful, but *
12# * WITHOUT ANY WARRANTY; without even the implied warranty of *
13# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14# * Lesser General Public License for more details. *
15# * *
16# * You should have received a copy of the GNU Lesser General Public *
17# * License along with FreeCAD. If not, see *
18# * <https://www.gnu.org/licenses/>. *
19# * *
20# **************************************************************************/
21
22from abc import ABC, abstractmethod, abstractclassmethod23from typing import List, Tuple24
25
26class MeasureBasePython(ABC):27
28@abstractclassmethod29def isValidSelection(cls, selection):30"""Returns True if the given selection is valid for this measurement"""31pass32
33@abstractclassmethod34def isPrioritySelection(cls, selection):35"""Returns True if creation of this measurement should be prioritized over other measurements for the given selection"""36pass37
38@abstractclassmethod39def getInputProps(cls) -> Tuple[str]:40"""Returns all properties that the measurement's result depends on"""41return ()42
43@abstractmethod44def getSubject(self, obj) -> Tuple:45"""Returns all objects that are measured, this is used to autohide the measurement if the relevant elements are not visible"""46return []47
48@abstractmethod49def parseSelection(self, obj, selection):50"""Sets the measurements properties from the given selection"""51pass52