Coverage for backend/django/flowsheetInternals/graphicData/models/graphicObjectModel.py: 100%

31 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2026-07-22 05:22 +0000

1from types import MappingProxyType 

2from typing import TYPE_CHECKING 

3from django.db import models 

4from core.auxiliary.enums import Status 

5from core.managers import AccessControlManager, AllFlowsheetStatesManager 

6from core.auxiliary.models.FlowsheetHistoryModel import FlowsheetHistoryModel 

7 

8if TYPE_CHECKING: 

9 from core.auxiliary.models.Flowsheet import Flowsheet 

10 from flowsheetInternals.unitops.models.SimulationObject import SimulationObject 

11 from flowsheetInternals.graphicData.models.groupingModel import Grouping 

12 

13 

14class GraphicObject(FlowsheetHistoryModel, models.Model): 

15 flowsheet_state = models.ForeignKey( 

16 "core_auxiliary.FlowsheetState", 

17 on_delete=models.CASCADE, 

18 related_name="GraphicObjects", 

19 ) 

20 simulationObject = models.ForeignKey( 

21 "flowsheetInternals_unitops.SimulationObject", 

22 on_delete=models.CASCADE, 

23 related_name="graphicObject", 

24 null=True, 

25 ) 

26 visible = models.BooleanField(default=True) 

27 x = models.FloatField(default=0) 

28 y = models.FloatField(default=0) 

29 height = models.FloatField(default=0) 

30 width = models.FloatField(default=0) 

31 rotation = models.IntegerField(default=0) 

32 group = models.ForeignKey( 

33 "flowsheetInternals_graphicData.Grouping", 

34 on_delete=models.CASCADE, 

35 related_name="graphicObjects", 

36 null=True, 

37 ) 

38 flipped = models.BooleanField(default=False) 

39 

40 def copy_position_from(self, other): 

41 self.x = other.x 

42 self.y = other.y 

43 self.height = other.height 

44 self.width = other.width 

45 self.rotation = other.rotation 

46 self.flipped = other.flipped 

47 self.save() 

48 

49 created_at = models.DateTimeField(auto_now_add=True) 

50 objects = AccessControlManager() 

51 all_states = AllFlowsheetStatesManager() 

52 

53 # runtime-accessed relations 

54 flowsheet: "Flowsheet" 

55 simulationObject: "SimulationObject | None" 

56 group: "Grouping | None"