import traceback
import argparse as AP
-import glob
import fnmatch
import pprint as PP # pretty print
import src
del sys.path[0]
done = False
filesForTest[aFile] = (aImport, aModule)
- except Exception as e:
+ except Exception:
if done:
del sys.path[0] # attention of sys.path appends
done = False
errPrint("Test: %s %s" % (i, k))
if i == 0:
suite = loader.loadTestsFromModule(filesForTest[k][1])
- pass
else:
suite.addTests(loader.loadTestsFromModule(filesForTest[k][1]))
- pass
if args.type == "std":
runner = unittest.TextTestRunner(verbosity=args.verbosity)
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import stat
import sys
import shutil
import subprocess
p_name, p_info = p_name_info
res = 0
error_step = ""
- pip_install_in_python = False
pip_wheels_dir = os.path.join(config.LOCAL.archive_dir, "wheels")
pip_install_cmd = (
config.INTERNAL.command.pip_install
p_info.name,
p_info.version,
)
- pip_install_in_python = True
else:
# pip will install product in product install_dir
pip_install_dir = os.path.join(
# Use the sorted list of all products to sort the list of products we have to compile
sorted_product_list = []
- product_list_runtime = []
- product_list_compiletime = []
# store at beginning compile time products, we need to compile them before!
for n in sorted_nodes:
),
1,
)
- except Exception as e:
+ except Exception:
pass
except Exception as e:
# logger.write(src.printcolors.printcInfo(" %s\n" % "no properties"), 1)
"\nConfig.%s of application %s:\n\n%s\n"
% (od, runner.cfg.VARS.application, res)
)
- except Exception as e:
+ except Exception:
msg = "\nConfig.%s of application %s: Unknown pyconf key\n" % (
od,
runner.cfg.VARS.application,
# check system prerequisites
if options.check_system:
check_install_system(runner.cfg, logger)
- pass
import os
import shutil
-import re
-import subprocess
import src
import prepare
import paramiko
except:
paramiko = "import paramiko impossible"
- pass
import src
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import platform
import shutil
import getpass
import subprocess
additional_env["ABSOLUTE_APPLI_PATH"] = (
"out_dir_Path" + config.VARS.sep + app_root_dir
)
- launcher_name = src.get_launcher_name(config)
+ src.get_launcher_name(config)
additional_env["APPLI"] = "out_dir_Path" + config.VARS.sep + file_name
# create an environment file writer
import os
import subprocess
-import re
import src
import prepare
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import re
import os
-import pprint as PP
import src
import src.debug as DBG
import os
import shutil
-import re
-import subprocess
import src
import prepare
import os
import shutil
-import re
-import subprocess
import src
import prepare
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import re
import subprocess
import src
import src.debug as DBG
p_name, p_info = p_name_info
res = 0
error_step = ""
- pip_install_in_python = False
pip_wheels_dir = os.path.join(config.LOCAL.archive_dir, "wheels")
pip_install_cmd = (
config.INTERNAL.command.pip_install
p_info.name,
p_info.version,
)
- pip_install_in_python = True
else:
# pip will install product in product install_dir
pip_install_dir = os.path.join(
# Use the sorted list of all products to sort the list of products we have to upgrade
sorted_product_list = []
- product_list_runtime = []
- product_list_compiletime = []
# store at beginning compile time products, we need to compile them before!
for n in sorted_nodes:
else:
import :sat:{Cpp_Template_}SWIG
my_:sat:{Cpp_Template_}=:sat:{Cpp_Template_}SWIG.:sat:{Cpp_Template_}()
-pass
#
#
print "Test Program of :sat:{Cpp_Template_} component"
else:
import :sat:{Cpp_Template_}SWIG
my_:sat:{Cpp_Template_}=:sat:{Cpp_Template_}SWIG.:sat:{Cpp_Template_}()
-pass
#
#
print "Test Program of :sat:{Cpp_Template_} component"
else:
import :sat:{Cpp_Template_}SWIG
my_:sat:{Cpp_Template_}=:sat:{Cpp_Template_}SWIG.:sat:{Cpp_Template_}()
-pass
#
#
print "Test Program of :sat:{Cpp_Template_} component"
else:
import :sat:{Cpp_Template_}SWIG
my_:sat:{Cpp_Template_}=:sat:{Cpp_Template_}SWIG.:sat:{Cpp_Template_}()
-pass
#
#
print "Test Program of :sat:{Cpp_Template_} component"
else:
import :sat:{Cpp_Template_}SWIG
my_:sat:{Cpp_Template_}=:sat:{Cpp_Template_}SWIG.:sat:{Cpp_Template_}()
-pass
#
#
print "Test Program of :sat:{Cpp_Template_} component"
else:
import :sat:{Cpp_Template_}SWIG
my_:sat:{Cpp_Template_}=:sat:{Cpp_Template_}SWIG.:sat:{Cpp_Template_}()
-pass
#
#
print "Test Program of :sat:{Cpp_Template_} component"
else:
import :sat:{Cpp_Template_}SWIG
my_:sat:{Cpp_Template_}=:sat:{Cpp_Template_}SWIG.:sat:{Cpp_Template_}()
-pass
#
#
print "Test Program of :sat:{Cpp_Template_} component"
self._mainFrame = MainFrame
self._nbPolylines = 0
self._nbCircles = 0
- pass
def getModels(self):
return self._models
def setNbPolylines(self, n):
self._nbPolylines = n
- pass
def getNbCircles(self):
return self._nbCircles
def setNbCircles(self, n):
self._nbCircles = n
- pass
def createPolyline(self, name, randomNumberOfPoints):
"""Creates a Polyline object nammed name with randomNumberOfPoints points"""
y = random.uniform(0, x)
point = x, y
points.append(point)
- pass
myPolyline = Polyline(name, points, self)
self._models.append(myPolyline)
def showModel(self, model):
model.updateViews(mode="showing")
- pass
def editName(self, model, name):
model.setName(name)
def removeModel(self, model):
model.updateViews(mode="supression")
- index = self._models.index(model)
+ self._models.index(model)
del model
- pass
def saveListOfModels(self):
for model in self._models:
model.save()
- pass
- pass
-pass
# Setting default name
nbCircles = controller.getNbCircles()
self.entryName.setText("circle_" + str(nbCircles + 1))
- pass
def addSpecialWidgets(self):
floatValidator = QDoubleValidator(self)
self.entryRadius.setValidator(floatValidator)
self.entryRadius.setText("10")
self.v12.addWidget(self.entryRadius)
- pass
def execApply(self):
name = self.name
self.xCenter = str(self.entryxCenter.text())
self.yCenter = str(self.entryyCenter.text())
self.radius = str(self.entryRadius.text())
- pass
def checkUserEntries(self):
if (
self.entryxCenter.setText("0")
self.entryyCenter.setText("0")
self.entryRadius.setText("10")
- pass
-pass
# Setting default name
nbPolylines = controller.getNbPolylines()
self.entryName.setText("polyline_" + str(nbPolylines + 1))
- pass
def addSpecialWidgets(self):
self.entryNbPoints.setValidator(intValidator)
self.entryNbPoints.setText("10")
self.v12.addWidget(self.entryNbPoints)
- pass
def execApply(self):
name = self.name
def retrieveUserEntries(self):
self.name = str(self.entryName.text())
self.nbPoints = str(self.entryNbPoints.text())
- pass
def checkUserEntries(self):
if self.name == "" or self.nbPoints == "":
nbPolylines = self.getController().getNbPolylines()
self.entryName.setText("polyline_" + str(nbPolylines + 1))
self.entryNbPoints.setText("10")
- pass
-pass
# Connecting widgets to slots
self.connectSlots()
- pass
def getController(self):
return self._controller
self.h2.addWidget(self.bClose)
self.bHelp = QPushButton("Help", self)
self.h2.addWidget(self.bHelp)
- pass
def addSpecialWidgets(self):
print("Virtual method")
- pass
def connectSlots(self):
self.bApply.clicked.connect(self.apply)
self.bHelp.clicked.connect(self.help)
self.bClose.clicked.connect(self.close)
- pass
def apply(self):
def retrieveUserEntries(self):
self.name = str(self.entryName.text())
- pass
def checkUserEntries(self):
if self.name == "":
def execApply(self):
print("Virtual method")
- pass
def reInitializeDialog(self):
print("Virtual method")
- pass
def help(self):
import os
os.system("firefox " + self._helpFile + "&")
- pass
def close(self):
self._widgetDialogBox.close()
- pass
-pass
# Connecting widgets to slots
self.connectSlots()
- pass
def getController(self):
return self._controller
self.h2.addWidget(self.bCancel)
self.bHelp = QPushButton("Help", self)
self.h2.addWidget(self.bHelp)
- pass
def addSpecialWidgets(self):
print("Virtual method")
- pass
def connectSlots(self):
self.bOk.clicked.connect(self.apply)
self.bHelp.clicked.connect(self.help)
self.bCancel.clicked.connect(self.close)
- pass
def apply(self):
self.retrieveUserEntries()
def retrieveUserEntries(self):
print("Virtual method")
- pass
def checkUserEntries(self):
print("Virtual method")
def execApply(self):
print("Virtual method")
- pass
def help(self):
import os
os.system("firefox " + self._helpFile + "&")
- pass
def close(self):
self._widgetDialogBox.close()
- pass
-pass
while oldCenter[i] != ":":
oldX += oldCenter[i]
i += 1
- pass
for j in range(i + 1, len(oldCenter)):
oldY += oldCenter[j]
- pass
self.entryX.setText(oldX)
self.entryY.setText(oldY)
- pass
def addSpecialWidgets(self):
floatValidator = QDoubleValidator(self)
self.entryY = QLineEdit(self)
self.entryY.setValidator(floatValidator)
self.v12.addWidget(self.entryY)
- pass
def execApply(self):
newX = float(self.newX)
def retrieveUserEntries(self):
self.newX = str(self.entryX.text())
self.newY = str(self.entryY.text())
- pass
def checkUserEntries(self):
if self.newX == "" or self.newY == "":
return True
-pass
while oldPoint[i] != ":":
oldX += oldPoint[i]
i += 1
- pass
for j in range(i + 1, len(oldPoint)):
oldY += oldPoint[j]
- pass
self.pointRange = pointRange
self.entryX.setText(oldX)
self.entryY.setText(oldY)
- pass
def addSpecialWidgets(self):
floatValidator = QDoubleValidator(self)
self.entryY = QLineEdit(self)
self.entryY.setValidator(floatValidator)
self.v12.addWidget(self.entryY)
- pass
def execApply(self):
pointRange = self.pointRange
def retrieveUserEntries(self):
self.newX = str(self.entryX.text())
self.newY = str(self.entryY.text())
- pass
def checkUserEntries(self):
if self.newX == "" or self.newY == "":
return True
-pass
self._model = model
self.entryRadius.setText(oldRadius)
- pass
def addSpecialWidgets(self):
floatValidator = QDoubleValidator(self)
self.entryRadius = QLineEdit(self)
self.entryRadius.setValidator(floatValidator)
self.v12.addWidget(self.entryRadius)
- pass
def execApply(self):
newRadius = self.newRadius
def retrieveUserEntries(self):
self.newRadius = str(self.entryRadius.text())
- pass
def checkUserEntries(self):
if self.newRadius == "":
return True
-pass
self._model = model
self.entryName.setText(oldName)
- pass
def addSpecialWidgets(self):
lName = QLabel("Name", self)
self.v11.addWidget(lName)
self.entryName = QLineEdit(self)
self.v12.addWidget(self.entryName)
- pass
def execApply(self):
newName = self.newName
def retrieveUserEntries(self):
self.newName = str(self.entryName.text())
- pass
def checkUserEntries(self):
if self.newName == "":
return True
-pass
self._radius = radius
self.addTreeWidgetItem(self.getName(), controller)
self.addGraphicScene(controller)
- pass
def getCenter(self):
return self._center[0], self._center[1]
def setCenter(self, center):
self._center = center
- pass
def getRadius(self):
return self._radius
pass
-pass
self._name = None
self._views = []
- pass
def getName(self):
return self._name
def setName(self, name):
self._name = name
- pass
def getViews(self):
return self._views
def save(self):
print("Virtual method")
- pass
-pass
self._points = points
self.addTreeWidgetItem(self.getName(), controller)
self.addGraphicScene(controller)
- pass
def getPoints(self):
return self._points
def setPoints(self, points):
self._points = points
- pass
def editPoint(self, pointRange, newPoint):
self._points[pointRange] = newPoint
- pass
def addTreeWidgetItem(self, name, controller):
from PolyTreeWidgetItem import PolyTreeWidgetItem
str(x) + ":" + str(y), controller, ["Edit"]
)
myTreeWidgetItem.addChild(newTreeWidgetItem)
- pass
myTreeWidgetItem.setModel(self)
self.getViews().append(myTreeWidgetItem)
return myTreeWidgetItem
pass
-pass
#
self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
#
- pass
"""
Touch the component
attr.SetValue( name )
attr = builder.FindOrCreateAttribute( object, "AttributeLocalID" )
attr.SetValue( objectID() )
- pass
"""
Dump module data to the Python script.
name = iter.Value().GetName()
if name: names.append( name )
iter.Next()
- pass
- pass
if names:
abuffer += [ " from batchmode_salome import lcc" ]
abuffer += [ " import :sat:{PYCMP}_ORB" ]
abuffer += [ " myCompo = lcc.FindOrLoadComponent( 'FactoryServerPy', '%s' )" % moduleName() ]
abuffer += [ " " ]
abuffer += [ " myCompo.createObject( theStudy, '%s' )" % name for name in names ]
- pass
abuffer += [ " " ]
abuffer.append( " pass" )
abuffer.append( "\0" )
__verbose__ = int( os.getenv( 'SALOME_VERBOSE', 0 ) )
except:
__verbose__ = 0
- pass
- pass
return __verbose__
###
global __orb__
if __orb__ is None:
__orb__ = CORBA.ORB_init( [''], CORBA.ORB_ID )
- pass
return __orb__
###
global __naming_service__
if __naming_service__ is None:
__naming_service__ = SALOME_NamingServicePy_i( getORB() )
- pass
return __naming_service__
##
global __lcc__
if __lcc__ is None:
__lcc__ = LifeCycleCORBA( getORB() )
- pass
return __lcc__
##
if __study_manager__ is None:
obj = getNS().Resolve( '/myStudyManager' )
__study_manager__ = obj._narrow( SALOMEDS.StudyManager )
- pass
return __study_manager__
###
global __engine__
if __engine__ is None:
__engine__ = getLCC().FindOrLoadComponent( "FactoryServerPy", moduleName() )
- pass
return __engine__
###
IOR = ""
if getORB() and getEngine():
IOR = getORB().object_to_string( getEngine() )
- pass
return IOR
###
attr.SetValue( moduleID() )
try:
builder.DefineComponentInstance( father, getEngine() )
- pass
except:
pass
- pass
return father
###
if sobj is not None:
test, anAttr = sobj.FindAttribute( "AttributeLocalID" )
if test: ID = anAttr._narrow( SALOMEDS.AttributeLocalID ).Value()
- pass
- pass
return ID
self.createTreeView()
self.createGraphicsView()
- pass
def createTreeView( self ) :
self._globalTree= TreeWidget( self )
self._dockGlobalTree.setAllowedAreas( Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea )
self._dockGlobalTree.setWidget( self._globalTree )
self._sgDesktop.addDockWidget( Qt.LeftDockWidgetArea, self._dockGlobalTree )
- pass
def createGraphicsView( self ) :
scene = GraphicsScene( self._controller )
self._globalGraphicsView = GraphicsView( scene )
self._globalGraphicsViewID = self._sgPyQt.createView( "ViewCurve", self._globalGraphicsView )
- pass
def createActions( self ) :
self.createPolylineAction = self._sgPyQt.createAction( self._polylineID, "Polyline", "Create Polyline", "Show Polyline dialog box", "ExecPolyline.png" )
self.createCircleAction = self._sgPyQt.createAction( self._circleID, "Circle", "Create Circle", "Show Circle dialog box", "ExecCircle.png" )
self.deleteAllAction = self._sgPyQt.createAction( self._deleteAllID, "Delete all", "Delete all", "Delete all objects", "ExecDelAll.png" )
- pass
def createMenus( self ) :
curveMenu = self._sgPyQt.createMenu( " Curve", -1, self._curveMenuID, self._sgPyQt.defaultMenuGroup() )
self._sgPyQt.createMenu( self.createPolylineAction, curveMenu )
self._sgPyQt.createMenu( self.createCircleAction, curveMenu )
self._sgPyQt.createMenu( self.deleteAllAction, advancedMenu )
- pass
def createToolBars( self ) :
createPolylineTB = self._sgPyQt.createTool("New polyline")
self._sgPyQt.createTool( self.createPolylineAction, createPolylineTB )
self._sgPyQt.createTool( self.createCircleAction, createCircleTB )
self._sgPyQt.createTool( self.deleteAllAction, deleteAllTB )
- pass
def createPopups( self ) :
pass
def setController( self, controller ) :
self._controller = controller
- pass
def getGlobalTree( self ) :
return self._globalTree
#Resizing the globalGraphicView
sceneRect = scene.getRect()
self._globalGraphicsView.fitInView ( sceneRect, Qt.KeepAspectRatio )
- pass
-pass
moduleDesktop = :sat:{PYCMP}Desktop( sgPyQt, sg )
objectsManager = Controller( moduleDesktop )
moduleDesktop.setController( objectsManager )
- pass
return moduleDesktop
def incObjToMap( m, id ):
if id not in m: m[id] = 0
m[id] += 1
- pass
def getSelection():
"""This method analyses selection"""
seltypes = {}
for i in range( selcount ):
incObjToMap( seltypes, getObjectID( sg.getSelected( i ) ) )
- pass
return selcount, seltypes
################################################
def initialize():
"""This method is called when module is initialized. It performs initialization actions"""
setDesktop()
- pass
def windows():
"""This method is called when module is initialized. It returns a map of popup windows to be used by the module"""
def createPreferences():
"""This method is called when module is initialized. It exports module preferences"""
- pass
def activate():
"""This method is called when module is initialized. It returns True if activating is successfull, False otherwise"""
def viewTryClose( wid ):
sgPyQt.setViewClosable(wid, True)
- pass
def deactivate():
"""This method is called when module is deactivated"""
moduleDesktop.getDockGlobalTree().hide()
moduleDesktop.updateGlobalGraphicsView( None )
moduleDesktop.getGlobalGraphicsView().hide()
- pass
def activeStudyChanged():
"""This method is called when active study is changed"""
setDesktop()
- pass
def createPopupMenu( popup, context ):
"""This method is called when popup menu is invocked"""
- pass
def OnGUIEvent( commandID ):
"""This method is called when a GUI action is activated"""
if commandID in dict_command:
dict_command[commandID]()
- pass
- pass
def preferenceChanged( section, setting ):
"""This method is called when module's preferences are changed"""
- pass
def activeViewChanged( viewID ):
"""This method is called when active view is changed"""
- pass
def viewCloned( viewID ):
"""This method is called when active view is cloned"""
- pass
def viewClosed( viewID ):
"""This method is called when active view viewClosed"""
- pass
def engineIOR():
"""This method is called when study is opened. It returns engine IOR"""
widgetDialogBox.setWidget( myDialog )
widgetDialogBox.setWindowTitle( "Polyline definition" )
sgDesktop.addDockWidget(Qt.LeftDockWidgetArea, widgetDialogBox)
- pass
def showCreateCircleDialog() :
from CreateCircleDialog import CreateCircleDialog
widgetDialogBox.setWidget( myDialog )
widgetDialogBox.setWindowTitle( "Circle definition" )
sgDesktop.addDockWidget(Qt.LeftDockWidgetArea, widgetDialogBox)
- pass
def deleteAll() :
models = moduleDesktop.getController().getModels()
if answer == QMessageBox.Yes :
for model in models :
moduleDesktop.getController().removeModel( model )
- pass
- pass
- pass
########################################################
# Commands dictionary
# Creating menus and toolbars
self.createMenus()
self.createToolBars()
- pass
def getController(self):
return self._controller
def setController(self, controller):
self._controller = controller
- pass
def getGlobalTree(self):
return self._globalTree
createPolylineAction.triggered.connect(self.showCreatePolylineDialog)
createCircleAction.triggered.connect(self.showCreateCircleDialog)
deleteAllAction.triggered.connect(self.deleteAll)
- pass
def createToolBars(self):
# Creating toolBars
# Connecting slots
createPolylineAction.triggered.connect(self.showCreatePolylineDialog)
createCircleAction.triggered.connect(self.showCreateCircleDialog)
- pass
def showCreatePolylineDialog(self):
from CreatePolylineDialog import CreatePolylineDialog
widgetDialogBox.setWidget(myDialog)
widgetDialogBox.setWindowTitle("Polyline definition")
self.addDockWidget(Qt.LeftDockWidgetArea, widgetDialogBox)
- pass
def showCreateCircleDialog(self):
from CreateCircleDialog import CreateCircleDialog
widgetDialogBox.setWidget(myDialog)
widgetDialogBox.setWindowTitle("Polyline definition")
self.addDockWidget(Qt.LeftDockWidgetArea, widgetDialogBox)
- pass
def deleteAll(self):
models = self.getController().getModels()
if answer == QMessageBox.Yes:
for model in models:
self.getController().removeModel(model)
- pass
- pass
- pass
def updateGlobalGraphicsView(self, scene):
self._globalGraphicsView.setScene(scene)
topLeft.x(), topLeft.y(), 2 * sceneRect.width(), 2 * sceneRect.height()
)
self._globalGraphicsView.fitInView(viewRect, Qt.IgnoreAspectRatio)
- pass
-pass
if __name__ == "__main__":
main(sys.argv)
- pass
class CircleGraphicsScene(GraphicsScene):
def __init__(self, controller):
GraphicsScene.__init__(self, controller)
- pass
def draw(self):
- import math
+ pass
center = self._model.getCenter()
radius = float(self._model.getRadius())
circleItem = QGraphicsEllipseItem()
circleItem.setRect(rect)
self.addItem(circleItem)
- pass
-pass
"""Constructor"""
TreeWidgetItem.__init__(self, name, controller, actionsList)
- pass
def editInGlobalTree(self, treeWidgetItem):
name = self.getModel().getName()
radius = self._model.getRadius()
relatedItem = treeWidgetItem.child(1)
relatedItem.setText(0, str(radius))
- pass
-pass
self._index = index
self.setFlag(self.ItemIsMovable, True)
self.setFlag(self.ItemIsSelectable, True)
- pass
def getIndex(self):
return self._index
-pass
View.__init__(self, controller)
QGraphicsScene.__init__(self)
- pass
def getRect(self):
rect = QRectF(0, 0, self.width(), self.height())
def editPoint(self, oldPoint, newPoint):
polyline = self.getModel()
self.getController().editPoint(polyline, oldPoint, newPoint)
- pass
def editCenter(self, center):
circle = self.getModel()
self.getController().editCenter(circle, center)
- pass
def editRadius(self, radius):
circle = self.getModel()
self.getController().editRadius(circle, radius)
- pass
def update(self, mode):
if mode == "creation":
self.showInGlobalGraphicsView()
- pass
elif mode == "showing":
self.showInGlobalGraphicsView()
elif mode == "modification":
self.undraw()
self.showInGlobalGraphicsView()
- pass
elif mode == "supression":
self.removeFromGlobalGraphicsView()
- pass
else:
return
def showInGlobalGraphicsView(self):
self.draw()
self.getController().getMainFrame().updateGlobalGraphicsView(self)
- pass
def removeFromGlobalGraphicsView(self):
self.getController().getMainFrame().updateGlobalGraphicsView(None)
- pass
def draw(self):
print("Virtual method")
- pass
def undraw(self):
for item in self.items():
self.removeItem(item)
- pass
- pass
-pass
self._selectedItem = None
self.moved[QPointF].connect(self.execMouseMoveEvent)
self.released[QPointF].connect(self.execMouseReleaseEvent)
- pass
def mousePressEvent(self, mouseEvent):
QGraphicsView.mousePressEvent(self, mouseEvent)
if self.scene() is None:
return
self._selectedItem = self.scene().mouseGrabberItem()
- pass
def mouseMoveEvent(self, mouseEvent):
QGraphicsView.mouseMoveEvent(self, mouseEvent)
pt = mouseEvent.pos()
currentPos = self.mapToScene(pt)
self.moved.emit(currentPos)
- pass
def mouseReleaseEvent(self, mouseEvent):
QGraphicsView.mouseReleaseEvent(self, mouseEvent)
newPos = self.mapToScene(pt)
self.released.emit(newPos)
self._selectedItem = None
- pass
- pass
def execMouseMoveEvent(self, currentPos):
if self._selectedItem is None:
selectedIndex = self._selectedItem.getIndex()
newX = currentPos.x()
newY = currentPos.y()
- newPoint = newX, newY
+ newX, newY
model = self.scene().getModel()
pen = QPen(QColor("red"))
if isinstance(model, Polyline):
xNext = nextPoint[0]
yNext = nextPoint[1]
self.scene().addLine(newX, newY, xNext, yNext, pen)
- pass
elif selectedIndex == len(model.getPoints()) - 1:
previousPoint = model.getPoints()[selectedIndex - 1]
xPrevious = previousPoint[0]
yPrevious = previousPoint[1]
self.scene().addLine(xPrevious, yPrevious, newX, newY, pen)
- pass
else:
previousPoint = model.getPoints()[selectedIndex - 1]
xPrevious = previousPoint[0]
xNext = nextPoint[0]
yNext = nextPoint[1]
self.scene().addLine(newX, newY, xNext, yNext, pen)
- pass
- pass
elif isinstance(model, Circle):
# Previsualisation
radius = float(model.getRadius())
circleItem.setPen(pen)
circleItem.setRect(rect)
self.scene().addItem(circleItem)
- pass
- pass
def execMouseReleaseEvent(self, newPos):
if self._selectedItem is None:
model = self.scene().getModel()
if isinstance(model, Polyline):
self.scene().getController().editPoint(model, newPoint, selectedIndex)
- pass
elif isinstance(model, Circle):
self.scene().getController().editCenter(model, newPoint)
- pass
- pass
-pass
QMenu.__init__(self)
self._item = item
- pass
def getItem(self):
return self._item
-pass
class PolyGraphicsScene(GraphicsScene):
def __init__(self, controller):
GraphicsScene.__init__(self, controller)
- pass
def draw(self):
points = self.getModel().getPoints()
# Constructing a rectangle centered on point
pointItem = GraphicsRectItem(xPoint - 0.1, yPoint - 0.1, 0.2, 0.2, i)
self.addItem(pointItem)
- pass
# Linking the points with lines
for i in range(len(points) - 1):
lineItem = QGraphicsLineItem()
lineItem.setLine(line)
self.addItem(lineItem)
- pass
- pass
-pass
"""Constructor"""
TreeWidgetItem.__init__(self, name, controller, actionsList)
- pass
def editInGlobalTree(self, treeWidgetItem):
name = self.getModel().getName()
yPoint = point[1]
relatedItem = treeWidgetItem.child(i)
relatedItem.setText(0, str(xPoint) + ":" + str(yPoint))
- pass
- pass
-pass
# Creating popup menu
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.customContextMenuRequested[QPoint].connect(self.createPopups)
- pass
def createPopups(self, point):
item = self.itemAt(point)
for action in item.getActionsList():
if action == "Show":
self.menu.addAction(action).triggered.connect(self.show)
- pass
elif action == "Rename":
self.menu.addAction(action).triggered.connect(self.showRenameDialog)
- pass
elif action == "Delete":
self.menu.addAction(action).triggered.connect(self.delete)
- pass
else:
self.menu.addAction(action).triggered.connect(self.showEditDialog)
- pass
- pass
self.menu.exec_(QCursor.pos())
- pass
def show(self):
model = self.menu.getItem().getModel()
controller = self._desktop.getController()
controller.showModel(model)
- pass
def showRenameDialog(self):
model = self.menu.getItem().getModel()
widgetDialogBox.setWidget(myDialog)
widgetDialogBox.setWindowTitle("Object renaming")
sgDesktop.addDockWidget(Qt.LeftDockWidgetArea, widgetDialogBox)
- pass
def delete(self):
answer = QMessageBox.question(
model = self.menu.getItem().getModel()
controller = self._desktop.getController()
controller.removeModel(model)
- pass
- pass
def showEditDialog(self):
item = self.menu.getItem()
oldPoint,
pointRange,
)
- pass
elif isinstance(parentModel, Circle):
selectedRange = parentItem.indexOfChild(item)
oldSelected = item.text(0)
)
else:
pass
- pass
else:
pass
widgetDialogBox.setWidget(myDialog)
widgetDialogBox.setWindowTitle("Object edition")
sgDesktop.addDockWidget(Qt.LeftDockWidgetArea, widgetDialogBox)
- pass
-pass
self._name = [name]
QTreeWidgetItem.__init__(self, self._name)
self._actionsList = actionsList
- pass
def getActionsList(self):
return self._actionsList
def editCenter(self, center):
circle = self.getModel()
self.getController().editCenter(circle, center)
- pass
def editRadius(self, radius):
circle = self.getModel()
self.getController().editRadius(circle, radius)
- pass
def update(self, mode):
if mode == "creation":
self.addToGlobalTree(self)
- pass
elif mode == "modification":
self.editInGlobalTree(self)
- pass
elif mode == "supression":
self.removeFromGlobalTree(self)
- pass
else:
return
def addToGlobalTree(self, treeWidgetItem):
globalTree = self.getController().getMainFrame().getGlobalTree()
globalTree.addTopLevelItem(treeWidgetItem)
- pass
def editInGlobalTree(self, treeWidgetItem):
print("Virtual")
- pass
def removeFromGlobalTree(self, treeWidgetItem):
globalTree = self.getController().getMainFrame().getGlobalTree()
globalTree.takeTopLevelItem(globalTree.indexOfTopLevelItem(treeWidgetItem))
- pass
-pass
self._model = None
self._controller = controller
- pass
def getModel(self):
return self._model
def setModel(self, model):
self._model = model
- pass
def getController(self):
return self._controller
def setController(self, controller):
self._controller = controller
- pass
def editName(self, name):
model = self.getModel()
self._controller.editName(model, name)
- pass
def update(self, mode):
print("Virtual method")
- pass
-pass
self._mainFrame = MainFrame
self._nbPolylines = 0
self._nbCircles = 0
- pass
def getModels(self):
return self._models
def setNbPolylines(self, n):
self._nbPolylines = n
- pass
def getNbCircles(self):
return self._nbCircles
def setNbCircles(self, n):
self._nbCircles = n
- pass
def createPolyline(self, name, randomNumberOfPoints):
"""Creates a Polyline object nammed name with randomNumberOfPoints points"""
y = random.uniform(0, x)
point = x, y
points.append(point)
- pass
myPolyline = Polyline(name, points, self)
self._models.append(myPolyline)
def showModel(self, model):
model.updateViews(mode="showing")
- pass
def editName(self, model, name):
model.setName(name)
def removeModel(self, model):
model.updateViews(mode="supression")
- index = self._models.index(model)
+ self._models.index(model)
del model
- pass
def saveListOfModels(self):
for model in self._models:
model.save()
- pass
- pass
-pass
# Setting default name
nbCircles = controller.getNbCircles()
self.entryName.setText("circle_" + str(nbCircles + 1))
- pass
def addSpecialWidgets(self):
floatValidator = QDoubleValidator(self)
self.entryRadius.setValidator(floatValidator)
self.entryRadius.setText("10")
self.v12.addWidget(self.entryRadius)
- pass
def execApply(self):
name = self.name
self.xCenter = str(self.entryxCenter.text())
self.yCenter = str(self.entryyCenter.text())
self.radius = str(self.entryRadius.text())
- pass
def checkUserEntries(self):
if (
self.entryxCenter.setText("0")
self.entryyCenter.setText("0")
self.entryRadius.setText("10")
- pass
-pass
# Setting default name
nbPolylines = controller.getNbPolylines()
self.entryName.setText("polyline_" + str(nbPolylines + 1))
- pass
def addSpecialWidgets(self):
self.entryNbPoints.setValidator(intValidator)
self.entryNbPoints.setText("10")
self.v12.addWidget(self.entryNbPoints)
- pass
def execApply(self):
name = self.name
def retrieveUserEntries(self):
self.name = str(self.entryName.text())
self.nbPoints = str(self.entryNbPoints.text())
- pass
def checkUserEntries(self):
if self.name == "" or self.nbPoints == "":
nbPolylines = self.getController().getNbPolylines()
self.entryName.setText("polyline_" + str(nbPolylines + 1))
self.entryNbPoints.setText("10")
- pass
-pass
# Connecting widgets to slots
self.connectSlots()
- pass
def getController( self ) :
return self._controller
self.h2.addWidget( self.bClose )
self.bHelp = QPushButton( "Help", self )
self.h2.addWidget( self.bHelp )
- pass
def addSpecialWidgets( self ) :
print 'Virtual method'
- pass
def connectSlots( self ) :
self.bApply.clicked.connect(self.apply)
self.bHelp.clicked.connect(self.help)
self.bClose.clicked.connect(self.close)
- pass
def apply( self ) :
def retrieveUserEntries( self ) :
self.name = str( self.entryName.text() )
- pass
def checkUserEntries( self ) :
if self.name == "" :
def execApply( self ) :
print 'Virtual method'
- pass
def reInitializeDialog( self ) :
print 'Virtual method'
- pass
def help( self ) :
import os
os.system( 'firefox ' + self._helpFile + '&' )
- pass
def close( self ) :
self._widgetDialogBox.close()
- pass
-pass
# Connecting widgets to slots
self.connectSlots()
- pass
def getController( self ) :
return self._controller
self.h2.addWidget( self.bCancel )
self.bHelp = QPushButton( "Help", self )
self.h2.addWidget( self.bHelp )
- pass
def addSpecialWidgets( self ) :
print 'Virtual method'
- pass
def connectSlots( self ) :
self.bOk.clicked.connect(self.apply)
self.bHelp.clicked.connect(self.help)
self.bCancel.clicked.connect(self.close)
- pass
def apply( self ) :
self.retrieveUserEntries()
def retrieveUserEntries( self ) :
print 'Virtual method'
- pass
def checkUserEntries( self ) :
print 'Virtual method'
def execApply( self ) :
print 'Virtual method'
- pass
def help( self ) :
import os
os.system( 'firefox ' + self._helpFile + '&' )
- pass
def close( self ) :
self._widgetDialogBox.close()
- pass
-pass
while oldCenter[i] != ":":
oldX += oldCenter[i]
i += 1
- pass
for j in range(i + 1, len(oldCenter)):
oldY += oldCenter[j]
- pass
self.entryX.setText(oldX)
self.entryY.setText(oldY)
- pass
def addSpecialWidgets(self):
floatValidator = QDoubleValidator(self)
self.entryY = QLineEdit(self)
self.entryY.setValidator(floatValidator)
self.v12.addWidget(self.entryY)
- pass
def execApply(self):
newX = float(self.newX)
def retrieveUserEntries(self):
self.newX = str(self.entryX.text())
self.newY = str(self.entryY.text())
- pass
def checkUserEntries(self):
if self.newX == "" or self.newY == "":
return True
-pass
while oldPoint[i] != ":":
oldX += oldPoint[i]
i += 1
- pass
for j in range(i + 1, len(oldPoint)):
oldY += oldPoint[j]
- pass
self.pointRange = pointRange
self.entryX.setText(oldX)
self.entryY.setText(oldY)
- pass
def addSpecialWidgets(self):
floatValidator = QDoubleValidator(self)
self.entryY = QLineEdit(self)
self.entryY.setValidator(floatValidator)
self.v12.addWidget(self.entryY)
- pass
def execApply(self):
pointRange = self.pointRange
def retrieveUserEntries(self):
self.newX = str(self.entryX.text())
self.newY = str(self.entryY.text())
- pass
def checkUserEntries(self):
if self.newX == "" or self.newY == "":
return True
-pass
self._model = model
self.entryRadius.setText(oldRadius)
- pass
def addSpecialWidgets(self):
floatValidator = QDoubleValidator(self)
self.entryRadius = QLineEdit(self)
self.entryRadius.setValidator(floatValidator)
self.v12.addWidget(self.entryRadius)
- pass
def execApply(self):
newRadius = self.newRadius
def retrieveUserEntries(self):
self.newRadius = str(self.entryRadius.text())
- pass
def checkUserEntries(self):
if self.newRadius == "":
return True
-pass
self._model = model
self.entryName.setText(oldName)
- pass
def addSpecialWidgets(self):
lName = QLabel("Name", self)
self.v11.addWidget(lName)
self.entryName = QLineEdit(self)
self.v12.addWidget(self.entryName)
- pass
def execApply(self):
newName = self.newName
def retrieveUserEntries(self):
self.newName = str(self.entryName.text())
- pass
def checkUserEntries(self):
if self.newName == "":
return True
-pass
self._radius = radius
self.addTreeWidgetItem(self.getName(), controller)
self.addGraphicScene(controller)
- pass
def getCenter(self):
return self._center[0], self._center[1]
def setCenter(self, center):
self._center = center
- pass
def getRadius(self):
return self._radius
pass
-pass
self._name = None
self._views = []
- pass
def getName( self ):
return self._name
def setName( self, name ):
self._name = name
- pass
def getViews( self ) :
return self._views
def save( self ) :
print 'Virtual method'
- pass
-pass
self._points = points
self.addTreeWidgetItem(self.getName(), controller)
self.addGraphicScene(controller)
- pass
def getPoints(self):
return self._points
def setPoints(self, points):
self._points = points
- pass
def editPoint(self, pointRange, newPoint):
self._points[pointRange] = newPoint
- pass
def addTreeWidgetItem(self, name, controller):
from PolyTreeWidgetItem import PolyTreeWidgetItem
str(x) + ":" + str(y), controller, ["Edit"]
)
myTreeWidgetItem.addChild(newTreeWidgetItem)
- pass
myTreeWidgetItem.setModel(self)
self.getViews().append(myTreeWidgetItem)
return myTreeWidgetItem
pass
-pass
#
self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
#
- pass
"""
Touch the component
attr.SetValue( name )
attr = builder.FindOrCreateAttribute( object, "AttributeLocalID" )
attr.SetValue( objectID() )
- pass
"""
Dump module data to the Python script.
name = iter.Value().GetName()
if name: names.append( name )
iter.Next()
- pass
- pass
if names:
abuffer += [ " from batchmode_salome import lcc" ]
abuffer += [ " import :sat:{PYCMP}_ORB" ]
abuffer += [ " myCompo = lcc.FindOrLoadComponent( 'FactoryServerPy', '%s' )" % moduleName() ]
abuffer += [ " " ]
abuffer += [ " myCompo.createObject( theStudy, '%s' )" % name for name in names ]
- pass
abuffer += [ " " ]
abuffer.append( " pass" )
abuffer.append( "\0" )
__verbose__ = int( os.getenv( 'SALOME_VERBOSE', 0 ) )
except:
__verbose__ = 0
- pass
- pass
return __verbose__
###
global __orb__
if __orb__ is None:
__orb__ = CORBA.ORB_init( [''], CORBA.ORB_ID )
- pass
return __orb__
###
global __naming_service__
if __naming_service__ is None:
__naming_service__ = SALOME_NamingServicePy_i( getORB() )
- pass
return __naming_service__
##
global __lcc__
if __lcc__ is None:
__lcc__ = LifeCycleCORBA( getORB() )
- pass
return __lcc__
##
if __study_manager__ is None:
obj = getNS().Resolve( '/myStudyManager' )
__study_manager__ = obj._narrow( SALOMEDS.StudyManager )
- pass
return __study_manager__
###
global __engine__
if __engine__ is None:
__engine__ = getLCC().FindOrLoadComponent( "FactoryServerPy", moduleName() )
- pass
return __engine__
###
IOR = ""
if getORB() and getEngine():
IOR = getORB().object_to_string( getEngine() )
- pass
return IOR
###
attr.SetValue( moduleID() )
try:
builder.DefineComponentInstance( father, getEngine() )
- pass
except:
pass
- pass
return father
###
if sobj is not None:
test, anAttr = sobj.FindAttribute( "AttributeLocalID" )
if test: ID = anAttr._narrow( SALOMEDS.AttributeLocalID ).Value()
- pass
- pass
return ID
self.createTreeView()
self.createGraphicsView()
- pass
def createTreeView( self ) :
self._globalTree= TreeWidget( self )
self._dockGlobalTree.setAllowedAreas( Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea )
self._dockGlobalTree.setWidget( self._globalTree )
self._sgDesktop.addDockWidget( Qt.LeftDockWidgetArea, self._dockGlobalTree )
- pass
def createGraphicsView( self ) :
scene = GraphicsScene( self._controller )
self._globalGraphicsView = GraphicsView( scene )
self._globalGraphicsViewID = self._sgPyQt.createView( "ViewCurve", self._globalGraphicsView )
- pass
def createActions( self ) :
self.createPolylineAction = self._sgPyQt.createAction( self._polylineID, "Polyline", "Create Polyline", "Show Polyline dialog box", "ExecPolyline.png" )
self.createCircleAction = self._sgPyQt.createAction( self._circleID, "Circle", "Create Circle", "Show Circle dialog box", "ExecCircle.png" )
self.deleteAllAction = self._sgPyQt.createAction( self._deleteAllID, "Delete all", "Delete all", "Delete all objects", "ExecDelAll.png" )
- pass
def createMenus( self ) :
curveMenu = self._sgPyQt.createMenu( " Curve", -1, self._curveMenuID, self._sgPyQt.defaultMenuGroup() )
self._sgPyQt.createMenu( self.createPolylineAction, curveMenu )
self._sgPyQt.createMenu( self.createCircleAction, curveMenu )
self._sgPyQt.createMenu( self.deleteAllAction, advancedMenu )
- pass
def createToolBars( self ) :
createPolylineTB = self._sgPyQt.createTool("New polyline")
self._sgPyQt.createTool( self.createPolylineAction, createPolylineTB )
self._sgPyQt.createTool( self.createCircleAction, createCircleTB )
self._sgPyQt.createTool( self.deleteAllAction, deleteAllTB )
- pass
def createPopups( self ) :
pass
def setController( self, controller ) :
self._controller = controller
- pass
def getGlobalTree( self ) :
return self._globalTree
#Resizing the globalGraphicView
sceneRect = scene.getRect()
self._globalGraphicsView.fitInView ( sceneRect, Qt.KeepAspectRatio )
- pass
-pass
moduleDesktop[studyID] = :sat:{PYCMP}Desktop( sgPyQt, sg )
objectsManager = Controller( moduleDesktop[studyID] )
moduleDesktop[studyID].setController( objectsManager )
- pass
currentDesktop = moduleDesktop[studyID]
return currentDesktop
if id not in m: m[id] = 0
m[id] += 1
- pass
def getSelection():
"""This method analyses selection"""
seltypes = {}
for i in range( selcount ):
incObjToMap( seltypes, getObjectID( getStudy(), sg.getSelected( i ) ) )
- pass
return selcount, seltypes
################################################
"""This method is called when module is initialized. It performs initialization actions"""
setDesktop( getStudyId() )
- pass
def windows():
"""This method is called when module is initialized. It returns a map of popup windows to be used by the module"""
def createPreferences():
"""This method is called when module is initialized. It exports module preferences"""
- pass
def activate():
"""This method is called when module is initialized. It returns True if activating is successfull, False otherwise"""
def viewTryClose( wid ):
sgPyQt.setViewClosable(wid, True)
- pass
def deactivate():
"""This method is called when module is deactivated"""
moduleDesktop[getStudyId()].getDockGlobalTree().hide()
moduleDesktop[getStudyId()].updateGlobalGraphicsView( None )
moduleDesktop[getStudyId()].getGlobalGraphicsView().hide()
- pass
def activeStudyChanged( studyID ):
"""This method is called when active study is changed"""
setDesktop( getStudyId() )
- pass
def createPopupMenu( popup, context ):
"""This method is called when popup menu is invocked"""
- pass
def OnGUIEvent( commandID ):
"""This method is called when a GUI action is activated"""
if commandID in dict_command:
dict_command[commandID]()
- pass
- pass
def preferenceChanged( section, setting ):
"""This method is called when module's preferences are changed"""
- pass
def activeViewChanged( viewID ):
"""This method is called when active view is changed"""
- pass
def viewCloned( viewID ):
"""This method is called when active view is cloned"""
- pass
def viewClosed( viewID ):
"""This method is called when active view viewClosed"""
- pass
def engineIOR():
"""This method is called when study is opened. It returns engine IOR"""
widgetDialogBox.setWidget( myDialog )
widgetDialogBox.setWindowTitle( "Polyline definition" )
sgDesktop.addDockWidget(Qt.LeftDockWidgetArea, widgetDialogBox)
- pass
def showCreateCircleDialog() :
from CreateCircleDialog import CreateCircleDialog
widgetDialogBox.setWidget( myDialog )
widgetDialogBox.setWindowTitle( "Circle definition" )
sgDesktop.addDockWidget(Qt.LeftDockWidgetArea, widgetDialogBox)
- pass
def deleteAll() :
models = moduleDesktop[getStudyId()].getController().getModels()
if answer == QMessageBox.Yes :
for model in models :
moduleDesktop[getStudyId()].getController().removeModel( model )
- pass
- pass
- pass
########################################################
# Commands dictionary
# Creating menus and toolbars
self.createMenus()
self.createToolBars()
- pass
def getController(self):
return self._controller
def setController(self, controller):
self._controller = controller
- pass
def getGlobalTree(self):
return self._globalTree
createPolylineAction.triggered.connect(self.showCreatePolylineDialog)
createCircleAction.triggered.connect(self.showCreateCircleDialog)
deleteAllAction.triggered.connect(self.deleteAll)
- pass
def createToolBars(self):
# Creating toolBars
# Connecting slots
createPolylineAction.triggered.connect(self.showCreatePolylineDialog)
createCircleAction.triggered.connect(self.showCreateCircleDialog)
- pass
def showCreatePolylineDialog(self):
from CreatePolylineDialog import CreatePolylineDialog
widgetDialogBox.setWidget(myDialog)
widgetDialogBox.setWindowTitle("Polyline definition")
self.addDockWidget(Qt.LeftDockWidgetArea, widgetDialogBox)
- pass
def showCreateCircleDialog(self):
from CreateCircleDialog import CreateCircleDialog
widgetDialogBox.setWidget(myDialog)
widgetDialogBox.setWindowTitle("Polyline definition")
self.addDockWidget(Qt.LeftDockWidgetArea, widgetDialogBox)
- pass
def deleteAll(self):
models = self.getController().getModels()
if answer == QMessageBox.Yes:
for model in models:
self.getController().removeModel(model)
- pass
- pass
- pass
def updateGlobalGraphicsView(self, scene):
self._globalGraphicsView.setScene(scene)
topLeft.x(), topLeft.y(), 2 * sceneRect.width(), 2 * sceneRect.height()
)
self._globalGraphicsView.fitInView(viewRect, Qt.IgnoreAspectRatio)
- pass
-pass
if __name__ == "__main__":
main(sys.argv)
- pass
class CircleGraphicsScene(GraphicsScene):
def __init__(self, controller):
GraphicsScene.__init__(self, controller)
- pass
def draw(self):
- import math
+ pass
center = self._model.getCenter()
radius = float(self._model.getRadius())
circleItem = QGraphicsEllipseItem()
circleItem.setRect(rect)
self.addItem(circleItem)
- pass
-pass
"""Constructor"""
TreeWidgetItem.__init__(self, name, controller, actionsList)
- pass
def editInGlobalTree(self, treeWidgetItem):
name = self.getModel().getName()
radius = self._model.getRadius()
relatedItem = treeWidgetItem.child(1)
relatedItem.setText(0, str(radius))
- pass
-pass
self._index = index
self.setFlag(self.ItemIsMovable, True)
self.setFlag(self.ItemIsSelectable, True)
- pass
def getIndex(self):
return self._index
-pass
View.__init__( self, controller )
QGraphicsScene.__init__( self )
- pass
def getRect( self ) :
rect = QRectF( 0, 0, self.width(), self.height() )
def editPoint( self, oldPoint, newPoint ) :
polyline = self.getModel()
self.getController().editPoint( polyline, oldPoint, newPoint )
- pass
def editCenter( self, center ) :
circle = self.getModel()
self.getController().editCenter( circle, center )
- pass
def editRadius( self, radius ) :
circle = self.getModel()
self.getController().editRadius( circle, radius )
- pass
def update( self, mode ) :
if mode == 'creation' :
self.showInGlobalGraphicsView()
- pass
elif mode == "showing" :
self.showInGlobalGraphicsView()
elif mode == 'modification' :
self.undraw()
self.showInGlobalGraphicsView()
- pass
elif mode == 'supression' :
self.removeFromGlobalGraphicsView()
- pass
else :
return
def showInGlobalGraphicsView( self ) :
self.draw()
self.getController().getMainFrame().updateGlobalGraphicsView( self )
- pass
def removeFromGlobalGraphicsView( self ) :
self.getController().getMainFrame().updateGlobalGraphicsView( None )
- pass
def draw( self ) :
print 'Virtual method'
- pass
def undraw( self ) :
for item in self.items() :
self.removeItem( item )
- pass
- pass
-pass
self._selectedItem = None
self.moved[QPointF].connect(self.execMouseMoveEvent)
self.released[QPointF].connect(self.execMouseReleaseEvent)
- pass
def mousePressEvent(self, mouseEvent):
QGraphicsView.mousePressEvent(self, mouseEvent)
if self.scene() is None:
return
self._selectedItem = self.scene().mouseGrabberItem()
- pass
def mouseMoveEvent(self, mouseEvent):
QGraphicsView.mouseMoveEvent(self, mouseEvent)
pt = mouseEvent.pos()
currentPos = self.mapToScene(pt)
self.moved.emit(currentPos)
- pass
def mouseReleaseEvent(self, mouseEvent):
QGraphicsView.mouseReleaseEvent(self, mouseEvent)
newPos = self.mapToScene(pt)
self.released.emit(newPos)
self._selectedItem = None
- pass
- pass
def execMouseMoveEvent(self, currentPos):
if self._selectedItem is None:
selectedIndex = self._selectedItem.getIndex()
newX = currentPos.x()
newY = currentPos.y()
- newPoint = newX, newY
+ newX, newY
model = self.scene().getModel()
pen = QPen(QColor("red"))
if isinstance(model, Polyline):
xNext = nextPoint[0]
yNext = nextPoint[1]
self.scene().addLine(newX, newY, xNext, yNext, pen)
- pass
elif selectedIndex == len(model.getPoints()) - 1:
previousPoint = model.getPoints()[selectedIndex - 1]
xPrevious = previousPoint[0]
yPrevious = previousPoint[1]
self.scene().addLine(xPrevious, yPrevious, newX, newY, pen)
- pass
else:
previousPoint = model.getPoints()[selectedIndex - 1]
xPrevious = previousPoint[0]
xNext = nextPoint[0]
yNext = nextPoint[1]
self.scene().addLine(newX, newY, xNext, yNext, pen)
- pass
- pass
elif isinstance(model, Circle):
# Previsualisation
radius = float(model.getRadius())
circleItem.setPen(pen)
circleItem.setRect(rect)
self.scene().addItem(circleItem)
- pass
- pass
def execMouseReleaseEvent(self, newPos):
if self._selectedItem is None:
model = self.scene().getModel()
if isinstance(model, Polyline):
self.scene().getController().editPoint(model, newPoint, selectedIndex)
- pass
elif isinstance(model, Circle):
self.scene().getController().editCenter(model, newPoint)
- pass
- pass
-pass
QMenu.__init__(self)
self._item = item
- pass
def getItem(self):
return self._item
-pass
class PolyGraphicsScene(GraphicsScene):
def __init__(self, controller):
GraphicsScene.__init__(self, controller)
- pass
def draw(self):
points = self.getModel().getPoints()
# Constructing a rectangle centered on point
pointItem = GraphicsRectItem(xPoint - 0.1, yPoint - 0.1, 0.2, 0.2, i)
self.addItem(pointItem)
- pass
# Linking the points with lines
for i in range(len(points) - 1):
lineItem = QGraphicsLineItem()
lineItem.setLine(line)
self.addItem(lineItem)
- pass
- pass
-pass
"""Constructor"""
TreeWidgetItem.__init__(self, name, controller, actionsList)
- pass
def editInGlobalTree(self, treeWidgetItem):
name = self.getModel().getName()
yPoint = point[1]
relatedItem = treeWidgetItem.child(i)
relatedItem.setText(0, str(xPoint) + ":" + str(yPoint))
- pass
- pass
-pass
# Creating popup menu
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.customContextMenuRequested[QPoint].connect(self.createPopups)
- pass
def createPopups(self, point):
item = self.itemAt(point)
for action in item.getActionsList():
if action == "Show":
self.menu.addAction(action).triggered.connect(self.show)
- pass
elif action == "Rename":
self.menu.addAction(action).triggered.connect(self.showRenameDialog)
- pass
elif action == "Delete":
self.menu.addAction(action).triggered.connect(self.delete)
- pass
else:
self.menu.addAction(action).triggered.connect(self.showEditDialog)
- pass
- pass
self.menu.exec_(QCursor.pos())
- pass
def show(self):
model = self.menu.getItem().getModel()
controller = self._desktop.getController()
controller.showModel(model)
- pass
def showRenameDialog(self):
model = self.menu.getItem().getModel()
widgetDialogBox.setWidget(myDialog)
widgetDialogBox.setWindowTitle("Object renaming")
sgDesktop.addDockWidget(Qt.LeftDockWidgetArea, widgetDialogBox)
- pass
def delete(self):
answer = QMessageBox.question(
model = self.menu.getItem().getModel()
controller = self._desktop.getController()
controller.removeModel(model)
- pass
- pass
def showEditDialog(self):
item = self.menu.getItem()
oldPoint,
pointRange,
)
- pass
elif isinstance(parentModel, Circle):
selectedRange = parentItem.indexOfChild(item)
oldSelected = item.text(0)
)
else:
pass
- pass
else:
pass
widgetDialogBox.setWidget(myDialog)
widgetDialogBox.setWindowTitle("Object edition")
sgDesktop.addDockWidget(Qt.LeftDockWidgetArea, widgetDialogBox)
- pass
-pass
self._name = [ name ]
QTreeWidgetItem.__init__( self, self._name )
self._actionsList = actionsList
- pass
def getActionsList( self ) :
return self._actionsList
def editCenter( self, center ) :
circle = self.getModel()
self.getController().editCenter( circle, center )
- pass
def editRadius( self, radius ) :
circle = self.getModel()
self.getController().editRadius( circle, radius )
- pass
def update( self, mode ) :
if mode == 'creation' :
self.addToGlobalTree( self )
- pass
elif mode == 'modification' :
self.editInGlobalTree( self )
- pass
elif mode == 'supression' :
self.removeFromGlobalTree( self )
- pass
else :
return
def addToGlobalTree( self, treeWidgetItem ) :
globalTree = self.getController().getMainFrame().getGlobalTree()
globalTree.addTopLevelItem( treeWidgetItem )
- pass
def editInGlobalTree( self, treeWidgetItem ) :
print 'Virtual'
- pass
def removeFromGlobalTree( self, treeWidgetItem ) :
globalTree = self.getController().getMainFrame().getGlobalTree()
globalTree.takeTopLevelItem( globalTree.indexOfTopLevelItem(treeWidgetItem) )
- pass
-pass
self._model = None
self._controller = controller
- pass
def getModel( self ) :
return self._model
def setModel( self, model ) :
self._model = model
- pass
def getController( self ) :
return self._controller
def setController( self, controller ) :
self._controller = controller
- pass
def editName( self, name ) :
model = self.getModel()
self._controller.editName( model, name )
- pass
def update( self, mode ) :
print 'Virtual method'
- pass
-pass
# All configuration values have a default; values that are commented out
# serve to show the default.
-import sys
-import os
# https://stackoverflow.com/questions/23462494/how-to-add-a-custom-css-file-to-sphinx
"""
- pass
# --------------------------------------------------------------------
import errno
import stat
import fnmatch
-import pprint as PP
from ftplib import FTP
from . import pyconf
import os
import sys
import inspect
-import logging
-import pprint as PP
##############################################################################
def GetConsoleScreenBufferInfo(stream_id=STDOUT):
handle = handles[stream_id]
csbi = CONSOLE_SCREEN_BUFFER_INFO()
- success = _GetConsoleScreenBufferInfo(handle, byref(csbi))
+ _GetConsoleScreenBufferInfo(handle, byref(csbi))
return csbi
def SetConsoleTextAttribute(stream_id, attrs):
class InStream(StringIO):
"""utility class for pyconf.Config input iostream"""
- pass
def getLocalEnv():
"""
try: # type config, mapping
- order = object.__getattribute__(config, "order")
+ object.__getattribute__(config, "order")
data = object.__getattribute__(config, "data")
except:
aStream.write("%s%s : '%s'\n" % (indstr, path, str(config)))
zt.delimiter = delim
try:
value = zt.substitute(self.environ)
- except KeyError as exc:
+ except KeyError:
pass
# raise src.SatException(_("Missing definition "
# "in environment: %s") % str(exc))
import os
import sys
import time
-import pickle
import subprocess
# OP
if __name__ == "__main__":
verbose = False
unittest.main()
- pass
import os
import sys
-import time
-import random
import logging as LOGI
-from logging.handlers import BufferingHandler
import pprint as PP
import src.debug as DBG # Easy print stderr (for DEBUG only)
if self.args:
try: # better message on format error
msg = msg % self.args
- except Exception as e:
+ except Exception:
msg = "ERROR: %s with args %s" % (msg, PP.pformat(self.args))
log(msg, True)
return msg
if prod_name == prod_info.name:
if prod_info.version == compile_cfg[prod_name]:
DBG.write("check_config_exists OK 333", compile_cfg, verbose)
- pass
else: # no correspondence with newer with prod_name sat-config.pyconf files
config_corresponds = False
break
This is the base class of exceptions raised by this module.
"""
- pass
class ConfigFormatError(ConfigError):
configurations.
"""
- pass
class ConfigResolutionError(ConfigError):
configurations.
"""
- pass
def isWord(s):
break
except:
rv = None
- pass
current = object.__getattribute__(current, "parent")
if current is None:
raise ConfigResolutionError(
import imp
import types
import gettext
-import traceback
import src
import src.debug as DBG # Easy print stderr (for DEBUG only)
if self.options.debug_mode:
logger_command.write("\n" + DBG.format_exception("") + "\n", 1)
- except Exception as e:
+ except Exception:
# here we print the stack in addition
logger_command.write("\n***** ", 1)
logger_command.write(
self.base_ressources_dir = base_ressources_dir
self.tmp_dir = tmp_dir
self.test_ressources_dir = test_ressources_dir
- pass
def init(self):
self.inFiles = []
pylog.write('status = "OK"\n')
pylog.write('time = "' + timeTest.__str__() + '"\n')
- pass
# print("here testout.flush")
testout.flush()
# testout.close()
sys.stdout = __stdout__
sys.stderr = __stderr__
my_tools.writeInFiles(pylog)
- pass
pylog.flush()
# pylog.close()
exec_result.write('Close\n')
- pass
# exec_result.close()
if 'PY' not in '${sessionName}':
import string
import imp
import subprocess
-import glob
import pprint as PP
verbose = False
if verbose:
print("--- CRASH ldic\n%s" % PP.pformat(ldic)) # cvw TODO
print("--- CRASH gdic\n%s" % PP.pformat(gdic))
- pass
exec_time = -1
if "time" in ldic:
subproc_res = subprocess.Popen(
cmd, stdout=subprocess.PIPE, shell=True
).communicate()
- pass
else:
subproc_res = subprocess.Popen(
cmd, stdout=subprocess.PIPE, shell=True, executable="/bin/bash"
).communicate()
- pass
root_dir = subproc_res[0].split()[-1]
if len(self.launcher) > 0:
# There are two cases : The old application (runAppli)
# and the new one
- launcherName = os.path.basename(self.launcher)
+ os.path.basename(self.launcher)
launcherDir = os.path.dirname(self.launcher)
if os.path.basename(launcherDir) == "APPLI":
# Old application
| >> UTS.Popen('ls && etc...', ...)
"""
-import os
-import shutil
import errno
-import stat
import time
-import re
-import tempfile
import subprocess as SP
import src.returnCode as RCO
| PATCH version when you make backwards-compatible bug fixes.
"""
-import os
-import sys
verbose = False # True
f.write(
"<?xml-stylesheet type='text/xsl' href='./%s'?>\n" % stylesheet
)
- pass
res = etree.tostring(self.xmlroot, encoding="utf-8")
f.write(res)
except IOError:
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import os
-import sys
import unittest
import initializeTest # set PATH etc for test
if __name__ == "__main__":
unittest.main(exit=False)
- pass
| PATCH version when you make backwards-compatible bug fixes.
"""
-import os
-import sys
import unittest
import pprint as PP
if __name__ == "__main__":
unittest.main(exit=False)
- pass
| logger.warning('Testing %s', 'foo')
"""
-import os
-import sys
import unittest
-import pprint as PP
import logging as LOGI
-from logging.handlers import BufferingHandler
import src.debug as DBG
if verbose:
DBG.push_debug(True)
# DBG.write("assert unittest", [a for a in dir(self) if "assert" in a])
- pass
def test_999(self):
# one shot tearDown() for this TestCase
if __name__ == "__main__":
unittest.main(exit=False)
- pass
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import os
-import sys
import unittest
import initializeTest # set PATH etc for test
if __name__ == "__main__":
unittest.main(exit=False)
- pass
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import os
-import sys
import unittest
import initializeTest # set PATH etc for test
self.assertFalse("CRITICAL" in logs)
def test_000(self):
- logger = LOG.getUnittestLogger()
+ LOG.getUnittestLogger()
# one shot setUp() for this TestCase
if self.debug:
DBG.push_debug(True)
if __name__ == "__main__":
unittest.main(exit=False)
- pass
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import os
-import sys
import unittest
import initializeTest # set PATH etc for test
self.assertFalse("CRITICAL ::" in logs)
def test_000(self):
- logger = LOG.getUnittestLogger()
+ LOG.getUnittestLogger()
# one shot setUp() for this TestCase
if self.debug:
DBG.push_debug(True)
s = SAT.Sat(logger)
DBG.write("test_120 'sat %s'" % cmd, "expected raise", dbg)
with self.assertRaises(Exception):
- returnCode = s.execute_cli(cmd)
+ s.execute_cli(cmd)
logs = logger.getLogsAndClear()
DBG.write("logs", logs, dbg)
if __name__ == "__main__":
unittest.main(exit=False)
- pass
"""
import os
-import sys
import unittest
import getpass
if __name__ == "__main__":
# verbose = True # human eyes
unittest.main(exit=False)
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import unittest
import src.product
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import unittest
import src.product
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import unittest
import src.product
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import unittest
import src.product
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# test launch
if __name__ == '__main__':
unittest.main()
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import unittest
from src.salomeTools import Sat
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import os
-import sys
import threading
import time
import unittest
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import os
-import sys
import platform
import unittest
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import os
-import sys
import platform
import unittest
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import unittest
from src.salomeTools import Sat
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import unittest
from src.salomeTools import Sat
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import unittest
from src.salomeTools import Sat
# test launch
if __name__ == "__main__":
unittest.main()
- pass
sat.config("-v VARS.user")
- nb_logs_t0 = len(os.listdir(sat.cfg.USER.log_dir))
+ len(os.listdir(sat.cfg.USER.log_dir))
if os.path.exists(sat.cfg.USER.log_dir + "_save"):
shutil.rmtree(sat.cfg.USER.log_dir + "_save")
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import os
-import sys
import threading
import time
import unittest
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import unittest
from src.salomeTools import Sat
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import shutil
import unittest
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import shutil
import unittest
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import unittest
from src.salomeTools import Sat
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import unittest
from src.salomeTools import Sat
# test launch
if __name__ == "__main__":
unittest.main()
- pass
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
-import sys
import unittest
from src.salomeTools import Sat
# test launch
if __name__ == "__main__":
unittest.main()
- pass
import datetime
import StringIO
import sys
-import time
import unittest
from xml.sax import saxutils