mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-28 05:10:33 +05:00
102 lines
3.0 KiB
Python
102 lines
3.0 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)
|
|
|
|
import sys
|
|
|
|
from qtsalome import QGridLayout, QFrame, QApplication
|
|
|
|
from .basedlg import BaseDlg
|
|
from .geomrepairadv_common import DlgRef_1Spin_QTD
|
|
|
|
class SubShapesBaseDlg(BaseDlg):
|
|
"""
|
|
Base dialog for Merge Faces and Union Edges plugins that provides
|
|
to algorithm selected faces with a given precision.
|
|
"""
|
|
|
|
def __init__(self, window_title, algo_name, is_default_location, selection_level, min_selected):
|
|
# Set min number of selected sub-shapes
|
|
self._min_selected = min_selected
|
|
|
|
# Make layout for new widgets
|
|
main_widget = QFrame()
|
|
layout = QGridLayout(main_widget)
|
|
layout.setContentsMargins(0, 0, 0, 0)
|
|
|
|
# Precision widget
|
|
self._precision_widget = DlgRef_1Spin_QTD('Precision', 0, 2, 100)
|
|
|
|
# Add the widgets to layout
|
|
layout.addWidget(self._precision_widget, 0, 0)
|
|
|
|
BaseDlg.__init__(
|
|
self, main_widget, window_title, algo_name, is_default_location, selection_level)
|
|
|
|
|
|
def get_precision(self):
|
|
"""
|
|
Returns current precision value.
|
|
|
|
Args:
|
|
None.
|
|
|
|
Returns:
|
|
Double.
|
|
"""
|
|
|
|
return self._precision_widget.SpinBox_DX.value()
|
|
|
|
|
|
def get_args(self):
|
|
"""
|
|
Collects arguments for a repair execution algorithm into a dictionary.
|
|
|
|
Args:
|
|
None.
|
|
|
|
Returns:
|
|
Dictionary with arguments for execution.
|
|
"""
|
|
|
|
selected_ids = self.get_local_selection()
|
|
if self.is_selection_valid(selected_ids, self._min_selected):
|
|
return {
|
|
'selected_ids': selected_ids,
|
|
'result_name': self.get_result_name(),
|
|
'precision': self.get_precision()
|
|
}
|
|
|
|
return None
|
|
|
|
|
|
# For testing run as a module from geomrepairadv parent directory in
|
|
# Salome INSTALL, because the dialog needs a generated Ui_BaseDlg class
|
|
# that we don't have in the SOURCE.
|
|
# Example:
|
|
# $ python -m geomrepairadv.subshapes_basedlg
|
|
if __name__ == '__main__':
|
|
app = QApplication(sys.argv)
|
|
|
|
dlg = SubShapesBaseDlg('Test SubShapesBaseDlg', 'merge_faces_algo.py', True, None, 1)
|
|
dlg.show()
|
|
|
|
sys.exit(app.exec_())
|