1 from Polyline import Polyline
2 from Circle import Circle
5 """Manages the Model instances"""
7 def __init__( self, MainFrame ) :
11 self._mainFrame = MainFrame
16 def getModels( self ) :
19 def getMainFrame( self ) :
20 return self._mainFrame
22 def getNbPolylines( self ) :
23 return self._nbPolylines
25 def setNbPolylines( self, n ) :
29 def getNbCircles( self ) :
30 return self._nbCircles
32 def setNbCircles( self, n ) :
36 def createPolyline( self, name, randomNumberOfPoints ) :
37 """Creates a Polyline object nammed name with randomNumberOfPoints points"""
41 # Making randomNumberOfPoints random positionned points
43 x = random.uniform( 0, randomNumberOfPoints )
44 for i in range( randomNumberOfPoints ) :
45 x = random.uniform( x, x+randomNumberOfPoints )
46 y = random.uniform( 0, x )
48 points.append( point )
51 myPolyline = Polyline( name, points, self )
52 self._models.append( myPolyline )
53 myPolyline.updateViews( mode = 'creation' )
58 def createCircle( self, name, center, radius ) :
59 """Creates a Circle object nammed name with center and radius"""
61 myCircle = Circle( name, center, radius, self )
62 self._models.append( myCircle )
63 myCircle.updateViews( mode = 'creation' )
68 def showModel( self, model ) :
69 model.updateViews( mode = 'showing' )
72 def editName( self, model, name ) :
74 model.updateViews( mode = 'modification' )
77 def editPoint( self, polyline, newPoint, pointRange ) :
78 polyline.editPoint( pointRange, newPoint )
79 polyline.updateViews( mode = 'modification' )
82 def editCenter( self, circle, center ) :
83 circle.setCenter( center )
84 circle.updateViews( mode = 'modification' )
87 def editRadius( self, circle, radius ) :
88 circle.setRadius( radius )
89 circle.updateViews( mode = 'modification' )
92 def removeModel( self, model ) :
93 model.updateViews( mode = 'supression' )
94 index = self._models.index( model )
98 def saveListOfModels( self ) :
99 for model in self._models :