geom/src/RepairGUIAdv/geomrepairadv_common.py

68 lines
2.6 KiB
Python

# -*- coding: utf-8 -*-
# Copyright (C) 2014-2024 EDF
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See https://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
# Author : Konstantin Leontev (OpenCascade S.A.S)
from qtsalome import QWidget
from SalomePyQt import SalomePyQt
from salome.geom.geomrepairadv.DlgRef_1Sel_QTD_ui import Ui_DlgRef_1Sel_QTD
from salome.geom.geomrepairadv.DlgRef_1Spin_QTD_ui import Ui_DlgRef_1Spin_QTD
# Constants from /src/GEOMGUI/GEOM_msg_en.ts
GEOM_RESULT_NAME_GRP = 'Result name'
NAME_LBL = 'Name'
GEOM_SELECTED_LBL = 'Name'
GEOM_SELECTED_SHAPE = 'Selected shape'
GEOM_SELECTED_SUBSHAPE = 'Selected sub-shape'
class DlgRef_1Sel_QTD(Ui_DlgRef_1Sel_QTD, QWidget):
"""
Helper class to set up a widget for any related dialog.
We need it because a class generated from ui file is derived from an object and
cannot be added as a widget to a dialog's layout.
"""
def __init__(self):
QWidget.__init__(self)
# Set up the user interface from Designer.
self.setupUi(self)
# Set 'select' icon
icon = SalomePyQt.loadIcon('GEOM', 'select1.png')
self.PushButton1.setIcon(icon)
class DlgRef_1Spin_QTD(Ui_DlgRef_1Spin_QTD, QWidget):
"""
Helper class to set up a widget for any related dialog.
We need it because a class generated from ui file is derived from an object and
cannot be added as a widget to a dialog's layout.
"""
def __init__(self, title, default_value, decimals, max_value):
QWidget.__init__(self)
# Set up the user interface from Designer.
self.setupUi(self)
self.TextLabel1.setText(title)
# Setting deciamals must be in the first place, because from QDoubleSpinBox docs:
# the maximum, minimum and value might change as a result of changing this property.
self.SpinBox_DX.setDecimals(decimals)
self.SpinBox_DX.setMaximum(max_value)
self.SpinBox_DX.setValue(default_value)