Skip to content

Commit

Permalink
[Scripts] Remove need of PyQt5 if gui is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
epernod committed May 7, 2024
1 parent 14b86c9 commit a449e75
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 31 deletions.
20 changes: 0 additions & 20 deletions python/mor/gui/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,26 +202,6 @@ def removeLine(tab,rm=False):
tab.removeRow(row)
return row

def update_progress(progress):
barLength = 50 # Modify this to change the length of the progress bar
status = "Compute Weight&RID"
if isinstance(progress, int):
progress = float(progress)
if not isinstance(progress, float):
progress = 0
status = "error: progress var must be float\r\n"
if progress < 0:
progress = 0
status = "Halt...\r\n"
if progress > 1:
progress = 1
block = int(round(barLength*progress))
text = "\r[{0}] {1}% {2}".format( "#"*block + "-"*(barLength-block), progress*100, status)
if progress == 1 :
text = text+"\n"
sys.stdout.write(text)
sys.stdout.flush()

def left(lineEdit):
newTxt = str(lineEdit.text())
if newTxt:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
path = os.path.dirname(os.path.abspath(__file__))
sys.path.append(path+'/../../gui')

import utility as u
from mor.utility import utility as util


def errDif(G, xi, b):
return np.linalg.norm(G.dot(xi) - b)
Expand All @@ -33,7 +34,7 @@ def selectECSW(G,b,tau,verbose):
if verbose :
print ("Current Error: ", currentValue,"Target Error:", valTarget)
else :
u.update_progress( round( ( 100 - ((currentValue - valTarget)*100) / marge) / 100 , 4) )
util.update_progress( round( ( 100 - ((currentValue - valTarget)*100) / marge) / 100 , 4) )

vecDiff = b - G.dot(xi)
GT = np.transpose(G)
Expand Down
21 changes: 12 additions & 9 deletions tools/modelOrderReduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,27 @@
path = os.path.dirname(os.path.abspath(__file__))
sys.path.append(path+'/../python') # TO CHANGE

useGui = True

# MOR IMPORT
from mor.gui import utility
if useGui:
from mor.gui import utility

from mor.reduction import ReduceModel
from mor.reduction.container import ObjToAnimate

#######################################################################
#################### PARAMETERS ###########################

# Select Output Dir and original scene name & path
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)

originalScene = utility.openFileName('Select the SOFA scene you want to reduce')
outputDir = utility.openDirName('Select the directory that will contain all the results')

# originalScene = "/home/felix_v/SOFA/plugins/ModelOrderReduction/tools/test/sofa_test_scene/diamondRobot.py"
# outputDir = "/home/felix_v/SOFA/plugins/ModelOrderReduction/tools/test/test_diamond"
if useGui:
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
originalScene = utility.openFileName('Select the SOFA scene you want to reduce')
outputDir = utility.openDirName('Select the directory that will contain all the results')
else:
originalScene = "/home/felix_v/SOFA/plugins/ModelOrderReduction/tools/test/sofa_test_scene/diamondRobot.py"
outputDir = "/home/felix_v/SOFA/plugins/ModelOrderReduction/tools/test/test_diamond"

phasesToExecute = None

Expand Down

0 comments on commit a449e75

Please sign in to comment.