Beispiel #1
0
    def __set_curves(self):
        self.__refreshTimout.stop()
        crvs = self.__crvs
        if len(crvs) == len(self.__curveViews):  #refresh the existing views
            for i in range(len(crvs)):
                pos, c = crvs[i]
                v = self.__curveViews[i]
                v.setCurve(c)
                v.pos = pos
                self.__curveLabels[i].setValue(pos)
        else:  #recreate them
            del self.__curveViews[:]
            del self.__curveLabels[:]
            scrolledWidget = QtGui.QWidget(self)
            layout = QtGui.QBoxLayout(self.orientation)
            scrolledWidget.setLayout(layout)

            # -- used to lock the bounding cross section line edits --
            minPos = min(crvs, key=lambda x: x[0])[0]
            maxPos = max(crvs, key=lambda x: x[0])[0]

            for pos, c in crvs:
                frame = QtGui.QFrame(scrolledWidget)
                frame.setFrameShape(QtGui.QFrame.Panel)
                frame.setFrameShadow(QtGui.QFrame.Raised)
                subLay = QtGui.QBoxLayout(QtGui.QBoxLayout.TopToBottom)
                frame.setLayout(subLay)

                w = CurvePanel.SimpleCurve2DView(pos, c, frame)
                w.clicked.connect(self.curveEditRequested)
                w.deleteRequested.connect(self.curveDeleteRequested)

                label = QtGui.QDoubleSpinBox()
                label.setRange(-100000., 100000.)
                label.setValue(pos)
                label.setAlignment(QtCore.Qt.AlignHCenter)
                sender = SenderWidget(label, float, self)
                if pos in [minPos, maxPos]:
                    label.setEnabled(False)
                else:
                    sender.valueChanged.connect(self.__on_label_changed)

                subLay.addWidget(w, QtCore.Qt.AlignHCenter)
                subLay.addWidget(label, QtCore.Qt.AlignHCenter)
                layout.addWidget(frame)
                self.__curveViews.append(w)
                self.__curveLabels.append(label)
            self.setWidget(scrolledWidget)
Beispiel #2
0
    def __init__(self, parent=None, editingCentral=False):
        QtGui.QSplitter.__init__(self, QtCore.Qt.Vertical, parent)
        self.__splitter = QtGui.QSplitter(QtCore.Qt.Horizontal, self)

        self.__profileExplorer = ProfileViewer(None)
        self.__curveOverview = CurvePanel()
        self.__curveEdit = Curve2DEditor(self.__splitter)
        self.__curveEdit.position = 0.0  #additional attribute needed to refresh the edited curve.

        self.__addonConf = AddOnControlWidget(self.__profileExplorer, self)

        # -- curve panel conf --
        self.__curveEdit.sphere = interpolated_profile.sg.Sphere(radius=0.002)
        self.__curveEdit.accessorType[NurbsCurve] = ProfileEditor.NurbsAccessor

        # -- profile explorer conf --
        self.__profileExplorer.factor = [1, 1, 2]
        self.__profileExplorer.userSlices.enabled = True
        self.__profileExplorer.visualSections.enabled = True
        self.__profileExplorer.visualSections.baseAlpha = 0.5
        self.__profileExplorer.grids.enabled = True
        self.__profileExplorer.grids.xzGrid = True
        self.__profileExplorer.grids.zScale = True

        # -- signal binding --
        self.__curveOverview.curveEditRequested.connect(
            self.__on_curve_edit_request)
        self.__curveOverview.curveDeleteRequested.connect(
            self.__on_curve_delete_request)
        self.__curveOverview.curveMoveRequested.connect(
            self.__on_curve_move_request)
        self.__profileExplorer.positionChanged.connect(
            self.__on_position_changed)
        self.__profileExplorer.userSectionHighlighted.connect(
            self.__on_user_section_highlight)
        self.__profileExplorer.userSectionHighlighted.connect(
            self.__curveOverview.highlight_curve_at_position)
        # !!! Do not bind this one as valueChanged can be anything
        # !!! and that our custom curvePanel.curveAccessor directly
        # !!! edits the interpolated profile.
        # self.__curveEdit.connect(self.__curveEdit, QtCore.SIGNAL("valueChanged()"), self.__on_curve_edited)

        # -- layout --
        l = QtGui.QBoxLayout(QtGui.QBoxLayout.TopToBottom)
        l.addWidget(
            self.__profileExplorer if not editingCentral else self.__curveEdit)
        l.addWidget(self.__curveOverview)
        l.setContentsMargins(0, 0, 0, 0)
        explorerAndCurveOverview = QtGui.QWidget(self.__splitter)
        explorerAndCurveOverview.setLayout(l)
        self.__splitter.addWidget(self.__addonConf)
        self.__splitter.addWidget(explorerAndCurveOverview)
        self.__splitter.addWidget(
            self.__curveEdit if not editingCentral else self.__profileExplorer)
        self.__splitter.setSizes([0, explorerAndCurveOverview.width(), 0])
        self.addWidget(self.__splitter)

        # -- latest position of profile explorer
        # -- cursor that matched a user defined curve.
        self.__editedPosition = None
Beispiel #3
0
    def __init__(self, explorer, parent=None):
        QtGui.QScrollArea.__init__(self, parent)

        # -- reference to the profile explorer
        self.__exp = weakref.proxy(explorer)
        self.setSizePolicy(QtGui.QSizePolicy.Preferred,
                           QtGui.QSizePolicy.Maximum)
        # -- Layout --
        self.__subWidget = QtGui.QWidget(
        )  # A QScrollArea needs an inner widget to scroll.
        self.__layout = QtGui.QBoxLayout(QtGui.QBoxLayout.TopToBottom)
        # -- internals --
        self.__widmap = {
        }  #map a widget instance to an addon path "addon_name.attribute_name" and the opposite way too.
        self.__addOns = {}  #map an addon name to an addon instance.
        self.build_gui()  #browse the addon list and build the GUI.
        self.__subWidget.setLayout(self.__layout)
        self.setWidget(self.__subWidget)