-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// 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.
+// 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.
//
-// 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.
+// 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
+// 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 http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMESHGUI : GUI for SMESH component
#include "SMESHGUI.h"
#include "SMESHGUI_ConvToQuadDlg.h"
+#include "SMESHGUI_MeshEditPreview.h"
#include "SMESHGUI_Utils.h"
-#include "SMDSAbs_ElementType.hxx"
-
+#include "SMESH_ActorUtils.h"
#include "SMESH_TypeFilter.hxx"
+#include "SMDSAbs_ElementType.hxx"
// SALOME GUI includes
#include <LightApp_UpdateFlags.h>
#include <SUIT_MessageBox.h>
#include <SUIT_OverrideCursor.h>
#include <SalomeApp_Tools.h>
+#include <SALOME_Actor.h>
// IDL includes
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
+// VTK includes
+#include <vtkProperty.h>
+
//================================================================================
/*!
* \brief Constructor
//================================================================================
SMESHGUI_ConvToQuadOp::SMESHGUI_ConvToQuadOp()
: SMESHGUI_SelectionOp(),
- myDlg( 0 )
+ myDlg( 0 ),
+ myBadElemsPreview(0)
{
}
//================================================================================
SMESHGUI_ConvToQuadOp::~SMESHGUI_ConvToQuadOp()
{
- if ( myDlg )
- delete myDlg;
+ if ( myDlg ) delete myDlg;
+ if ( myBadElemsPreview ) delete myBadElemsPreview;
}
//================================================================================
SUIT_SelectionFilter* SMESHGUI_ConvToQuadOp::createFilter( const int theId ) const
{
if ( theId == 0 )
- return new SMESH_TypeFilter( MESHorSUBMESH );
+ return new SMESH_TypeFilter( SMESH::MESHorSUBMESH );
else
return 0;
}
{
SMESH::SMESH_MeshEditor_var aEditor = mesh->GetMeshEditor();
aResult = true;
+ SMESH::SMESH_Mesh_var sourceMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pObj );
if( !myDlg->CurrentRB() )
{
- bool aParam = true;
+ bool force3d = true;
if( myDlg->IsEnabledCheck() )
- aParam = myDlg->IsMediumNdsOnGeom();
+ force3d = myDlg->IsMediumNdsOnGeom();
- if ( myDlg->isWarningShown() )
- aEditor->ConvertToQuadraticObject( aParam, idSource );
+ if ( sourceMesh->_is_nil() )
+ aEditor->ConvertToQuadraticObject( force3d, idSource );
else
- aEditor->ConvertToQuadratic( aParam );
+ aEditor->ConvertToQuadratic( force3d );
+
+ if ( !force3d )
+ {
+ SMESH::ComputeError_var error = aEditor->GetLastError();
+ if ( error->hasBadMesh )
+ {
+ if ( myBadElemsPreview ) delete myBadElemsPreview; // viewWindow may change
+ myBadElemsPreview = new SMESHGUI_MeshEditPreview( viewWindow() );
+
+ vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
+ vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
+ vtkProperty* prop = vtkProperty::New();
+ prop->SetLineWidth( aLineWidth * 3 );
+ prop->SetPointSize( aPointSize * 3 );
+ prop->SetColor( 250, 0, 250 );
+ myBadElemsPreview->GetActor()->SetProperty( prop );
+ prop->Delete();
+
+ SMESH::MeshPreviewStruct_var previewData = aEditor->GetPreviewData();
+ myBadElemsPreview->SetData( & previewData.in() );
+ myBadElemsPreview->SetVisibility(true);
+
+ SUIT_MessageBox* mb = new SUIT_MessageBox(SUIT_MessageBox::Warning,
+ tr( "SMESH_WRN_WARNING" ),
+ tr("EDITERR_NO_MEDIUM_ON_GEOM"),
+ SUIT_MessageBox::Ok, myDlg);
+ mb->setWindowModality( Qt::NonModal );
+ mb->setAttribute( Qt::WA_DeleteOnClose );
+ mb->show();
+ connect ( mb, SIGNAL( finished(int) ), this, SLOT( onWarningWinFinished() ));
+ //connect ( mb, SIGNAL( rejected() ), this, SLOT( onWarningWinFinished() ));
+ }
+ }
}
else
{
- if ( myDlg->isWarningShown() )
+ if ( sourceMesh->_is_nil() )
aEditor->ConvertFromQuadraticObject( idSource );
else
aEditor->ConvertFromQuadratic();
return aResult;
}
+//================================================================================
+/*!
+ * \brief SLOT called when a warning window is closed
+ */
+//================================================================================
+
+void SMESHGUI_ConvToQuadOp::onWarningWinFinished()
+{
+ if ( myBadElemsPreview )
+ myBadElemsPreview->SetVisibility(false);
+}
+
//================================================================================
/*! ConsistMesh
* Determines, what elements this mesh contains.