From: rnv Date: Thu, 22 Jun 2017 14:55:49 +0000 (+0300) Subject: Merge Python 3 porting. X-Git-Tag: V9_0_0~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4b84d5ef39e8bc3247c4d4fa9e1fddfac2431254;p=modules%2Fgeom.git Merge Python 3 porting. --- 4b84d5ef39e8bc3247c4d4fa9e1fddfac2431254 diff --cc src/GEOM_I/GEOM_Gen_i.cc index 553a763e8,15241bd08..5c99e5876 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@@ -594,8 -599,8 +595,8 @@@ SALOMEDS::TMPFile* GEOM_Gen_i::Save(SAL // Prepare a file name to open TCollection_AsciiString aNameWithExt(""); if (isMultiFile) -- aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath - (getStudyServant()->URL())).c_str()); - (Kernel_Utils::encode(theComponent->GetStudy()->URL()))).c_str()); ++ aNameWithExt = TCollection_AsciiString( (char*)(SALOMEDS_Tool::GetNameFromPath( ++ Kernel_Utils::encode(getStudyServant()->URL())).c_str())); #if OCC_VERSION_MAJOR > 6 aNameWithExt += TCollection_AsciiString("_GEOM.cbf"); #else diff --cc src/GEOM_PY/structelem/__init__.py index cf5ef97aa,648e6d9b4..04d12a1ff --- a/src/GEOM_PY/structelem/__init__.py +++ b/src/GEOM_PY/structelem/__init__.py @@@ -244,10 -252,11 +244,10 @@@ class StructuralElementManager # Create the part try: - part = parts.__dict__[parttype]( - self._studyEditor.studyId, meshGroup, - groupGeomObj, newparams) + part = parts.__dict__[parttype](meshGroup, + groupGeomObj, newparams) element.addPart(part) - except InvalidParameterError, e: + except InvalidParameterError as e: logger.error("Invalid parameter error: %s" % e) raise except: @@@ -434,8 -452,8 +434,9 @@@ class StructuralElement different parts of the structural element, and add them to the study. """ gg = salome.ImportComponentGUI("GEOM") - geompy = getGeompy(self._studyEditor.studyId) ++ + geompy = getGeompy() - for part in self._parts.itervalues(): + for part in self._parts.values(): # Build the structural element part logger.debug("Building %s" % part) try: diff --cc src/GEOM_PY/structelem/parts.py index 01b665042,61cdd7d04..d2f46a9b8 --- a/src/GEOM_PY/structelem/parts.py +++ b/src/GEOM_PY/structelem/parts.py @@@ -450,10 -454,10 +450,10 @@@ class CircularBeam(Beam) """ - def __init__(self, studyId, groupName, groupGeomObj, parameters, + def __init__(self, groupName, groupGeomObj, parameters, name = Beam.DEFAULT_NAME, color = None): if color is None: - if parameters.has_key("R1"): # variable section + if "R1" in parameters: # variable section color = LIGHT_RED else: # constant section color = RED @@@ -562,10 -566,10 +562,10 @@@ class RectangularBeam(Beam) """ - def __init__(self, studyId, groupName, groupGeomObj, parameters, + def __init__(self, groupName, groupGeomObj, parameters, name = Beam.DEFAULT_NAME, color = None): if color is None: - if parameters.has_key("HY1") or parameters.has_key("H1"): + if "HY1" in parameters or "H1" in parameters: color = LIGHT_BLUE # variable section else: # constant section color = BLUE diff --cc src/GEOM_SWIG/GEOM_ObjectInfo.py index 84c40fdd2,3e74aa887..9a686cb60 --- a/src/GEOM_SWIG/GEOM_ObjectInfo.py +++ b/src/GEOM_SWIG/GEOM_ObjectInfo.py @@@ -47,12 -47,12 +47,12 @@@ obj5_entry = geompy.addToStudy(obj5, "O # Get information about objects hasInfo = geompy.hasObjectInfo() - print "Check if GEOM module provides information about its objects: ", hasInfo + print("Check if GEOM module provides information about its objects: ", hasInfo) if hasInfo == True: - print "Information about first object: ", geompy.getObjectInfo(obj1_entry) - print "Information about second object: ", geompy.getObjectInfo(obj2_entry) - print "Information about third object: ", geompy.getObjectInfo(obj3_entry) - print "Information about fourth object: ", geompy.getObjectInfo(obj4_entry) - print "Information about fifth object: ", geompy.getObjectInfo(obj5_entry) - print("Information about first object: ", geompy.getObjectInfo(salome.myStudyId, obj1_entry)) - print("Information about second object: ", geompy.getObjectInfo(salome.myStudyId, obj2_entry)) - print("Information about third object: ", geompy.getObjectInfo(salome.myStudyId, obj3_entry)) - print("Information about fourth object: ", geompy.getObjectInfo(salome.myStudyId, obj4_entry)) - print("Information about fifth object: ", geompy.getObjectInfo(salome.myStudyId, obj5_entry)) ++ print("Information about first object: ", geompy.getObjectInfo(obj1_entry)) ++ print("Information about second object: ", geompy.getObjectInfo(obj2_entry)) ++ print("Information about third object: ", geompy.getObjectInfo(obj3_entry)) ++ print("Information about fourth object: ", geompy.getObjectInfo(obj4_entry)) ++ print("Information about fifth object: ", geompy.getObjectInfo(obj5_entry)) -salome.sg.updateObjBrowser(True) +salome.sg.updateObjBrowser() diff --cc src/GEOM_SWIG/PAL_MESH_028_geometry.py index 45dbbd78e,2e57573b8..6139da415 --- a/src/GEOM_SWIG/PAL_MESH_028_geometry.py +++ b/src/GEOM_SWIG/PAL_MESH_028_geometry.py @@@ -80,11 -80,11 +80,11 @@@ theFilenameToSave = theHomePath + "/Pyr if os.access(theFilenameToSave, os.F_OK): if os.access(theFilenameToSave, os.W_OK): os.remove(theFilenameToSave) - salome.myStudyManager.SaveAs(theFilenameToSave, salome.myStudy, 0) + salome.myStudy.SaveAs(theFilenameToSave, 0, 0) else: - print "You have no enough permissions to overwrite HDF file: ",theFilenameToSave + print("You have no enough permissions to overwrite HDF file: ",theFilenameToSave) else: - salome.myStudyManager.SaveAs(theFilenameToSave, salome.myStudy, 0) + salome.myStudy.SaveAs(theFilenameToSave, 0, 0) -salome.sg.updateObjBrowser(True) +salome.sg.updateObjBrowser() diff --cc src/GEOM_SWIG/geomBuilder.py index 934a62219,8d5bda38e..afb8509e1 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@@ -649,9 -729,10 +729,9 @@@ class geomBuilder(GEOM._objref_GEOM_Gen #print "-------- geomBuilder __init__ --- ", created, self if not created: created = True - GEOM._objref_GEOM_Gen.__init__(self) + GEOM._objref_GEOM_Gen.__init__(self, *args) self.myMaxNbSubShapesAllowed = 0 # auto-publishing is disabled by default self.myBuilder = None - self.myStudyId = 0 self.father = None self.BasicOp = None @@@ -891,13 -973,13 +971,13 @@@ """ # Example: see GEOM_TestAll.py try: - aSObject = self.AddInStudy(self.myStudy, aShape, aName, None) + aSObject = self.AddInStudy(aShape, aName, None) if aSObject and aName: aSObject.SetAttrString("AttributeName", aName) if doRestoreSubShapes: - self.RestoreSubShapesSO(self.myStudy, aSObject, theArgs, + self.RestoreSubShapesSO(aSObject, theArgs, theFindMethod, theInheritFirstArg, True ) except: - print "addToStudy() failed" + print("addToStudy() failed") return "" return aShape.GetStudyEntry() @@@ -924,10 -1006,10 +1004,10 @@@ """ # Example: see GEOM_TestAll.py try: - aSObject = self.AddInStudy(self.myStudy, aShape, aName, aFather) + aSObject = self.AddInStudy(aShape, aName, aFather) if aSObject and aName: aSObject.SetAttrString("AttributeName", aName) except: - print "addToStudyInFather() failed" + print("addToStudyInFather() failed") return "" return aShape.GetStudyEntry() @@@ -13436,10 -13518,10 +13516,10 @@@ if include_min: left_str = " <= " if include_max: right_str = " <= " - self.addToStudyInFather(shape, group_edges, "Group of edges with " + `min_length` - + left_str + "length" + right_str + `max_length`) + self.addToStudyInFather(shape, group_edges, "Group of edges with " + repr(min_length) + + left_str + "length" + right_str + repr(max_length)) - sg.updateObjBrowser(True) + sg.updateObjBrowser() return group_edges diff --cc src/Tools/t_shape/t_shape_builder.py index a62795814,8a77a8b09..c1830cf30 --- a/src/Tools/t_shape/t_shape_builder.py +++ b/src/Tools/t_shape/t_shape_builder.py @@@ -99,9 -101,10 +99,9 @@@ def demidisk(r1, a1, roty=0, solid_thic else: return v, l, arc1, part1 -def pointsProjetes(study, vref, face): - #geompy = geomBuilder.New(study) +def pointsProjetes(vref, face): vface = geompy.ExtractShapes(face, geompy.ShapeType["VERTEX"], True) - vord = range(len(vref)) + vord = list(range(len(vref))) plan = geompy.MakePlaneThreePnt(vref[0], vref[1], vref[-1], 10000) vproj = [ geompy.MakeProjection(vert, plan) for vert in vface ] for i,v in enumerate(vproj): @@@ -111,9 -114,10 +111,9 @@@ vord[dist[0][1]] = vface[i] return vord -def arcsProjetes(study, vf, face): - #geompy = geomBuilder.New(study) +def arcsProjetes(vf, face): lface = geompy.ExtractShapes(face, geompy.ShapeType["EDGE"], True) - lord = range(3) + lord = list(range(3)) ends = [vf[1], vf[6], vf[7], vf[3]] for i in range(3): for lf in lface: @@@ -393,10 -399,10 +393,10 @@@ def test_t_shape_builder() h1 = r1 * 2.0 h2 = h1 try: - res = build_shape(theStudy, r1, r2, h1, h2, thickness) + res = build_shape(r1, r2, h1, h2, thickness) geompy.addToStudy(res, "res_%f_%f_%f"%(r1,r2, thickness)) except: - print "problem with res_%f_%f_%f"%(r1,r2, thickness) + print("problem with res_%f_%f_%f"%(r1,r2, thickness)) if __name__=="__main__": """For testing purpose"""