* \return boolean indicating if export was successful.
*/
boolean ExportXAO(in GEOM_Object shape,
- in ListOfGO groups, in ListOfGO fields,
+ in ListOfGO groups, in ListOfFields fields,
in string author, in string fileName);
/*!
* \return boolean indicating if import was successful.
*/
boolean ImportXAO(in string fileName, out GEOM_Object shape,
- out ListOfGO subShapes, out ListOfGO groups, out ListOfGO fields);
+ out ListOfGO subShapes, out ListOfGO groups, out ListOfFields fields);
};
// # GEOM_IKindOfShape:
void ExportTranslators (out string_array theFormats,
out string_array thePatterns) ;
boolean ExportXAO(in GEOM_Object shape,
- in ListOfGO groups, in ListOfGO fields,
- in string author, in string fileName);
+ in ListOfGO groups, in ListOfFields fields,
+ in string author, in string fileName);
boolean ImportXAO(in string fileName, out GEOM_Object shape,
- out ListOfGO subShapes, out ListOfGO groups, out ListOfGO fields);
+ out ListOfGO subShapes, out ListOfGO groups, out ListOfFields fields);
//-----------------------------------------------------------//
// TransformOperations //
};
typedef GenericObjPtr<GEOM::GEOM_Object> GeomObjPtr;
+ typedef GenericObjPtr<GEOM::GEOM_Field> GeomFieldPtr;
typedef GenericObjPtr<GEOM::GEOM_IBasicOperations> BasicOpPtr;
typedef GenericObjPtr<GEOM::GEOM_ITransformOperations> TransformOpPtr;
typedef GenericObjPtr<GEOM::GEOM_I3DPrimOperations> I3DPrimOpPtr;
#include <GEOMImpl_Types.hxx>
#include "GEOMImpl_IShapesOperations.hxx"
#include "GEOMImpl_IGroupOperations.hxx"
+#include "GEOMImpl_IFieldOperations.hxx"
#include "GEOMImpl_XAODriver.hxx"
#include "GEOMImpl_IImportExportXAO.hxx"
#include <XAO_Group.hxx>
#include <XAO_Field.hxx>
#include <XAO_XaoUtils.hxx>
+#include <XAO_BooleanField.hxx>
+#include <XAO_IntegerField.hxx>
+#include <XAO_DoubleField.hxx>
+#include <XAO_StringField.hxx>
+#include <XAO_BooleanStep.hxx>
+#include <XAO_IntegerStep.hxx>
+#include <XAO_DoubleStep.hxx>
+#include <XAO_StringStep.hxx>
#include <Basics_OCCTVersion.hxx>
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
#include <TColStd_HArray1OfByte.hxx>
+#include <TColStd_HArray1OfReal.hxx>
#else
#include <TDataStd_HArray1OfByte.hxx>
#endif
MESSAGE("GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations");
myShapesOperations = new GEOMImpl_IShapesOperations(GetEngine(), GetDocID());
myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID());
+ myFieldOperations = new GEOMImpl_IFieldOperations(GetEngine(), GetDocID());
}
//=============================================================================
MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations");
delete myShapesOperations;
delete myGroupOperations;
+ delete myFieldOperations;
}
//=============================================================================
return dim;
}
-void GEOMImpl_IInsertOperations::exportGroups(std::list<Handle(GEOM_Object)> groupList, XAO::Xao* xaoObject, XAO::BrepGeometry* geometry)
+void GEOMImpl_IInsertOperations::exportGroups(std::list<Handle(GEOM_Object)> groupList,
+ XAO::Xao* xaoObject,
+ XAO::BrepGeometry* geometry)
{
// add the groups
std::list<Handle(GEOM_Object)>::iterator groupIterator = groupList.begin();
case TopAbs_VERTEX:
for (int i = 1; i <= groupIds->Length(); i++)
{
- std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
- int index = geometry->getVertexIndexByReference(ref);
- group->add(index);
+ std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
+ int index = geometry->getVertexIndexByReference(ref);
+ group->add(index);
}
break;
case TopAbs_EDGE:
for (int i = 1; i <= groupIds->Length(); i++)
{
- std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
- int index = geometry->getEdgeIndexByReference(ref);
- group->add(index);
+ std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
+ int index = geometry->getEdgeIndexByReference(ref);
+ group->add(index);
}
break;
case TopAbs_FACE:
for (int i = 1; i <= groupIds->Length(); i++)
{
- std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
- int index = geometry->getFaceIndexByReference(ref);
- group->add(index);
+ std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
+ int index = geometry->getFaceIndexByReference(ref);
+ group->add(index);
}
break;
case TopAbs_SOLID:
for (int i = 1; i <= groupIds->Length(); i++)
{
- std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
- int index = geometry->getSolidIndexByReference(ref);
- group->add(index);
+ std::string ref = XAO::XaoUtils::intToString(groupIds->Value(i));
+ int index = geometry->getSolidIndexByReference(ref);
+ group->add(index);
}
break;
}
}
}
-void GEOMImpl_IInsertOperations::exportFields(std::list<Handle(GEOM_Object)> fieldList, XAO::Xao* xaoObject, XAO::BrepGeometry* geometry)
+void GEOMImpl_IInsertOperations::exportFields(std::list<Handle(GEOM_Field)> fieldList,
+ XAO::Xao* xaoObject,
+ XAO::BrepGeometry* geometry)
{
- // TODO
+ std::list<Handle(GEOM_Field)>::iterator fieldIterator = fieldList.begin();
+ while (fieldIterator != fieldList.end())
+ {
+ Handle(GEOM_Field) currField = (*fieldIterator++);
+
+ int fdim = currField->GetDimension();
+ int ftype = currField->GetDataType();
+ int nbComponents = currField->GetNbComponents();
+ std::string name = currField->GetName().ToCString();
+
+ XAO::Field* field = xaoObject->addField((XAO::Type)ftype, (XAO::Dimension)fdim, nbComponents, name);
+
+ Handle(TColStd_HArray1OfExtendedString) components = currField->GetComponents();
+ std::cout << "nb comp " << nbComponents << std::endl;
+ std::cout << components->Lower() << " - " << components->Upper() << std::endl;
+ for (int i = components->Lower(), j = 0; i <= components->Upper(); ++i, ++j)
+ {
+ field->setComponentName(j, TCollection_AsciiString(components->Value(i)).ToCString());
+ }
+
+ std::list< Handle(GEOM_FieldStep)> steps = currField->GetSteps();
+ std::list<Handle(GEOM_FieldStep)>::iterator stepIterator = steps.begin();
+ while (stepIterator != steps.end())
+ {
+ Handle(GEOM_FieldStep) currStep = (*stepIterator++);
+
+ XAO::Step* step = field->addNewStep(currStep->GetID());
+ step->setStamp(currStep->GetStamp());
+
+ switch (ftype)
+ {
+ case 0: // bool
+ {
+ XAO::BooleanStep* bs = (XAO::BooleanStep*)step;
+ Handle(TColStd_HArray1OfInteger) bvalues = currStep->GetIntValues();
+ std::vector<bool> bv;
+ bv.reserve(bvalues->Upper());
+ for ( int i = bvalues->Lower(), nb = bvalues->Upper(); i <= nb; ++i )
+ {
+ bv.push_back(bvalues->Value(i) != 0);
+ }
+ bs->setValues(bv);
+ break;
+ }
+ case 1: // integer
+ {
+ XAO::IntegerStep* is = (XAO::IntegerStep*)step;
+ Handle(TColStd_HArray1OfInteger) ivalues = currStep->GetIntValues();
+ std::vector<int> iv;
+ iv.reserve(ivalues->Upper());
+ for ( int i = ivalues->Lower(), nb = ivalues->Upper(); i <= nb; ++i )
+ {
+ iv.push_back(ivalues->Value(i));
+ }
+ is->setValues(iv);
+ break;
+ }
+ case 2: // double
+ {
+ XAO::DoubleStep* ds = (XAO::DoubleStep*)step;
+ Handle(TColStd_HArray1OfReal) dvalues = currStep->GetDoubleValues();
+ std::vector<double> dv;
+ dv.reserve(dvalues->Upper());
+ for ( int i = dvalues->Lower(), nb = dvalues->Upper(); i <= nb; ++i )
+ {
+ dv.push_back(dvalues->Value(i));
+ }
+ ds->setValues(dv);
+ break;
+ }
+ case 3: // string
+ {
+ XAO::StringStep* ss = (XAO::StringStep*)step;
+ Handle(TColStd_HArray1OfExtendedString) svalues = currStep->GetStringValues();
+ std::vector<std::string> sv;
+ sv.reserve(svalues->Upper());
+ for ( int i = svalues->Lower(), nb = svalues->Upper(); i <= nb; ++i )
+ {
+ sv.push_back(TCollection_AsciiString(svalues->Value(i)).ToCString());
+ }
+ ss->setValues(sv);
+ break;
+ }
+ }
+ }
+ }
}
void GEOMImpl_IInsertOperations::exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry)
switch (subObject->GetValue().ShapeType())
{
case TopAbs_VERTEX:
- geometry->changeVertexName(subIndex, subObject->GetName().ToCString());
- break;
+ geometry->changeVertexName(subIndex, subObject->GetName().ToCString());
+ break;
case TopAbs_EDGE:
- geometry->changeEdgeName(subIndex, subObject->GetName().ToCString());
- break;
+ geometry->changeEdgeName(subIndex, subObject->GetName().ToCString());
+ break;
case TopAbs_FACE:
- geometry->changeFaceName(subIndex, subObject->GetName().ToCString());
- break;
+ geometry->changeFaceName(subIndex, subObject->GetName().ToCString());
+ break;
case TopAbs_SOLID:
- geometry->changeSolidName(subIndex, subObject->GetName().ToCString());
- break;
+ geometry->changeSolidName(subIndex, subObject->GetName().ToCString());
+ break;
}
}
}
*/
//=============================================================================
bool GEOMImpl_IInsertOperations::ExportXAO(Handle(GEOM_Object) shape,
- std::list<Handle(GEOM_Object)> groupList,
- std::list<Handle(GEOM_Object)> fieldList,
- const char* author,
- const char* fileName)
+ std::list<Handle(GEOM_Object)> groupList,
+ std::list<Handle(GEOM_Field)> fieldList,
+ const char* author,
+ const char* fileName)
{
SetErrorCode(KO);
-
+
if (shape.IsNull()) return false;
// add a new shape function with parameters
pd << "], [";
if (fieldList.size() > 0)
{
- std::list<Handle(GEOM_Object)>::iterator itField = fieldList.begin();
+ std::list<Handle(GEOM_Field)>::iterator itField = fieldList.begin();
pd << (*itField++);
while (itField != fieldList.end())
{
}
void GEOMImpl_IInsertOperations::importSubShapes(XAO::Geometry* xaoGeometry,
- Handle(GEOM_Function) function, int shapeType, int dim,
- Handle(TColStd_HSequenceOfTransient)& subShapeList)
+ Handle(GEOM_Function) function, int shapeType, int dim,
+ Handle(TColStd_HSequenceOfTransient)& subShapeList)
{
Handle(GEOM_Object) subShape;
Handle(GEOM_Function) aFunction;
*/
//=============================================================================
bool GEOMImpl_IInsertOperations::ImportXAO(const char* fileName,
- Handle(GEOM_Object)& shape,
- Handle(TColStd_HSequenceOfTransient)& subShapes,
- Handle(TColStd_HSequenceOfTransient)& groups,
- Handle(TColStd_HSequenceOfTransient)& fields)
+ Handle(GEOM_Object)& shape,
+ Handle(TColStd_HSequenceOfTransient)& subShapes,
+ Handle(TColStd_HSequenceOfTransient)& groups,
+ Handle(TColStd_HSequenceOfTransient)& fields)
{
SetErrorCode(KO);
function = group->GetLastFunction();
}
- // TODO: create the fields
+ // create the fields
+ int nbFields = xaoObject->countFields();
+ for (int i = 0; i < nbFields; ++i)
+ {
+ XAO::Field* xaoField = xaoObject->getField(i);
+
+ Handle(TColStd_HArray1OfExtendedString) components = new TColStd_HArray1OfExtendedString(0, xaoField->countComponents());
+ for (int j = 0; j < xaoField->countComponents(); ++j)
+ {
+ components->SetValue(j, (TCollection_ExtendedString)xaoField->getComponentName(j).c_str());
+ }
+
+ Handle(GEOM_Field) field = myFieldOperations->CreateField(shape,
+ xaoField->getName().c_str(),
+ (int)xaoField->getType(),
+ (int)xaoField->getDimension(),
+ components);
+
+ switch (xaoField->getType())
+ {
+ case XAO::BOOLEAN:
+ {
+ XAO::BooleanField* bfield = (XAO::BooleanField*)xaoField;
+ for (int j = 0; j < xaoField->countSteps(); ++j)
+ {
+ XAO::BooleanStep* bstep = bfield->getStep(j);
+ Handle(GEOM_FieldStep) step = field->AddStep(bstep->getStep(), bstep->getStamp());
+
+ Handle(TColStd_HArray1OfInteger) values = new TColStd_HArray1OfInteger(0, bstep->countValues());
+ std::vector<bool> bvalues = bstep->getValues();
+ for (int k = 0; k < bstep->countValues(); ++k)
+ {
+ values->SetValue(0, bvalues[k] ? 1 : 0);
+ }
+ step->SetValues(values);
+ }
+ break;
+ }
+ case XAO::INTEGER:
+ {
+ XAO::IntegerField* ifield = (XAO::IntegerField*)xaoField;
+ for (int j = 0; j < xaoField->countSteps(); ++j)
+ {
+ XAO::IntegerStep* istep = ifield->getStep(j);
+ Handle(GEOM_FieldStep) step = field->AddStep(istep->getStep(), istep->getStamp());
+
+ Handle(TColStd_HArray1OfInteger) values = new TColStd_HArray1OfInteger(0, istep->countValues());
+ std::vector<int> ivalues = istep->getValues();
+ for (int k = 0; k < istep->countValues(); ++k)
+ {
+ values->SetValue(0, ivalues[k]);
+ }
+ step->SetValues(values);
+ }
+ break;
+ }
+ case XAO::DOUBLE:
+ {
+ XAO::DoubleField* dfield = (XAO::DoubleField*)xaoField;
+ for (int j = 0; j < xaoField->countSteps(); ++j)
+ {
+ XAO::DoubleStep* dstep = dfield->getStep(j);
+ Handle(GEOM_FieldStep) step = field->AddStep(dstep->getStep(), dstep->getStamp());
+
+ Handle(TColStd_HArray1OfReal) values = new TColStd_HArray1OfReal(0, dstep->countValues());
+ std::vector<double> dvalues = dstep->getValues();
+ for (int k = 0; k < dstep->countValues(); ++k)
+ {
+ values->SetValue(0, dvalues[k]);
+ }
+ step->SetValues(values);
+ }
+ break;
+ }
+ case XAO::STRING:
+ {
+ XAO::StringField* sfield = (XAO::StringField*)xaoField;
+ for (int j = 0; j < xaoField->countSteps(); ++j)
+ {
+ XAO::StringStep* sstep = sfield->getStep(j);
+ Handle(GEOM_FieldStep) step = field->AddStep(sstep->getStep(), sstep->getStamp());
+
+ Handle(TColStd_HArray1OfExtendedString) values = new TColStd_HArray1OfExtendedString(0, sstep->countValues());
+ std::vector<std::string> svalues = sstep->getValues();
+ for (int k = 0; k < sstep->countValues(); ++k)
+ {
+ values->SetValue(0, TCollection_ExtendedString(svalues[k].c_str()));
+ }
+ step->SetValues(values);
+ }
+ break;
+ }
+ }
+
+ fields->Append(field);
+ }
// make a Python command
GEOM::TPythonDump pd(function);
#include "GEOM_IOperations.hxx"
#include "GEOM_Engine.hxx"
#include "GEOM_Object.hxx"
+#include "GEOM_Field.hxx"
#include <Basics_OCCTVersion.hxx>
class GEOMImpl_IShapesOperations;
class GEOMImpl_IGroupOperations;
+class GEOMImpl_IFieldOperations;
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
class Handle_TColStd_HArray1OfByte;
int& theWidth, int& theHeight);
Standard_EXPORT std::list<int> GetAllTextures();
-
+
Standard_EXPORT bool ExportXAO(Handle(GEOM_Object) shape,
- std::list<Handle(GEOM_Object)> groupList,
- std::list<Handle(GEOM_Object)> fieldList,
- const char* author,
- const char* fileName);
+ std::list<Handle(GEOM_Object)> groupList,
+ std::list<Handle(GEOM_Field)> fieldList,
+ const char* author,
+ const char* fileName);
Standard_EXPORT bool ImportXAO(const char* fileName,
- Handle(GEOM_Object)& shape,
- Handle(TColStd_HSequenceOfTransient)& subShapes,
- Handle(TColStd_HSequenceOfTransient)& groups,
- Handle(TColStd_HSequenceOfTransient)& fields);
+ Handle(GEOM_Object)& shape,
+ Handle(TColStd_HSequenceOfTransient)& subShapes,
+ Handle(TColStd_HSequenceOfTransient)& groups,
+ Handle(TColStd_HSequenceOfTransient)& fields);
private:
Standard_Boolean InitResMgr ();
void importSubShapes(XAO::Geometry* xaoGeometry, Handle(GEOM_Function) function,
- int shapeType, int dim,
- Handle(TColStd_HSequenceOfTransient)& subshapeList);
+ int shapeType, int dim,
+ Handle(TColStd_HSequenceOfTransient)& subshapeList);
void exportSubshapes(const Handle(GEOM_Object)& shape, XAO::BrepGeometry* geometry);
- void exportFields(std::list<Handle(GEOM_Object)> fieldList, XAO::Xao* xaoObject,
- XAO::BrepGeometry* geometry);
+ void exportFields(std::list<Handle(GEOM_Field)> fieldList, XAO::Xao* xaoObject,
+ XAO::BrepGeometry* geometry);
void exportGroups(std::list<Handle(GEOM_Object)> groupList, XAO::Xao* xaoObject,
- XAO::BrepGeometry* geometry);
+ XAO::BrepGeometry* geometry);
private:
Handle(Resource_Manager) myResMgr;
Handle(Resource_Manager) myResMgrUser;
GEOMImpl_IShapesOperations* myShapesOperations;
GEOMImpl_IGroupOperations* myGroupOperations;
+ GEOMImpl_IFieldOperations* myFieldOperations;
};
#endif
*/
//=============================================================================
CORBA::Boolean GEOM_IInsertOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape,
- const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields,
- const char* author, const char* fileName)
+ const GEOM::ListOfGO& groups,
+ const GEOM::ListOfFields& fields,
+ const char* author,
+ const char* fileName)
{
bool isGood = false;
// Set a not done flag
if (gobj.IsNull()) return false;
groupsObj.push_back(gobj);
}
-
+
// Get the reference fields
ind = 0;
- std::list<Handle(GEOM_Object)> fieldsObj;
+ std::list<Handle(GEOM_Field)> fieldsObj;
for (; ind < fields.length(); ind++)
{
- Handle(GEOM_Object) fobj = GetObjectImpl(fields[ind]);
+ Handle(GEOM_Field) fobj = Handle(GEOM_Field)::DownCast(GetBaseObjectImpl(fields[ind]));
if (fobj.IsNull()) return false;
fieldsObj.push_back(fobj);
}
*/
//=============================================================================
CORBA::Boolean GEOM_IInsertOperations_i::ImportXAO(const char* fileName,
- GEOM::GEOM_Object_out shape,
- GEOM::ListOfGO_out subShapes,
- GEOM::ListOfGO_out groups,
- GEOM::ListOfGO_out fields)
+ GEOM::GEOM_Object_out shape,
+ GEOM::ListOfGO_out subShapes,
+ GEOM::ListOfGO_out groups,
+ GEOM::ListOfFields_out fields)
{
GEOM::GEOM_Object_var vshape;
shape = vshape._retn();
subShapes = new GEOM::ListOfGO;
groups = new GEOM::ListOfGO;
- fields = new GEOM::ListOfGO;
+ fields = new GEOM::ListOfFields;
// Set a not done flag
GetOperations()->SetNotDone();
fields->length(n);
for (int i = 1; i <= n; i++)
{
- (*fields)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedFields->Value(i)));
+ // TODO: FPS
+ //(*fields)[i - 1] = GetObject(Handle(GEOM_Field)::DownCast(importedFields->Value(i)));
}
shape = GetObject(hshape);
GEOM::ListOfLong* GetAllTextures();
CORBA::Boolean ExportXAO (GEOM::GEOM_Object_ptr shape,
- const GEOM::ListOfGO& groups,
- const GEOM::ListOfGO& fields,
- const char* author,
- const char* fileName);
+ const GEOM::ListOfGO& groups,
+ const GEOM::ListOfFields& fields,
+ const char* author,
+ const char* fileName);
CORBA::Boolean ImportXAO (const char* fileName,
- GEOM::GEOM_Object_out shape,
- GEOM::ListOfGO_out subShapes,
- GEOM::ListOfGO_out groups,
- GEOM::ListOfGO_out fields);
+ GEOM::GEOM_Object_out shape,
+ GEOM::ListOfGO_out subShapes,
+ GEOM::ListOfGO_out groups,
+ GEOM::ListOfFields_out fields);
::GEOMImpl_IInsertOperations* GetOperations()
{ return (::GEOMImpl_IInsertOperations*)GetImpl(); }
// ExportXAO
//=============================================================================
CORBA::Boolean GEOM_Superv_i::ExportXAO (GEOM::GEOM_Object_ptr shape,
- const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields,
+ const GEOM::ListOfGO& groups, const GEOM::ListOfFields& fields,
const char* author, const char* fileName)
{
beginService( " GEOM_Superv_i::ExportXAO" );
// ImportXAO
//=============================================================================
CORBA::Boolean GEOM_Superv_i::ImportXAO (const char* fileName, GEOM::GEOM_Object_out shape,
- GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfGO_out fields)
+ GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfFields_out fields)
{
return false;
}
// ImportExport Operations //
//-----------------------------------------------------------//
CORBA::Boolean ExportXAO(GEOM::GEOM_Object_ptr shape,
- const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields,
+ const GEOM::ListOfGO& groups, const GEOM::ListOfFields& fields,
const char* author, const char* fileName);
CORBA::Boolean ImportXAO(const char* fileName, GEOM::GEOM_Object_out shape,
- GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfGO_out fields);
+ GEOM::ListOfGO_out subShapes, GEOM::ListOfGO_out groups, GEOM::ListOfFields_out fields);
//-----------------------------------------------------------//
// Advanced Operations //
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
+#include <SUIT_OverrideCursor.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
+#include <SalomeApp_Tools.h>
#include <LightApp_SelectionMgr.h>
#include <QLabel>
#include <QListWidget>
#include <QFileDialog>
#include <QMap>
-//#include <ui_ImportExportGUI_1Sel1LineEdit2ListWidget_QTD.h>
// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <GEOMImpl_Types.hxx>
#include "ImportExportGUI_ExportXAODlg.h"
-//#include "ImportExportGUI_Widgets.h"
//=================================================================================
// Constructor
lstGroups = new QListWidget(gbxFilter);
lstGroups->setSelectionMode(QAbstractItemView::ExtendedSelection);
lstFields = new QListWidget(gbxFilter);
- lstFields ->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ lstFields->setSelectionMode(QAbstractItemView::ExtendedSelection);
line++; col = 0;
gridLayoutFilter->addWidget(lstGroups, line, col++, 1, 1);
connect(btnFileSelect, SIGNAL(clicked()), this, SLOT(btnFileSelectClicked()));
-
initName(tr("GEOM_EXPORTXAO"));
SelectionIntoArgument();
}
item->setData(Qt::UserRole, QVariant(i));
item->setText(GEOMBase::GetName(groups[i]));
lstGroups->addItem(item);
+ item->setSelected(true);
m_groups.append(GEOM::GeomObjPtr(groups[i].in()));
}
lstGroups->sortItems(Qt::AscendingOrder);
- // TODO: add fields
+ // add fields
+ GEOM::GEOM_IFieldOperations_var fieldOp = getGeomEngine()->GetIFieldOperations(getStudyId());
+
+ GEOM::ListOfFields_var fields = fieldOp->GetFields(m_mainObj);
+ for (int i = 0, n = fields->length(); i < n; i++)
+ {
+ QListWidgetItem* item = new QListWidgetItem();
+ item->setData(Qt::UserRole, QVariant(i));
+ item->setText(fields[i]->GetName());
+ lstFields->addItem(item);
+ item->setSelected(true);
+ m_fields.append(GEOM::GeomFieldPtr(fields[i].in()));
+ }
+ lstFields->sortItems(Qt::AscendingOrder);
}
}
//=================================================================================
void ImportExportGUI_ExportXAODlg::ClickOnOk()
{
+ setIsApplyAndClose(true);
if (ClickOnApply())
ClickOnCancel();
+ setIsApplyAndClose(false);
}
//=================================================================================
//=================================================================================
bool ImportExportGUI_ExportXAODlg::ClickOnApply()
{
- if (!onAccept())
+ if (!isApplyAndClose())
+ {
+ setIsDisableBrowsing(true);
+ setIsDisplayResult(false);
+ }
+
+ QString msg;
+ if (!isValid(msg))
+ {
+ showError(msg);
return false;
+ }
+ SUIT_OverrideCursor wc;
+ SUIT_Session::session()->activeApplication()->putInfo("");
- initName();
+ try
+ {
+ if (openCommand())
+ if (!execute(/*isApplyAndClose()*/))
+ {
+ abortCommand();
+ showError();
+ return false;
+ }
+ }
+ catch (const SALOME::SALOME_Exception& e)
+ {
+ SalomeApp_Tools::QtCatchCorbaException(e);
+ abortCommand();
+ return false;
+ }
+ commitCommand();
+
+ if (!isApplyAndClose())
+ {
+ setIsDisableBrowsing(false);
+ setIsDisplayResult(true);
+ }
+
+ processObject();
return true;
}
// function : execute
// purpose :
//=================================================================================
-bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects)
+bool ImportExportGUI_ExportXAODlg::execute()
{
bool res = false;
// get selected fields
QList<QListWidgetItem*> selFields = lstFields->selectedItems();
- GEOM::ListOfGO_var fields = new GEOM::ListOfGO();
+ GEOM::ListOfFields_var fields = new GEOM::ListOfFields();
fields->length(m_fields.count());
+ i = 0;
for (QList<QListWidgetItem*>::iterator it = selFields.begin(); it != selFields.end(); ++it)
{
QListWidgetItem* item = (*it);
// call engine function
GEOM::GEOM_IInsertOperations_var ieOp = GEOM::GEOM_IInsertOperations::_narrow(getOperation());
res = ieOp->ExportXAO(m_mainObj, groups, fields,
- author.toStdString().c_str(),
- fileName.toStdString().c_str());
+ author.toStdString().c_str(),
+ fileName.toStdString().c_str());
return res;
}
// redefined from GEOMBase_Helper
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid(QString&);
- virtual bool execute(ObjectList&);
+ virtual bool execute();
private:
void Init();
private:
GEOM::GEOM_Object_var m_mainObj;
QList<GEOM::GeomObjPtr> m_groups;
- QList<GEOM::GeomObjPtr> m_fields;
+ QList<GEOM::GeomFieldPtr> m_fields;
QLineEdit* ledShape;
QLineEdit* ledFileName;
QLineEdit* ledAuthor;
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
-// void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void btnFileSelectClicked();
void ImportExportGUI_ImportXAODlg::btnFileSelectClicked()
{
QString selFile = QFileDialog::getOpenFileName(this, tr("GEOM_SELECT_EXPORT_XAO"),
- QString(), tr("XAO_FILES"));
+ QString(), tr("XAO_FILES"));
if (!selFile.isEmpty())
{
ledFileName->setText(selFile);
QString fileName = ledFileName->text();
GEOM::GEOM_Object_var shape;
- GEOM::ListOfGO_var groups, fields, subShapes;
+ GEOM::ListOfGO_var groups, subShapes;
+ GEOM::ListOfFields_var fields;
GEOM::GEOM_IInsertOperations_var ieOp = GEOM::GEOM_IInsertOperations::_narrow(getOperation());
res = ieOp->ImportXAO(fileName.toStdString().c_str(), shape, subShapes, groups, fields);
}
for (int i = 0; i < fields->length(); i++)
{
- objects.push_back(GEOM::GEOM_Object::_duplicate(fields[i]));
+ //objects.push_back(GEOM::GEOM_Field::_duplicate(fields[i]));
}
return res;
return countFaces();
if (dim == XAO::SOLID)
return countSolids();
+ if (dim == XAO::WHOLE)
+ return 1;
throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim);
}
xmlDocPtr exportXMLDoc(Xao* xaoObject);
void exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePtr xao);
void exportGeometricElements(Geometry* xaoGeometry, xmlNodePtr topology,
- XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag);
+ XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag);
void exportGroups(Xao* xaoObject, xmlNodePtr xao);
void exportFields(Xao* xaoObject, xmlNodePtr xao);
void exportStep(Step* step, Field* field, xmlNodePtr nodeSteps);
void parseStepElementNode(xmlNodePtr eltNode, Step* step);
std::string readStringProp(xmlNodePtr node, const xmlChar* attribute,
- const bool& required, const std::string& defaultValue, const std::string& exception = std::string(""));
+ const bool& required, const std::string& defaultValue, const std::string& exception = std::string(""));
int readIntegerProp(xmlNodePtr node, const xmlChar* attribute,
- const bool& required, const int& defaultValue, const std::string& exception = std::string(""));
+ const bool& required, const int& defaultValue, const std::string& exception = std::string(""));
std::string readStringProp(xmlNodePtr node, const xmlChar* attribute,
- const bool& required, const std::string& defaultValue,
- const std::string& exception /*= std::string() */)
+ const bool& required, const std::string& defaultValue,
+ const std::string& exception /*= std::string() */)
{
xmlChar* strAttr = xmlGetProp(node, attribute);
if (strAttr == NULL)
}
int readIntegerProp(xmlNodePtr node, const xmlChar* attribute,
- const bool& required, const int& defaultValue,
- const std::string& exception /*= std::string() */)
+ const bool& required, const int& defaultValue,
+ const std::string& exception /*= std::string() */)
{
xmlChar* strAttr = xmlGetProp(node, attribute);
if (strAttr == NULL)
}
void exportGeometricElements(Geometry* xaoGeometry,
- xmlNodePtr topology, XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag)
+ xmlNodePtr topology, XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag)
{
xmlNodePtr vertices = xmlNewChild(topology, 0, colTag, 0);
xmlNewProp(vertices, C_ATTR_COUNT, BAD_CAST XaoUtils::intToString(xaoGeometry->countElements(dim)).c_str());
int component = readIntegerProp(valNode, C_ATTR_VALUE_COMPONENT, true, -1);
xmlChar* data = xmlNodeGetContent(valNode->children);
- if (data == NULL)
+ std::string value = (char*)data;
+ if (data != NULL)
+ {
+ value = (char*)data;
+ }
+ else if (step->getType() != XAO::STRING)
{
throw XAO_Exception(MsgBuilder() << "Line " << valNode->line << ": no content for value.");
}
- std::string value = (char*)data;
step->setStringValue(index, component, value);
}
}