Salome HOME
updated copyright message
[modules/geom.git] / src / MeasureGUI / MeasureGUI_FastCheckIntersectionsDlg.cxx
index a9ba9622f09bd4089f9db41300bf48a56c2cee8f..6a72250fb249e7d5d339fb552b18781b5ced67b6 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //            true to construct a modal dialog.
 //=================================================================================
 MeasureGUI_FastCheckIntersectionsDlg::MeasureGUI_FastCheckIntersectionsDlg (GeometryGUI* GUI, QWidget* parent)
-  : GEOMBase_Skeleton (GUI, parent, false),
-    mySelButton1       (0),
-    mySelButton2       (0),
-    myEditObjName1     (0),
-    myEditObjName2     (0),
-    myDetGaps          (0),
-    myTolerance        (0),
-    myDeflection       (0),
-    myComputeButton    (0),
-    myShapeList1       (0),
-    myShapeList2       (0)
+  : GEOMBase_Skeleton (GUI, parent, false)
 {
   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
   QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FAST_CHECK_INTERSECTIONS")));
@@ -82,33 +72,30 @@ MeasureGUI_FastCheckIntersectionsDlg::MeasureGUI_FastCheckIntersectionsDlg (Geom
   mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
   mainFrame()->RadioButton3->close();
 
-  QGroupBox *aGrp      = new QGroupBox(tr("GEOM_FAST_CHECK_OBJ"));
-  QLabel    *anObjLbl1  = new QLabel(tr("GEOM_OBJECT_I").arg("1"));
-  QLabel    *anObjLbl2  = new QLabel(tr("GEOM_OBJECT_I").arg("2"));
-  QLabel    *aShapeLbl1 = new QLabel(tr("GEOM_FAST_CHECK_INT_SUBSHAPES").arg("1"));
-  QLabel    *aShapeLbl2 = new QLabel(tr("GEOM_FAST_CHECK_INT_SUBSHAPES").arg("2"));
-  QLabel    *aDeflectLbl = new QLabel(tr("GEOM_FAST_CHECK_INT_DEFLECT"));
-  QFont      aFont (TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE);
+  QGroupBox* aGrp        = new QGroupBox(tr("GEOM_FAST_CHECK_OBJ"), centralWidget());
+  QLabel*    anObjLbl1   = new QLabel(tr("GEOM_OBJECT_I").arg("1"), aGrp);
+  QLabel*    anObjLbl2   = new QLabel(tr("GEOM_OBJECT_I").arg("2"), aGrp);
+  QLabel*    aShapeLbl1  = new QLabel(tr("GEOM_FAST_CHECK_INT_SUBSHAPES").arg("1"), aGrp);
+  QLabel*    aShapeLbl2  = new QLabel(tr("GEOM_FAST_CHECK_INT_SUBSHAPES").arg("2"), aGrp);
+  QLabel*    aDeflectLbl = new QLabel(tr("GEOM_FAST_CHECK_INT_DEFLECT"), aGrp);
 
-  aFont.setStyleHint(QFont::TypeWriter, QFont::PreferAntialias);
-
-  mySelButton1 = new QPushButton;
+  mySelButton1 = new QPushButton(aGrp);
   mySelButton1->setIcon(image1);
   mySelButton1->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
-  mySelButton2 = new QPushButton;
+  mySelButton2 = new QPushButton(aGrp);
   mySelButton2->setIcon(image1);
   mySelButton2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
 
-  myEditObjName1 = new QLineEdit;
+  myEditObjName1 = new QLineEdit(aGrp);
   myEditObjName1->setReadOnly(true);
-  myEditObjName2 = new QLineEdit;
+  myEditObjName2 = new QLineEdit(aGrp);
   myEditObjName2->setReadOnly(true);
 
-  myDetGaps = new QCheckBox( tr( "GEOM_FAST_CHECK_INT_DETECT_GAPS" ));
-  myTolerance = new SalomeApp_DoubleSpinBox;
-  myDeflection = new SalomeApp_DoubleSpinBox;
-  myShapeList1  = new QListWidget;
-  myShapeList2 = new QListWidget;
+  myDetGaps = new QCheckBox(tr( "GEOM_FAST_CHECK_INT_DETECT_GAPS" ));
+  myTolerance = new SalomeApp_DoubleSpinBox(aGrp);
+  myDeflection = new SalomeApp_DoubleSpinBox(aGrp);
+  myShapeList1  = new QListWidget(aGrp);
+  myShapeList2 = new QListWidget(aGrp);
   myShapeList1->setSelectionMode(QAbstractItemView::ExtendedSelection);
   myShapeList2->setSelectionMode(QAbstractItemView::ExtendedSelection);
 
@@ -170,18 +157,14 @@ void MeasureGUI_FastCheckIntersectionsDlg::Init()
   myEditObjName2->setEnabled(false);
 
   myDetGaps->setChecked(false);
-  double SpecificStep = 0.001;
-  double prec = Precision::Confusion();
-  initSpinBox(myTolerance, prec, MAX_NUMBER, SpecificStep);
-  myTolerance->setValue(SpecificStep);
+  initSpinBox(myTolerance, 0, MAX_NUMBER, 1);
+  myTolerance->setValue(0);
   myTolerance->setEnabled(false);
 
   // Obtain deflection from preferences
   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-  const char* quantity = "deflection_coeff";
-  double aDeflection = resMgr->doubleValue("Geometry", quantity, 0.00001); 
-  initSpinBox(myDeflection, prec, 1.0, aDeflection);
-  myDeflection->setValue(aDeflection);
+  initSpinBox(myDeflection, 1e-3, 1.0, 1e-3);
+  myDeflection->setValue(qMax(1e-3, resMgr->doubleValue("Geometry", "deflection_coeff", 1e-3)));
 
   myEditCurrentArgument = myEditObjName1;
 
@@ -245,6 +228,8 @@ void MeasureGUI_FastCheckIntersectionsDlg::clear()
 //=================================================================================
 void MeasureGUI_FastCheckIntersectionsDlg::onCompute()
 {
+  SUIT_OverrideCursor wc;
+
   myShapeList1->clear();
   myShapeList2->clear();
 
@@ -267,7 +252,7 @@ void MeasureGUI_FastCheckIntersectionsDlg::onCompute()
     TopExp::MapShapes(aSelShape2, anIndices2);
 
     //Sub-shapes of 1st Object
-    for (int i = 0; i < myInters1->length(); i++) {
+    for (int i = 0; i < (int)myInters1->length(); i++) {
       TopoDS_Shape aSubShape = anIndices1.FindKey(myInters1[i]);
       QString aType = GEOMBase::GetShapeTypeString(aSubShape);
       if (!aType.isEmpty())
@@ -277,7 +262,7 @@ void MeasureGUI_FastCheckIntersectionsDlg::onCompute()
     myShapeList1->selectAll();
 
     //Sub-shapes of second Object
-    for (int i = 0; i < myInters2->length(); i++) {
+    for (int i = 0; i < (int)myInters2->length(); i++) {
       TopoDS_Shape aSubShape = anIndices2.FindKey(myInters2[i]);
       QString aType = GEOMBase::GetShapeTypeString(aSubShape);
       if (!aType.isEmpty())
@@ -332,7 +317,7 @@ void MeasureGUI_FastCheckIntersectionsDlg::activateSelection()
 
   std::list<int> needTypes;
   needTypes.push_back( TopAbs_FACE ), needTypes.push_back( TopAbs_SHELL ), needTypes.push_back( TopAbs_SOLID ), needTypes.push_back( TopAbs_COMPOUND );
-  localSelection(GEOM::GEOM_Object::_nil(), needTypes );
+  localSelection( needTypes );
 
 }
 
@@ -375,7 +360,7 @@ bool MeasureGUI_FastCheckIntersectionsDlg::extractPrefix() const
 //=================================================================================
 GEOM::GEOM_IOperations_ptr MeasureGUI_FastCheckIntersectionsDlg::createOperation()
 {
-  return getGeomEngine()->GetIMeasureOperations( getStudyId() );
+  return getGeomEngine()->GetIMeasureOperations();
 }
 
 //=================================================================================
@@ -428,10 +413,10 @@ void MeasureGUI_FastCheckIntersectionsDlg::SetEditCurrentArgument()
 // function : OnGaps()
 // purpose  :
 //=================================================================================
-void MeasureGUI_FastCheckIntersectionsDlg::OnGaps(bool cheked)
+void MeasureGUI_FastCheckIntersectionsDlg::OnGaps(bool checked)
 {
   clear();
-  myTolerance->setEnabled(cheked);
+  myTolerance->setEnabled(checked);
 }
 //=================================================================================
 // function : SelectionIntoArgument
@@ -490,7 +475,7 @@ bool MeasureGUI_FastCheckIntersectionsDlg::findIntersections()
     GEOM::GEOM_IMeasureOperations::_narrow(getOperation());
   bool isOK = true;
 
-  bool HasInte;
+  bool HasInte = false;
   try {
     HasInte = anOper->FastIntersect(myObj1.get(), myObj2.get(), getTolerance(), getDeflection(), myInters1, myInters2);
   }
@@ -560,12 +545,12 @@ void MeasureGUI_FastCheckIntersectionsDlg::previewSubShapesListSelection(QListWi
     SALOME_Prs* aPrs = 0;
     TopExp::MapShapes(aSelShape, anIndices);
     QList<int>::iterator it;
+    getDisplayer()->SetColor(theWidget == myShapeList1 ? Quantity_NOC_RED : Quantity_NOC_GREEN);
+    getDisplayer()->SetWidth(3);
+    getDisplayer()->SetToActivate(false);
     for (it = aIds.begin(); it != aIds.end(); ++it) {
       aSubShape = anIndices.FindKey(anInters[(*it)]);
       try {
-        getDisplayer()->SetColor(Quantity_NOC_RED);
-        getDisplayer()->SetWidth(3);
-        getDisplayer()->SetToActivate(false);
         aPrs = !aSubShape.IsNull() ? getDisplayer()->BuildPrs(aSubShape) : 0;
         if (aPrs)
           displayPreview(aPrs, true);
@@ -626,7 +611,7 @@ GEOM::ListOfGO_var MeasureGUI_FastCheckIntersectionsDlg::getLstObjFromListSelect
   }
 
   if (myShapesOper->_is_nil())
-    myShapesOper = getGeomEngine()->GetIShapesOperations(getStudyId());
+    myShapesOper = getGeomEngine()->GetIShapesOperations();
 
   GEOM::ListOfGO_var aObjLstCreate = myShapesOper->MakeSubShapes(anObj.get(), anArray);
 
@@ -638,7 +623,7 @@ GEOM::ListOfGO_var MeasureGUI_FastCheckIntersectionsDlg::getLstObjFromListSelect
   for (i=0, anIter = aObjLstExist.begin(); anIter != aObjLstExist.end(); i++, ++anIter) {
     anObjLst[i] = *anIter;
   }
-  for (int j = 0; j < aObjLstCreate->length(); j++) {
+  for (int j = 0; j < (int)aObjLstCreate->length(); j++) {
     anObjLst[aObjLstExist.size()+j]=aObjLstCreate[j];
   }
   return  anObjLst._retn();
@@ -660,11 +645,11 @@ bool MeasureGUI_FastCheckIntersectionsDlg::execute(ObjectList& objects)
   //Collect general intersection list
   aCompList->length(nbObj);
   int i;
-  for (i = 0; i < aList1->length(); i++) {
+  for (i = 0; i < (int)aList1->length(); i++) {
     GEOMBase::PublishSubObject( aList1[i] );
     aCompList[i]=aList1[i];
   }
-  for (int j = 0; j < aList2->length(); j++) {
+  for (int j = 0; j < (int)aList2->length(); j++) {
     GEOMBase::PublishSubObject( aList2[j] );
     aCompList[i+j]=aList2[j];
   }
@@ -694,3 +679,14 @@ double MeasureGUI_FastCheckIntersectionsDlg::getTolerance()
     return 0.0;
   return aVal;
 }
+
+//=================================================================================
+// function : getSourceObjects
+// purpose  : virtual method to get source objects
+//=================================================================================
+QList<GEOM::GeomObjPtr> MeasureGUI_FastCheckIntersectionsDlg::getSourceObjects()
+{
+  QList<GEOM::GeomObjPtr> res;
+  res << myObj1 << myObj2;
+  return res;
+}