mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-03 05:22:06 +00:00
bimtester: parse behave args to the gui too and other small gui
improvements
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
# TODO: improve layout, start with feature file path and beside button !!!!!
|
# TODO: all args should be passed to the gui,
|
||||||
|
# either pass them further to behave or make it possible to edit them before
|
||||||
# TODO: if browse widgets will be canceled, last QLineEdit should be restored
|
# TODO: if browse widgets will be canceled, last QLineEdit should be restored
|
||||||
# TODO: keep path or file if in browse widget canceled
|
# TODO: keep path or file if in browse widget canceled
|
||||||
|
# TODO: make a frame around features direcory chooser and
|
||||||
|
# use features path from ifc button
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -17,7 +20,8 @@ class GuiWidgetBimTester(QtWidgets.QWidget):
|
|||||||
self,
|
self,
|
||||||
featurespath="",
|
featurespath="",
|
||||||
ifcfile="",
|
ifcfile="",
|
||||||
get_featurepath_from_ifcpath=False
|
get_featurepath_from_ifcpath=False,
|
||||||
|
args=[]
|
||||||
):
|
):
|
||||||
super(GuiWidgetBimTester, self).__init__()
|
super(GuiWidgetBimTester, self).__init__()
|
||||||
|
|
||||||
@@ -36,6 +40,7 @@ class GuiWidgetBimTester(QtWidgets.QWidget):
|
|||||||
self.initial_featurespath = featurespath
|
self.initial_featurespath = featurespath
|
||||||
self.initial_ifcfile = ifcfile
|
self.initial_ifcfile = ifcfile
|
||||||
self.get_featurepath_from_ifcpath = get_featurepath_from_ifcpath
|
self.get_featurepath_from_ifcpath = get_featurepath_from_ifcpath
|
||||||
|
self.args = args
|
||||||
# print(self.initial_featurespath)
|
# print(self.initial_featurespath)
|
||||||
# print(self.initial_ifcfile)
|
# print(self.initial_ifcfile)
|
||||||
# print(self.get_featurepath_from_ifcpath)
|
# print(self.get_featurepath_from_ifcpath)
|
||||||
@@ -198,18 +203,42 @@ class GuiWidgetBimTester(QtWidgets.QWidget):
|
|||||||
|
|
||||||
# **********************************************************
|
# **********************************************************
|
||||||
def run_bimtester(self):
|
def run_bimtester(self):
|
||||||
print("Run BIMTester")
|
print("Run BIMTester by the GUI")
|
||||||
QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
|
QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
|
||||||
|
|
||||||
# get features dir
|
# get features dir
|
||||||
if self.featuredirfromifc_cb.isChecked() is True:
|
if self.featuredirfromifc_cb.isChecked() is True:
|
||||||
the_features_path = os.path.dirname(os.path.realpath(
|
ifcfile = self.get_ifcfile()
|
||||||
self.get_ifcfile()
|
|
||||||
))
|
|
||||||
print(
|
print(
|
||||||
"Make sure the feature files are beside "
|
"Make sure the feature files are beside "
|
||||||
"the ifc file in a directory named 'features'."
|
"the ifc file in a directory named 'features'."
|
||||||
)
|
)
|
||||||
|
if ifcfile == "":
|
||||||
|
# os.path.realpath("") would return the cmd dir and not ""
|
||||||
|
print(
|
||||||
|
"No ifcfile given, "
|
||||||
|
"thus features files path will be set to ''."
|
||||||
|
)
|
||||||
|
the_features_path = ""
|
||||||
|
elif os.path.isfile(ifcfile) is not True:
|
||||||
|
# if ifcfile does not exist set features path to ""
|
||||||
|
print(
|
||||||
|
"The ifcfile does not exist, "
|
||||||
|
"thus features files path will be set to ''."
|
||||||
|
)
|
||||||
|
the_features_path = ""
|
||||||
|
else:
|
||||||
|
ifcfilepath = os.path.dirname(os.path.realpath(ifcfile))
|
||||||
|
if os.path.isdir(ifcfilepath):
|
||||||
|
the_features_path = ifcfilepath
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
"ifcfilepath does not exist, "
|
||||||
|
"thus features files path will be set to ''."
|
||||||
|
"this shold never happen, please debug. "
|
||||||
|
)
|
||||||
|
the_features_path = ""
|
||||||
|
|
||||||
else:
|
else:
|
||||||
the_features_path = self.get_featurefilesdir()
|
the_features_path = self.get_featurefilesdir()
|
||||||
print(the_features_path)
|
print(the_features_path)
|
||||||
@@ -218,11 +247,13 @@ class GuiWidgetBimTester(QtWidgets.QWidget):
|
|||||||
the_ifcfile = self.get_ifcfile()
|
the_ifcfile = self.get_ifcfile()
|
||||||
print(the_ifcfile)
|
print(the_ifcfile)
|
||||||
|
|
||||||
|
# overwrite the_features_path and ifcfile in args
|
||||||
|
patched_args = self.args
|
||||||
|
patched_args["featuresdir"] = the_features_path
|
||||||
|
patched_args["ifcfile"] = the_ifcfile
|
||||||
|
|
||||||
# run bimtester
|
# run bimtester
|
||||||
status = run_all(
|
status = run_all(patched_args)
|
||||||
the_features_path,
|
|
||||||
the_ifcfile,
|
|
||||||
)
|
|
||||||
print(status)
|
print(status)
|
||||||
|
|
||||||
QtWidgets.QApplication.restoreOverrideCursor()
|
QtWidgets.QApplication.restoreOverrideCursor()
|
||||||
|
|||||||
@@ -281,15 +281,12 @@ def run_copyintmp_tests(args={}):
|
|||||||
return copy_base_path
|
return copy_base_path
|
||||||
|
|
||||||
|
|
||||||
def run_all(the_features_path, the_ifcfile):
|
def run_all(args):
|
||||||
|
|
||||||
print("# Run all.")
|
print("# Run all.")
|
||||||
|
|
||||||
# run bimtester
|
# run bimtester
|
||||||
runpath = run_copyintmp_tests({
|
runpath = run_copyintmp_tests(args)
|
||||||
"featuresdir": the_features_path,
|
|
||||||
"ifcfile": the_ifcfile
|
|
||||||
})
|
|
||||||
print(runpath)
|
print(runpath)
|
||||||
|
|
||||||
# check if it worked out well
|
# check if it worked out well
|
||||||
@@ -306,7 +303,7 @@ def run_all(the_features_path, the_ifcfile):
|
|||||||
generate_report(runpath)
|
generate_report(runpath)
|
||||||
# get the feature files
|
# get the feature files
|
||||||
feature_files = os.listdir(
|
feature_files = os.listdir(
|
||||||
os.path.join(the_features_path, "features")
|
os.path.join(args["featuresdir"], "features")
|
||||||
)
|
)
|
||||||
# print(feature_files)
|
# print(feature_files)
|
||||||
for ff in feature_files:
|
for ff in feature_files:
|
||||||
|
|||||||
@@ -8,7 +8,12 @@ from bimtester import reports
|
|||||||
from bimtester import run
|
from bimtester import run
|
||||||
|
|
||||||
|
|
||||||
def show_widget(features="", ifcfile="", get_featurepath_from_ifcpath=False):
|
def show_widget(
|
||||||
|
features="",
|
||||||
|
ifcfile="",
|
||||||
|
get_featurepath_from_ifcpath=False,
|
||||||
|
args=[]
|
||||||
|
):
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from PySide2 import QtWidgets
|
from PySide2 import QtWidgets
|
||||||
@@ -19,7 +24,12 @@ def show_widget(features="", ifcfile="", get_featurepath_from_ifcpath=False):
|
|||||||
app = QtWidgets.QApplication(sys.argv)
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
|
|
||||||
# Create and show the form
|
# Create and show the form
|
||||||
form = GuiWidgetBimTester(features, ifcfile, get_featurepath_from_ifcpath)
|
form = GuiWidgetBimTester(
|
||||||
|
features,
|
||||||
|
ifcfile,
|
||||||
|
get_featurepath_from_ifcpath,
|
||||||
|
args
|
||||||
|
)
|
||||||
form.show()
|
form.show()
|
||||||
|
|
||||||
# Run the main Qt loop
|
# Run the main Qt loop
|
||||||
@@ -58,6 +68,13 @@ if __name__ == "__main__":
|
|||||||
),
|
),
|
||||||
default=""
|
default=""
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-f",
|
||||||
|
"--feature",
|
||||||
|
type=str,
|
||||||
|
help="Specify a feature file to test",
|
||||||
|
default=""
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-g",
|
"-g",
|
||||||
"--gui",
|
"--gui",
|
||||||
@@ -67,13 +84,6 @@ if __name__ == "__main__":
|
|||||||
"is triggered automaticly."
|
"is triggered automaticly."
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
"-f",
|
|
||||||
"--feature",
|
|
||||||
type=str,
|
|
||||||
help="Specify a feature file to test",
|
|
||||||
default=""
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-i",
|
"-i",
|
||||||
"--ifcfile",
|
"--ifcfile",
|
||||||
@@ -135,12 +145,13 @@ if __name__ == "__main__":
|
|||||||
elif args["report"]:
|
elif args["report"]:
|
||||||
reports.generate_report()
|
reports.generate_report()
|
||||||
elif args["gui"]:
|
elif args["gui"]:
|
||||||
|
args["copyintemprun"] = True
|
||||||
fea = args["featuresdir"]
|
fea = args["featuresdir"]
|
||||||
ifc = args["ifcfile"]
|
ifc = args["ifcfile"]
|
||||||
if fea != "" and ifc != "":
|
if fea != "" and ifc != "":
|
||||||
show_widget(fea, ifc, False)
|
show_widget(fea, ifc, False, args)
|
||||||
elif fea == "" and ifc != "":
|
elif fea == "" and ifc != "":
|
||||||
show_widget(fea, ifc, True)
|
show_widget(fea, ifc, True, args)
|
||||||
elif args["copyintemprun"]:
|
elif args["copyintemprun"]:
|
||||||
run.run_copyintmp_tests(args)
|
run.run_copyintmp_tests(args)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user