return QString();
}
+QString HYDROData_Entity::GetType() const
+{
+ return Type( GetKind() );
+}
+
+QString HYDROData_Entity::Type( ObjectKind theKind )
+{
+ switch( theKind )
+ {
+ case KIND_UNKNOWN:
+ return "Unknown";
+ case KIND_IMAGE:
+ return "Image";
+ case KIND_POLYLINE:
+ return "Polyline";
+ case KIND_BATHYMETRY:
+ return "Bathymetry";
+ case KIND_ALTITUDE:
+ return "Altitude";
+ case KIND_IMMERSIBLE_ZONE:
+ return "Immersible_zone";
+ case KIND_RIVER:
+ return "River";
+ case KIND_STREAM:
+ return "Stream";
+ case KIND_CONFLUENCE:
+ return "Confluence";
+ case KIND_CHANNEL:
+ return "Channel";
+ case KIND_OBSTACLE:
+ return "Obstacle";
+ case KIND_DIGUE:
+ return "Digue";
+ case KIND_PROFILE:
+ return "Profile";
+ case KIND_PROFILEUZ:
+ return "Profile_UZ";
+ case KIND_POLYLINEXY:
+ return "Polyline_XY";
+ case KIND_CALCULATION:
+ return "Calculation_case";
+ case KIND_ZONE:
+ return "Zone";
+ case KIND_REGION:
+ return "Region";
+ case KIND_VISUAL_STATE:
+ return "Visual_state";
+ case KIND_ARTIFICIAL_OBJECT:
+ return "Artificial_object";
+ case KIND_NATURAL_OBJECT:
+ return "Natural_object";
+ case KIND_DUMMY_3D:
+ return "Dummy_3d";
+ case KIND_SHAPES_GROUP:
+ return "Shapes_group";
+ case KIND_SPLIT_GROUP:
+ return "Split_group";
+ case KIND_STREAM_ALTITUDE:
+ return "Stream_altitude";
+ case KIND_OBSTACLE_ALTITUDE:
+ return "Obstacle_altitude";
+ case KIND_STRICKLER_TABLE:
+ return "Strickler_table";
+ case KIND_LAND_COVER_OBSOLETE:
+ return "Land_cover";
+ case KIND_CHANNEL_ALTITUDE:
+ return "Channel_altitude";
+ case KIND_LAND_COVER_MAP:
+ return "Land_cover_map";
+ case KIND_DTM:
+ return "DTM";
+ }
+ return "";
+}
+
QString HYDROData_Entity::GetObjPyName() const
{
QString aName = GetName();
aName.replace(QRegExp("[\\W]"), "_");
+ if( aName[0].isDigit() )
+ aName = GetType() + "_" + aName;
+
return aName;
}
const ObjectKind KIND_CHANNEL_ALTITUDE = 28;
const ObjectKind KIND_LAND_COVER_MAP = 29;
const ObjectKind KIND_DTM = 30;
-const ObjectKind KIND_LAST = KIND_DTM;
+const ObjectKind KIND_LAST = KIND_DTM+1;
class MapOfTreatedObjects : public QMap<QString,Handle(Standard_Transient)>
{
public:
DEFINE_STANDARD_RTTIEXT(HYDROData_Entity, MMgt_TShared);
+ HYDRODATA_EXPORT static QString Type( ObjectKind );
+ HYDRODATA_EXPORT virtual QString GetType() const;
+
/**
* Returns the kind of this object. Must be redefined in all objects of known type.
*/
aDoc->Close();
}
+
+void test_HYDROData_Entity::testPythonNameChoice()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
+
+ anObj->SetName("test");
+ CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "test" ) );
+
+ anObj->SetName("test_1");
+ CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "test_1" ) );
+
+ anObj->SetName("test 1");
+ CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "test_1" ) );
+
+ anObj->SetName(" test abc hello ");
+ CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "__test_abc____hello_____" ) );
+
+ anObj->SetName("123");
+ CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "Image_123" ) );
+
+ anObj->SetName(" 123");
+ CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "__123" ) );
+
+ aDoc->Close();
+}
+
+void test_HYDROData_Entity::testTypes()
+{
+ for( int i=0; i<KIND_LAST; i++ )
+ {
+ CPPUNIT_ASSERT_EQUAL( false, HYDROData_Entity::Type( (ObjectKind)i ).isEmpty() );
+ CPPUNIT_ASSERT_EQUAL( false, HYDROData_Entity::Type( (ObjectKind)i ).contains(' ') );
+ }
+}
CPPUNIT_TEST(testName);
CPPUNIT_TEST(testRemove);
CPPUNIT_TEST(testCopy);
+ CPPUNIT_TEST(testPythonNameChoice);
+ CPPUNIT_TEST(testTypes);
CPPUNIT_TEST_SUITE_END();
private:
// checks the copying of object
void testCopy();
+
+ void testPythonNameChoice();
+ void testTypes();
};
CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_Entity);