From e708a4603c9557ed37e2c48342e1bc6e638e39f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Luis=20Cerc=C3=B3s=20pita?= Date: Sun, 8 Jul 2012 16:04:16 +0200 Subject: [PATCH] Imported numpy, and added as dependency --- src/Mod/Ship/InitGui.py | 18 ++++++++++++------ src/Mod/Ship/simRun/Simulation.py | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Mod/Ship/InitGui.py b/src/Mod/Ship/InitGui.py index 925c5e12c5..7152e03428 100644 --- a/src/Mod/Ship/InitGui.py +++ b/src/Mod/Ship/InitGui.py @@ -36,12 +36,22 @@ class ShipWorkbench ( Workbench ): self.appendToolbar("Ship design",list) list = ["Ship_Weights", "Ship_CreateTank", "Ship_GZ"] self.appendToolbar("Weights",list) + # Simulation stuff only if pyOpenCL & numpy are present + hasOpenCL = True + hasNumpy = True try: import pyopencl except ImportError: + hasOpenCL = False msg = Translator.translate("pyOpenCL not installed, ship simulations disabled\n") App.Console.PrintWarning(msg) - else: + try: + import numpy + except ImportError: + hasNumpy = False + msg = Translator.translate("numpy not installed, ship simulations disabled\n") + App.Console.PrintWarning(msg) + if hasOpenCL and hasNumpy: list = ["Ship_CreateSim", "Ship_RunSim", "Ship_StopSim"] self.appendToolbar("Simulation",list) @@ -50,11 +60,7 @@ class ShipWorkbench ( Workbench ): self.appendMenu("Ship design",list) list = ["Ship_Weights", "Ship_CreateTank", "Ship_GZ"] self.appendMenu("Weights",list) - try: - import pyopencl - except ImportError: - pass - else: + if hasOpenCL and hasNumpy: list = ["Ship_CreateSim", "Ship_RunSim", "Ship_StopSim"] self.appendMenu("Simulation",list) diff --git a/src/Mod/Ship/simRun/Simulation.py b/src/Mod/Ship/simRun/Simulation.py index bb616dfdb9..0767342cbb 100644 --- a/src/Mod/Ship/simRun/Simulation.py +++ b/src/Mod/Ship/simRun/Simulation.py @@ -27,6 +27,7 @@ import threading # pyOpenCL import pyopencl as cl +import numpy as np # FreeCAD import FreeCAD,FreeCADGui