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

29 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-12-18 04:00 +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 

6 

7if TYPE_CHECKING: 

8 from core.auxiliary.models.Flowsheet import Flowsheet 

9 from flowsheetInternals.unitops.models.SimulationObject import SimulationObject 

10 from flowsheetInternals.graphicData.models.groupingModel import Grouping 

11 

12 

13class GraphicObject(models.Model): 

14 flowsheet = models.ForeignKey("core_auxiliary.Flowsheet", on_delete=models.CASCADE, related_name="GraphicObjects") 

15 simulationObject = models.ForeignKey('flowsheetInternals_unitops.SimulationObject', on_delete=models.CASCADE, 

16 related_name='graphicObject', null=True) 

17 visible = models.BooleanField(default=True) 

18 x = models.FloatField(default=0) 

19 y = models.FloatField(default=0) 

20 height = models.FloatField(default=0) 

21 width = models.FloatField(default=0) 

22 rotation = models.IntegerField(default=0) 

23 group = models.ForeignKey('flowsheetInternals_graphicData.Grouping', on_delete=models.CASCADE, 

24 related_name='graphicObjects', null=True) 

25 flipped = models.BooleanField(default=False) 

26 

27 def copy_position_from(self, other): 

28 self.x = other.x 

29 self.y = other.y 

30 self.height = other.height 

31 self.width = other.width 

32 self.rotation = other.rotation 

33 self.flipped = other.flipped 

34 self.save() 

35 

36 created_at = models.DateTimeField(auto_now_add=True) 

37 objects = AccessControlManager() 

38 

39 # runtime-accessed relations 

40 flowsheet: "Flowsheet" 

41 simulationObject: "SimulationObject | None" 

42 group: "Grouping | None"