Ejemplo n.º 1
0
def createPopupMenu(popup, context):
    """
    This method is called when popup menu is requested by the user (right click).
    Should analyze the selection and fill in the popup menu with the corresponding actions.

    @type popup: C{QPopupMenu}
    @param popup: popup menu from the Object Browser.
    @type context: C{String}
    @param context: equal to 'ObjectBrowser' or 'VTKViewer' for example.
    """
    #log.debug("createPopupMenu -> context = %s" % context)

    study = CFDSTUDYGUI_DataModel._getStudy()
    dsk = sgPyQt.getDesktop()
    ActionHandler = _DesktopMgr.getActionHandler(dsk)

    #log.debug("createPopupMenu -> SelectedCount = %s" % sg.SelectedCount())

    if sg.SelectedCount() > 0:
        # Custom Popup menu added or removed regards to the type of the object
        for i in range(sg.SelectedCount()):
            entry = sg.getSelected(i)
            if entry != '':
                sobj = study.FindObjectID(entry)
                if sobj is not None:
                    test, anAttr = sobj.FindAttribute("AttributeLocalID")
                    if test:
                        id = anAttr._narrow(SALOMEDS.AttributeLocalID).Value()
                        if id >= 0:

                            if sobj.GetFatherComponent().GetName() == "Mesh":
                                if CFDSTUDYGUI_DataModel.getMeshFromMesh(
                                        sobj) == None:
                                    meshGroupObject, group = CFDSTUDYGUI_DataModel.getMeshFromGroup(
                                        sobj)
                                    if meshGroupObject != None:
                                        ActionHandler.customPopup(id, popup)
                                        if sg.SelectedCount() > 1:
                                            popup.removeAction(
                                                ActionHandler.commonAction(
                                                    CFDSTUDYGUI_ActionsHandler.
                                                    DisplayOnlyGroupMESHAction)
                                            )
                                else:
                                    ActionHandler.customPopup(id, popup)
                                    popup.removeAction(
                                        ActionHandler.commonAction(
                                            CFDSTUDYGUI_ActionsHandler.
                                            DisplayOnlyGroupMESHAction))

                            else:
                                ActionHandler.customPopup(id, popup)
                                fathername = sobj.GetFather().GetName()
                                if fathername in ["RESU", "RESU_COUPLING"]:
                                    if CFDSTUDYGUI_DataModel.checkType(sobj, CFDSTUDYGUI_DataModel.dict_object["RESUSubFolder"]) or \
                                        CFDSTUDYGUI_DataModel.checkType(sobj, CFDSTUDYGUI_DataModel.dict_object["RESU_COUPLINGSubFolder"]):
                                        ActionHandler.customPopup(id, popup)
                                        ActionHandler.commonAction(
                                            ActionHandler.RemoveAction
                                        ).setEnabled(True)
Ejemplo n.º 2
0
def BoundaryGroup():
    """
    Import groups of faces.
    """
    if sMeshComponent == None and sGeomComponent == None:
        raise ValueError("Component SMESH and GEOM not found")

    local = ""
    if sg.SelectedCount() > 0:
        for i in range(sg.SelectedCount()):
            entry = sg.getSelected(i)
            if entry != '':
                sobj = aStudy.FindObjectID(entry)
                if sobj != None:
                    anObjectDS = sobj.GetObject()
                    if anObjectDS != None:

                        # check for smesh group
                        aSmeshObject = anObjectDS._narrow(
                            SMESH.SMESH_GroupBase)
                        #if aSmeshObject == None:
                        #    aSmeshObject = anObjectDS._narrow(SMESH.SMESH_Group)
                        #if aSmeshObject == None:
                        #    aSmeshObject = anObjectDS._narrow(SMESH.SMESH_GroupOnGeom)
                        if aSmeshObject != None and aSmeshObject.GetType(
                        ) == SMESH.FACE:
                            if not local:
                                local = aSmeshObject.GetName()
                            else:
                                local += ' or ' + aSmeshObject.GetName()

                        # check for geom group of faces
                        aGeomObject = anObjectDS._narrow(GEOM.GEOM_Object)
                        if aGeomObject != None and aGeomObject.GetType() == 37:
                            # check the group
                            # get all possible faces
                            all_ids = geomBuilder.SubShapeAllIDs(
                                aGeomObject.GetMainShape(),
                                geomBuilder.ShapeType["FACE"])
                            cur_ids = geomBuilder.GetObjectIDs(aGeomObject)
                            isValid = len(
                                cur_ids) > 0  # not include empty list
                            if isValid:
                                for face_id in cur_ids:
                                    if not face_id in all_ids:
                                        #invalid id
                                        isValid = False
                                        break

                            if isValid:
                                if not local:
                                    local = aGeomObject.GetName()
                                else:
                                    local += ' or ' + aGeomObject.GetName()

    log.debug("BoundaryGroup -> %s" % str(local))
    return local
Ejemplo n.º 3
0
def createPopupMenu(popup, context):
    """
    This method is called when popup menu is requested by the user (right click).
    Should analyze the selection and fill in the popup menu with the corresponding actions.

    @type popup: C{QPopupMenu}
    @param popup: popup menu from the Object Browser.
    @type context: C{String}
    @param context: equal to 'ObjectBrowser' or 'VTKViewer' for example.
    """
    #log.debug("createPopupMenu -> context = %s" % context)

    study = CFDSTUDYGUI_DataModel._getStudy()
    dsk = sgPyQt.getDesktop()
    ActionHandler = _DesktopMgr.getActionHandler(dsk)

    #log.debug("createPopupMenu -> SelectedCount = %s" % sg.SelectedCount())

    if sg.SelectedCount() > 0:
        # Custom Popup menu added or removed regards to the type of the object
        for i in range(sg.SelectedCount()):
            entry = sg.getSelected(i)
            if entry != '':
                sobj = study.FindObjectID(entry)
                if sobj is not None:
                    test, anAttr = sobj.FindAttribute("AttributeLocalID")
                    if test:
                        id = anAttr._narrow(SALOMEDS.AttributeLocalID).Value()
                        if id >= 0:

                            if sobj.GetFatherComponent().GetName() == "Mesh":
                                if CFDSTUDYGUI_DataModel.getMeshFromMesh(sobj) == None:
                                    meshGroupObject,group = CFDSTUDYGUI_DataModel.getMeshFromGroup(sobj)
                                    if meshGroupObject != None:
                                        ActionHandler.customPopup(id, popup)
                                        if sg.SelectedCount() > 1:
                                            popup.removeAction(ActionHandler.commonAction(CFDSTUDYGUI_ActionsHandler.DisplayOnlyGroupMESHAction))
                                else:
                                    ActionHandler.customPopup(id, popup)
                                    popup.removeAction(ActionHandler.commonAction(CFDSTUDYGUI_ActionsHandler.DisplayOnlyGroupMESHAction))

                            else:
                                if not CFDSTUDYGUI_DataModel.isLinkPathObject(sobj):
                                    ActionHandler.customPopup(id, popup)