*/
static QString partitionName( const ObjectKind theObjectKind );
+ /**
+ * Creates the default Strickler table object: both GUI data object and corresponding model object
+ * \param theDocument a document into which created object will be added
+ * \param theParent a created object will be appended as a child of this GUI object
+ */
+ void createDefaultStricklerTable( const Handle(HYDROData_Document)& theDocument,
+ LightApp_DataObject* theParent );
+
protected:
/**
* Returns the document for the current study
const QString& theParentEntry,
const bool theIsBuildTree ,
const bool theIsInOperation = false );
- /**
- * Creates the default Strickler table object: both GUI data object and corresponding model object
- * \param theDocument a document into which created object will be added
- * \param theParent a created object will be appended as a child of this GUI object
- */
- void createDefaultStricklerTable( const Handle(HYDROData_Document)& theDocument,
- LightApp_DataObject* theParent );
/**
* Build partition for object.
* \param theObject gui object for which the partition will be build
//
#include "HYDROGUI_DeleteOp.h"
-
+#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_DeleteDlg.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Tool.h"
HYDROGUI_DeleteDlg aDeleteDlg( module()->getApp()->desktop() );
aDeleteDlg.setObjectsToRemove( anObjNames );
+ bool isLastStricklerRemoved = false;
if ( aDeleteDlg.exec() != HYDROGUI_DeleteDlg::Accepted )
{
abort();
return;
- } else {
+ }
+ else
+ {
QStringList aTableNames =
HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_STRICKLER_TABLE, false );
aTableNames += anObjNames;
- if ( aTableNames.toSet().size() == anObjNames.size() ) {
+ if ( aTableNames.toSet().size() == anObjNames.size() )
+ {
aWarningMsg = tr("DELETE_LAST_TABLE_WRN");
+ isLastStricklerRemoved = true;
}
}
}
}
+ if( isLastStricklerRemoved )
+ {
+ HYDROGUI_DataModel* aModel = dynamic_cast<HYDROGUI_DataModel*>( module()->dataModel() );
+ aModel->createDefaultStricklerTable( doc(), 0 );
+ }
+
commitDocOperation();
module()->update( UF_Model | UF_Viewer | UF_OCCViewer | UF_VTKViewer );
#include <test_HYDROData_StricklerTable.h>
#include <HYDROData_Document.h>
+#include <HYDROData_Iterator.h>
#include <HYDROData_StricklerTable.h>
#include <HYDROData_Tool.h>
#include <QStringList>
aDoc->Close();
}
+
+void test_HYDROData_StricklerTable::test_duplication_refs_613()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_StricklerTable) aTable1 =
+ Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
+ aTable1->Set( "type1", 1.5 );
+ aTable1->SetColor( "type1", QColor( 10, 20, 30 ) );
+ aTable1->SetName( "DefStrickler_1" );
+
+ Handle(HYDROData_StricklerTable) aTable2 =
+ Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
+ aTable1->CopyTo( aTable2, true );
+
+ CPPUNIT_ASSERT_EQUAL( QString( "DefStrickler_2" ), aTable2->GetName() );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, aTable2->Get( "type1", 0.0 ), 1E-5 );
+ CPPUNIT_ASSERT_EQUAL( QColor( 10, 20, 30 ), aTable2->GetColor( "type1" ) );
+
+ aDoc->StartOperation();
+ aTable1->Remove();
+ aTable2->Remove();
+ Handle(HYDROData_StricklerTable) aTable3 =
+ Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
+ aTable3->SetName( "DefStrickler_1" );
+ aDoc->CommitOperation();
+
+ HYDROData_Iterator anIt1( aDoc, KIND_STRICKLER_TABLE );
+ CPPUNIT_ASSERT_EQUAL( true, anIt1.More() );
+ CPPUNIT_ASSERT_EQUAL( QString( "DefStrickler_1" ), anIt1.Current()->GetName() );
+ anIt1.Next();
+ CPPUNIT_ASSERT_EQUAL( false, anIt1.More() );
+
+ aDoc->Undo();
+
+ HYDROData_Iterator anIt2( aDoc, KIND_STRICKLER_TABLE );
+ CPPUNIT_ASSERT_EQUAL( true, anIt2.More() );
+ CPPUNIT_ASSERT_EQUAL( QString( "DefStrickler_1" ), anIt2.Current()->GetName() );
+ anIt2.Next();
+ CPPUNIT_ASSERT_EQUAL( true, anIt2.More() );
+ CPPUNIT_ASSERT_EQUAL( QString( "DefStrickler_2" ), anIt2.Current()->GetName() );
+ anIt2.Next();
+ CPPUNIT_ASSERT_EQUAL( false, anIt2.More() );
+
+ aDoc->Close();
+}
+
+void test_HYDROData_StricklerTable::test_dump_python()
+{
+ //TODO
+}
CPPUNIT_TEST( test_type_by_attr );
CPPUNIT_TEST( test_unique_attr_name );
CPPUNIT_TEST( test_colors_sync );
+ CPPUNIT_TEST( test_duplication_refs_613 );
+ CPPUNIT_TEST( test_dump_python );
CPPUNIT_TEST_SUITE_END();
public:
void test_type_by_attr();
void test_unique_attr_name();
void test_colors_sync();
+ void test_duplication_refs_613();
+ void test_dump_python();
};
CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_StricklerTable );