#include "SALOMEGUI_QtCatchCorbaException.hxx"
#include "utilities.h"
-#include "SMDS_Mesh.hxx"
-#include "SMESHDS_Document.hxx"
-#include "Document_Reader.h"
-#include "Document_Writer.h"
-#include "Mesh_Reader.h"
-#include "Mesh_Writer.h"
-
-#include "DriverDAT_R_SMESHDS_Document.h"
-#include "DriverMED_R_SMESHDS_Document.h"
-#include "DriverUNV_R_SMESHDS_Document.h"
-#include "DriverDAT_W_SMESHDS_Document.h"
-#include "DriverMED_W_SMESHDS_Document.h"
-#include "DriverUNV_W_SMESHDS_Document.h"
-#include "DriverDAT_R_SMESHDS_Mesh.h"
-#include "DriverMED_R_SMESHDS_Mesh.h"
-#include "DriverUNV_R_SMESHDS_Mesh.h"
-#include "DriverDAT_W_SMESHDS_Mesh.h"
-#include "DriverMED_W_SMESHDS_Mesh.h"
-#include "DriverUNV_W_SMESHDS_Mesh.h"
-
// QT Includes
#define INCLUDE_MENUITEM_DEF
#include <qapplication.h>
smeshGUI->myStudyAPI =
SMESHGUI_StudyAPI(smeshGUI->myStudy, smeshGUI->myComponentMesh);
- smeshGUI->myDocument = new SMESHDS_Document(1); //NBU
-
smeshGUI->mySimulationActors = vtkActorCollection::New();
smeshGUI->mySimulationActors2D = vtkActor2DCollection::New();
}
case 112:
case 111:
{
- Import_Document(parent, theCommandID); //NBU
- //Import_Mesh(parent,theCommandID);
+ smeshGUI->Import_Document(parent, theCommandID);
break;
}
return listSOmesh._retn();
}
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-void SMESHGUI::Import_Mesh(QAD_Desktop * parent, int theCommandID)
-{
- QString filter;
- string myExtension;
- Mesh_Reader *myReader;
-
- if (theCommandID == 113)
- {
- filter = tr("MED files (*.med)");
- myExtension = string("MED");
- myReader = new DriverMED_R_SMESHDS_Mesh;
- }
- else if (theCommandID == 112)
- {
- filter = tr("IDEAS files (*.unv)");
- myExtension = string("UNV");
- }
- else if (theCommandID == 111)
- {
- filter = tr("DAT files (*.dat)");
- myExtension = string("MED");
- myReader = new DriverDAT_R_SMESHDS_Mesh;
- }
-
- QString filename = QAD_FileDlg::getFileName(parent,
- "",
- filter,
- tr("Import mesh"),
- true);
- if (!filename.isEmpty())
- {
- QApplication::setOverrideCursor(Qt::waitCursor);
- string myClass = string("SMESHDS_Mesh");
-// Mesh_Reader* myReader = SMESHDriver::GetMeshReader(myExtension, myClass);
-
- int myMeshId = (smeshGUI->myDocument)->NewMesh();
- SMDS_Mesh *myMesh = (smeshGUI->myDocument)->GetMesh(myMeshId);
-
- myReader->SetFile(string(filename.latin1()));
- myReader->SetMesh(myMesh);
- myReader->SetMeshId(myMeshId);
- myReader->Read();
-
- QApplication::restoreOverrideCursor();
- }
-}
-
//=============================================================================
/*!
*
if (!filename.isEmpty())
{
QApplication::setOverrideCursor(Qt::waitCursor);
- aMesh->ExportMED(filename.latin1());
+ aMesh->Export(filename.latin1(), "MED");
QApplication::restoreOverrideCursor();
}
}
if (!filename.isEmpty())
{
QApplication::setOverrideCursor(Qt::waitCursor);
- aMesh->ExportDAT(filename.latin1());
+ aMesh->Export(filename.latin1(), "DAT");
QApplication::restoreOverrideCursor();
}
}
if (!filename.isEmpty())
{
QApplication::setOverrideCursor(Qt::waitCursor);
- aMesh->ExportUNV(filename.latin1());
+ aMesh->Export(filename.latin1(), "UNV");
QApplication::restoreOverrideCursor();
}
else
- aMesh->ExportDAT(filename.latin1());
+ aMesh->Export(filename.latin1(), "DAT");
QApplication::restoreOverrideCursor();
{
QString filter;
string myExtension;
- Document_Reader *myReader;
if (theCommandID == 113)
{
filter = tr("MED files (*.med)");
myExtension = string("MED");
- myReader = new DriverMED_R_SMESHDS_Document;
}
else if (theCommandID == 112)
{
filter = tr("IDEAS files (*.unv)");
myExtension = string("UNV");
- myReader = new DriverUNV_R_SMESHDS_Document;
}
else if (theCommandID == 111)
{
filter = tr("DAT files (*.dat)");
myExtension = string("DAT");
- myReader = new DriverDAT_R_SMESHDS_Document;
- }
-
- QString filename = QAD_FileDlg::getFileName(parent,
- "",
- filter,
- tr("Import document"),
- true);
- if (!filename.isEmpty())
- {
- QApplication::setOverrideCursor(Qt::waitCursor);
- string myClass = string("SMESHDS_Document");
-// Document_Reader* myReader = SMESHDriver::GetDocumentReader(myExtension, myClass);
- SMESHDS_Document *newDocument = new SMESHDS_Document(1);
-
- myReader->SetFile(string(filename.latin1()));
- myReader->SetDocument(smeshGUI->myDocument);
- myReader->Read();
- QApplication::restoreOverrideCursor();
}
-}
-void SMESHGUI::Export_Document(QAD_Desktop * parent, int theCommandID)
-{
- QString filter;
- Document_Writer *myWriter;
- string myExtension;
+ QString filename = QAD_FileDlg::getFileName(parent, "", filter,
+ tr("Import document"), true);
- if (theCommandID == 122)
- {
- filter = tr("MED files (*.med)");
- myExtension = string("MED");
- myWriter = new DriverMED_W_SMESHDS_Document;
- }
- else if (theCommandID == 121)
- {
- filter = tr("DAT files (*.dat)");
- myExtension = string("DAT");
- myWriter = new DriverDAT_W_SMESHDS_Document;
- }
- else if (theCommandID == 123)
- {
- filter = tr("IDEAS files (*.unv)");
- myExtension = string("UNV");
- myWriter = new DriverUNV_W_SMESHDS_Document;
- }
-
- QString filename = QAD_FileDlg::getFileName(parent,
- "",
- filter,
- tr("Export document"),
- false);
if (!filename.isEmpty())
{
QApplication::setOverrideCursor(Qt::waitCursor);
- string myClass = string("SMESHDS_Document");
- //Document_Writer* myWriter = SMESHDriver::GetDocumentWriter(myExtension, myClass);
-
- myWriter->SetFile(string(filename.latin1()));
- myWriter->SetDocument(smeshGUI->myDocument);
-
- //StudyContextStruct* myStudyContext = _impl.GetStudyContext(myStudyId);
- //Handle(SMESHDS_Document) myDocument = myStudyContext->myDocument;
- //myWriter->SetDocument(myDocument);
-
- myWriter->Write();
+ try
+ {
+ if (!myComponentMesh->_is_nil())
+ {
+ SMESH::SMESH_Mesh_var aMesh =
+ myComponentMesh->Import(myStudyId, filename.latin1(),
+ myExtension.c_str());
+
+ if (!aMesh->_is_nil())
+ {
+ SALOMEDS::SObject_var SM = myStudyAPI.AddNewMesh(aMesh);
+ myStudyAPI.SetName(SM, filename);
+ }
+ }
+ }
+ catch(const SALOME::SALOME_Exception & S_ex)
+ {
+ QtCatchCorbaException(S_ex);
+ }
+ myActiveStudy->updateObjBrowser(true);
QApplication::restoreOverrideCursor();
}
}
smeshGUI->myAutomaticUpdate = false;
}
- /* menus disable */
- parent->menuBar()->setItemEnabled(11, false); // IMPORT
-
return true;
}
return false;
}
-//=============================================================================
-/*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
- * Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
+/**
+ * Ensures that the actor for the given <theIO> exists in the active VTK view
+ * @TODO Handle multiple selection.
*/
-//=============================================================================
void SMESHGUI::BuildPresentation(const Handle(SALOME_InteractiveObject) & theIO)
{
+ MESSAGE("SMESHGUI::BuildPresentation("<<theIO->getEntry()<<")");
/* Create or retrieve an object SMESHGUI */
SMESHGUI::GetOrCreateSMESHGUI(QAD_Application::getDesktop());
if (activeFrame->getTypeView() == VIEW_VTK)
{
// VTK
- SALOMEDS::SObject_var fatherSF =
+ // Some ideas to handle multiple selection...
+ /*SALOMEDS::SObject_var fatherSF =
smeshGUI->myStudy->FindObjectID(activeFrame->entry());
SALOME_Selection *Sel =
getSelection());
SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
-// for(;It.More();It.Next()) {
-// Handle(SALOME_InteractiveObject) IObject = It.Value();
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();*/
Handle(SALOME_InteractiveObject) IObject = theIO;
if (IObject->hasEntry())
{
Standard_Boolean res;
SMESH_Actor *ac =
smeshGUI->FindActorByEntry(IObject->getEntry(), res, false);
-
- // Actor not found at all -> mesh is not computed -> do nothing!!!
+
if (!res)
{
- /*SMESH::SMESH_Mesh_var aM;
- * SALOMEDS::SObject_var aMorSM = smeshGUI->myStudy->FindObjectID( IObject->getEntry() );
- * SALOMEDS::SObject_var father = aMorSM->GetFather();
- * SALOMEDS::SObject_var fatherComp = aMorSM->GetFatherComponent();
- *
- * // Non-displayable objects (Hypo, Algo) have tags < 3 or have a father different from component
- * if (aMorSM->Tag() < 3 || strcmp(father->GetID(), fatherComp->GetID()) != 0)
- * continue;
- *
- * SALOMEDS::GenericAttribute_var anAttr;
- * SALOMEDS::AttributeIOR_var anIOR;
- * if ( !aMorSM->_is_nil() ) {
- * if (aMorSM->FindAttribute(anAttr, "AttributeIOR") ) {
- * anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- * aM = SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()) );
- * }
- * }
- *
- * if (!aM->_is_nil()) {
- * smeshGUI->InitActor(aM);
- * ac = smeshGUI->ReadScript(aM);
- * }
- *
- * if (ac) {
- * smeshGUI->DisplayActor( ac, true );
- * smeshGUI->DisplayEdges( ac );
- * smeshGUI->ChangeRepresentation( ac, ac->getDisplayMode() );
- * } */
-// continue;
+ SALOMEDS::SObject_var aMorSM=smeshGUI->myStudy->FindObjectID( IObject->getEntry());
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if(aMorSM->FindAttribute(anAttr, "AttributeIOR"))
+ {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ SMESH::SMESH_Mesh_var aM =
+ SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()));
+ if(!aM->_is_nil())
+ {
+ smeshGUI->InitActor(aM);
+ ac = smeshGUI->ReadScript(aM);
+ smeshGUI->DisplayActor( ac, true );
+ smeshGUI->DisplayEdges( ac );
+ smeshGUI->ChangeRepresentation( ac, ac->getDisplayMode() );
+ }
+ else
+ {
+ MESSAGE("Do not know how to display something which is not a SMESH_Mesh");
+ }
+ }
+ else
+ {
+ MESSAGE("The object "<<theIO->getEntry()<<
+ " do not have \"AttributeIOR\" attribute");
+ }
}
else
- { // The actor exists in some view
+ {
+ // The actor exists in some view
// Check whether the actor belongs to the active view
VTKViewer_RenderWindowInteractor *rwInter =
((VTKViewer_ViewFrame *) activeFrame->getRightFrame()->
smeshGUI->ChangeRepresentation(ac, ac->getDisplayMode());
}
}
-// }
}
else
{
- MESSAGE
- ("BuildPresentation() must not be called while non-VTK view is active")}
+ MESSAGE("BuildPresentation() must not be called while non-VTK view is active");
+ }
}
//=============================================================================
ASSERT(!CORBA::is_nil(_orb));
}
-//=============================================================================
-/*!
- *
+/**
+ * Get the history of all commands made in the SMESH server. This list of command
+ * is used to display the mesh in the VTK view
+ * @TODO Handle the REMOVE_ALL command.
*/
-//=============================================================================
SMESH_Actor *SMESHGUI::ReadScript(SMESH::SMESH_Mesh_ptr aMesh)
{
+ MESSAGE("SMESHGUI::ReadScript");
SMESH_Actor *MeshActor;
if (!aMesh->_is_nil())
{
if (result)
{
SMESH::log_array_var aSeq = aMesh->GetLog(true);
-
- if (aSeq->length() == 0)
- {
- MESSAGE("ReadScript(): log is empty") return MeshActor;
- }
+ MESSAGE("SMESHGUI::ReadScript: The log contains "<<aSeq->length()
+ <<" commands.");
for (unsigned int ind = 0; ind < aSeq->length(); ind++)
{
aSeq[ind].coords, aSeq[ind].indexes);
break;
}
+ case SMESH::REMOVE_ALL:
+ MESSAGE("REMOVE_ALL command not yet implemented");
+ break;
+ default: MESSAGE("Warning: Unknown script command.");
}
}
return MeshActor;
void SMESHGUI::AddNodes(SMESH_Actor * Mactor, int number,
const SMESH::double_array & coords, const SMESH::long_array & indexes)
{
+ MESSAGE("SMESHGUI::AddNodes(number="<<number<<", indexes.length()="<<indexes.length()<<")");
QApplication::setOverrideCursor(Qt::waitCursor);
if (Mactor->GetMapper() == NULL)
{
float z)
{
QApplication::setOverrideCursor(Qt::waitCursor);
- MESSAGE("SMESHGUI::AddNode " << idnode << " : " << x << ";" << y << ";" <<
- z) if (Mactor->GetMapper() == NULL)
+ MESSAGE("SMESHGUI::AddNode " << idnode << " : " << x << ";" << y << ";" << z);
+
+ if (Mactor->GetMapper() == NULL)
{
vtkPoints *Pts = vtkPoints::New();
int idVTK = Pts->InsertNextPoint(x, y, z);
void SMESHGUI::AddTriangles(SMESH_Actor * Mactor, int number,
const SMESH::double_array & coords, const SMESH::long_array & indexes)
{
+ MESSAGE("SMESHGUI::AddTriangles(number="<<number<<", indexes.length="
+ <<indexes.length()<<")");
+
QApplication::setOverrideCursor(Qt::waitCursor);
//vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource );
SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast(Mactor->DataSource);
//=============================================================================
void SMESHGUI::Update()
{
+ MESSAGE("SMESHGUI::Update");
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
{ //VTK
vtkRenderer *theRenderer =