Skip to content

Commit

Permalink
posicionamento funcional
Browse files Browse the repository at this point in the history
  • Loading branch information
AlgumCorrupto committed Apr 13, 2024
1 parent ce268d7 commit 4d1182c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Binary file modified src/__pycache__/graph.cpython-312.pyc
Binary file not shown.
Binary file modified src/__pycache__/renderer.cpython-312.pyc
Binary file not shown.
Binary file modified src/__pycache__/sim.cpython-312.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion src/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ def update(self):
#self.circle.remove()
#self.bg = self.fig.canvas.copy_from_bbox(self.fig.bbox)

#print("{}: {}".format(self.title, self.y[self.i]))

if self.i < len(self.x) - 1 and self.isRunning == True:
self.elapsedTime += 1
print("{}: {}".format(self.title, str(self.elapsedTime)))
if self.elapsedTime >= min(self.x):
self.i+= 1
self.circle = pt.Ellipse((self.x[self.i],self.y[self.i]),self.circleW, self.circleH, fc=clr.matNormal[3],ec='black', animated=True)
Expand Down
16 changes: 8 additions & 8 deletions src/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class scene(QGraphicsScene):
def __init__(self, parent, view, sim):
super().__init__(parent)
self.elapsedTime = -1
self.elapsedTime = 0
self.setSceneRect(0, 0, 400, 175)
self.sim = sim
self.view = view
Expand All @@ -19,7 +19,7 @@ def __init__(self, parent, view, sim):
self.text.setFont(QFont("Cursiv"))
self.text.setDefaultTextColor(clr.qtFg)
self.text.setScale(5)
self.runner = QGraphicsEllipseItem(0, 0, 100, 100)
self.runner = QGraphicsEllipseItem(self.sim.startPos, 0, 100, 100)
brush = QBrush(clr.qtNormal[3])
self.runner.setBrush(brush)
self.vel = self.sim.startVel
Expand All @@ -28,17 +28,17 @@ def __init__(self, parent, view, sim):

def run(self):
self.text.setPos((self.view.width()/2) - ((self.text.boundingRect().width()*5)/2), ((self.height()/2)) - ((self.text.boundingRect().height()) * 5)/2)
index = int(self.elapsedTime - self.sim.Time0) if int(self.elapsedTime - self.sim.Time0) >= 0 else 0
index = int(self.elapsedTime - self.sim.Time0) if int(self.elapsedTime - self.sim.Time0) < self.sim.TimeF else self.sim.TimeF - 1
self.text.setPlainText("T={}, a={}, S={}, V={}".format(self.elapsedTime if self.elapsedTime > 0 else 0,
self.sim.acce,
round(self.sim.dataArr[index].pos, 2),
round(self.sim.dataArr[index].vel, 2)))
self.vel))
if self.isRunning and self.elapsedTime < self.sim.TimeF:
print("renderer: {}".format(str(self.elapsedTime)))
if self.elapsedTime >= self.sim.Time0 - 1:
if self.elapsedTime > self.sim.Time0:
self.vel += self.sim.acce
pos = (self.runner.x() + (self.vel))
self.runner.setX(pos)
self.vel += self.sim.acce
self.elapsedTime+= 1
self.runner.setY((self.height()/2) - 100/2)

Expand All @@ -50,6 +50,6 @@ def playSim(self):
self.isRunning = True if not self.isRunning else False

def resetSim(self):
self.runner.setPos(0, self.runner.y())
self.runner.setPos(self.sim.startPos, self.runner.y())
self.vel = self.sim.startVel
self.elapsedTime = -1
self.elapsedTime = 0
2 changes: 1 addition & 1 deletion src/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def setPos(self, pos):

#run simulation
def run(self):
self.dataArr.append(data.Data(self.startPos, self.currTime + self.Time0, self.startVel, self.acce))
#self.dataArr.append(data.Data(self.startPos, self.currTime + self.Time0, self.startVel, self.acce))
while self.currTime + self.Time0 < (self.TimeF):
self.currTime+=1
vel = self.startVel + self.acce*self.currTime
Expand Down

0 comments on commit 4d1182c

Please sign in to comment.