- Calculation case dialog labels are updated.
void HYDROData_Zone::SetMergeType( const MergeBathymetriesType& theType )
{
Handle(TDataStd_Integer) anInt;
- if ( !myLab.FindChild( DataTag_MergeType ).FindAttribute( TDataStd_Integer::GetID(), anInt ) )
- anInt = TDataStd_Integer::Set( myLab, 0 );
- anInt->Set( (int)theType );
+ if ( myLab.FindChild( DataTag_MergeType ).FindAttribute( TDataStd_Integer::GetID(), anInt ) )
+ {
+ anInt->Set( (int)theType );
+ }
+ else
+ {
+ anInt = TDataStd_Integer::Set( myLab.FindChild( DataTag_MergeType ), (int)theType );
+ }
}
HYDROData_Zone::MergeBathymetriesType HYDROData_Zone::GetMergeType() const
#include <HYDROData_Document.h>
#include <HYDROData_Entity.h>
-#include <HYDROGUI_DataObject.h>
+#include <HYDROGUI_Zone.h>
#include <CAM_Application.h>
#include <LightApp_DataObject.h>
QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
QWizardPage* aPage = new QWizardPage( wizard() );
QFrame* aFrame = new QFrame( aPage );
- // Calculation name
-// myObjectNameGroup = new QGroupBox( tr( "CALCULATION_NAME" ), aFrame );
-// myObjectName = new QLineEdit( myObjectNameGroup );
+ // Calculation name
myObjectName = new QLineEdit( aPage );
myValidator = new HYDROGUI_NameValidator(module(), myObjectName);
myObjectName->setValidator( myValidator );
connect( myValidator, SIGNAL( emptyName() ), this, SLOT( onEmptyName() ) );
connect( myValidator, SIGNAL( alreadyExists( QString ) ), this, SLOT( onAlreadyExists( QString ) ) );
- //QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
- //aNameLayout->setMargin( 5 );
- //aNameLayout->setSpacing( 5 );
- //aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
- //aNameLayout->addWidget( myObjectName );
-
- // Calculation zones
- //QFrame* anObjectsFrame = new QFrame( aFrame );
-
- //myGeomObjects = new QListWidget( anObjectsFrame );
myGeomObjects = new QListWidget( aPage );
myGeomObjects->setSelectionMode( QListWidget::SingleSelection );
myGeomObjects->setEditTriggers( QListWidget::NoEditTriggers );
QFrame* aFrame = new QFrame( aPage );
QGridLayout* aLayout = new QGridLayout( aPage );
- //Handle(HYDROData_Entity) anEntity = module()->getDataModel()->getDocument()->CreateObject( KIND_CALCULATION );
- myBrowser = new HYDROGUI_DataBrowser( module(), 0/*module()->application()->activeStudy()->root()*/, aPage );
+ myBrowser = new HYDROGUI_DataBrowser( module(), 0, aPage );
myBrowser->setAutoOpenLevel( 3 );
aLayout->setMargin( 5 );
aLayout->setSpacing( 5 );
myBatimetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
myBathymetryChoice = new QComboBox( aFrame );
- myBathymetryChoice->addItem( tr( "ZMIN" ) );
- myBathymetryChoice->addItem( tr( "ZMAX" ) );
myBathymetryChoice->setVisible( false );
myBatimetryLabel->setVisible( false );
aPage->setLayout( aLayout );
connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
+ connect( myBathymetryChoice, SIGNAL( activated( int ) ), SLOT( onMergeTypeSelected( int ) ) );
return aPage;
}
+void HYDROGUI_CalculationDlg::onMergeTypeSelected( int theIndex )
+{
+ int aType = myBathymetryChoice->itemData( theIndex ).toInt();
+ QString aText = myBathymetryChoice->itemText( theIndex );
+ emit setMergeType( aType, aText );
+}
+
void HYDROGUI_CalculationDlg::onSelected( SUIT_DataObject* theObject )
{
bool doShow = false;
- HYDROGUI_DataObject* anObject = dynamic_cast<HYDROGUI_DataObject*>( theObject );
- if ( anObject )
+ HYDROGUI_Zone* aZone = dynamic_cast<HYDROGUI_Zone*>( theObject );
+ if ( aZone )
{
- doShow = anObject->isMergingNeed();
+ doShow = aZone->isMergingNeed();
}
+
+ if ( doShow )
+ {
+ // Fill the merge type combo box
+ bool prevBlock = myBathymetryChoice->blockSignals( true );
+ myCurrentZone = aZone;
+ myBathymetryChoice->clear();
+ myBathymetryChoice->addItem( QObject::tr("MERGE_UNKNOWN"), HYDROData_Zone::Merge_UNKNOWN );
+ myBathymetryChoice->addItem( QObject::tr("MERGE_ZMIN"), HYDROData_Zone::Merge_ZMIN );
+ myBathymetryChoice->addItem( QObject::tr("MERGE_ZMAX"), HYDROData_Zone::Merge_ZMAX );
+ QStringList aList = aZone->getBathymetries();
+ for ( int i = 0; i < aList.length(); i++ )
+ {
+ myBathymetryChoice->addItem( aList.at( i ), HYDROData_Zone::Merge_Object );
+ }
+ // Select the current choice if any
+ int aCurIndex = 0;
+ switch ( aZone->getMergeType() )
+ {
+ case HYDROData_Zone::Merge_ZMIN:
+ aCurIndex = 1;
+ break;
+ case HYDROData_Zone::Merge_ZMAX:
+ aCurIndex = 2;
+ break;
+ case HYDROData_Zone::Merge_Object:
+ aCurIndex = aList.indexOf( aZone->text( HYDROGUI_DataObject::BathymetryId ) );
+ break;
+ default:
+ aCurIndex = 0; // Select unknown by default
+ }
+ myBathymetryChoice->setCurrentIndex( aCurIndex );
+ myBathymetryChoice->blockSignals( prevBlock );
+ }
+
myBathymetryChoice->setVisible( doShow );
myBatimetryLabel->setVisible( doShow );
}
myBrowser->updateTree();
myBrowser->openLevels();
}
+
+HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const
+{
+ return myCurrentZone;
+}
\ No newline at end of file
class HYDROGUI_DataBrowser;
class HYDROGUI_NameValidator;
class SUIT_DataObject;
+class HYDROGUI_Zone;
class HYDROGUI_CalculationDlg : public HYDROGUI_Wizard
{
void setGeomObjects( const QStringList& theObjects );
void setSelectedGeomObjects( const QStringList& theObjects );
QStringList getSelectedGeomObjects() const;
+ HYDROGUI_Zone* getCurrentZone() const;
public slots:
void onEmptyName();
* Process items selection: hide/show bathymetry merge type selector.
*/
void onSelected( SUIT_DataObject* theObject );
+ /**
+ * Process merge type selection: set the selected bathymetry merge type for the currently selected zone.
+ */
+ void onMergeTypeSelected( int theIndex );
signals:
void addObjects();
void removeObjects();
void splitZones();
+ void setMergeType( int theMergeType, QString theBathymetryName );
private:
Handle(HYDROData_CalculationCase) myEditedObject;
QComboBox* myBathymetryChoice;
QLabel* myBatimetryLabel;
+ HYDROGUI_Zone* myCurrentZone;
};
#endif
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_Zone.h"
#include <HYDROData_Polyline.h>
#include <HYDROData_Iterator.h>
connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) );
connect( aPanel, SIGNAL( splitZones() ), SLOT( onSplitZones() ) );
connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
+ connect( aPanel, SIGNAL( setMergeType( int, QString ) ), SLOT( onSetMergeType( int, QString ) ) );
return aPanel;
}
+void HYDROGUI_CalculationOp::onSetMergeType( int theMergeType, QString theBathymetryName )
+{
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( aPanel )
+ {
+ HYDROGUI_Zone* aZone = aPanel->getCurrentZone();
+ if ( aZone )
+ {
+ aZone->setMergeType( theMergeType, theBathymetryName );
+ }
+ }
+}
+
void HYDROGUI_CalculationOp::onAddObjects()
{
// Add geometry objects selected in the module browser to the calculation case
* Remove selected objects from the calculation case.
*/
void onRemoveObjects();
+ /**
+ * Set the given bathymetry merge type to the current zone.
+ */
+ void onSetMergeType( int theMergeType, QString theBathymetryName );
void onSplitZones();
void onLastViewClosed( SUIT_ViewManager* );
static QString dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
const bool theWithPrefix = true );
- /**
- * Returns true if it is a zone which needs merge of bathymetries.
- */
- virtual bool isMergingNeed() const { return false; }
-
protected:
Handle(HYDROData_Entity) myData; ///< object from data model
QString myParentEntry;
}
return aRes;
}
+
+QStringList HYDROGUI_Zone::getBathymetries() const
+{
+ QStringList aRes;
+ Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( modelObject() );
+ if ( !aZone.IsNull() )
+ {
+ HYDROData_SequenceOfObjects aSeq = aZone->GetGeometryObjects();
+ // Collect all used bathymetries names when merging is necessary
+ // or just get the name of bathymetry of a single geometry object
+ HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Object) aRefGeomObj =
+ Handle(HYDROData_Object)::DownCast( anIter.Value() );
+ if ( !aRefGeomObj.IsNull() )
+ {
+ // Get bathymetry name
+ Handle(HYDROData_Bathymetry) aBathymetry = aRefGeomObj->GetBathymetry();
+ if ( !aBathymetry.IsNull() && !aRes.contains( aBathymetry->GetName() ))
+ {
+ aRes.append( aBathymetry->GetName() );
+ }
+ }
+ }
+ }
+ return aRes;
+}
+
+HYDROData_Zone::MergeBathymetriesType HYDROGUI_Zone::getMergeType() const
+{
+ HYDROData_Zone::MergeBathymetriesType aRes = HYDROData_Zone::Merge_UNKNOWN;
+ Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( modelObject() );
+ if ( !aZone.IsNull() )
+ {
+ aRes = aZone->GetMergeType();
+ }
+ return aRes;
+}
+
+void HYDROGUI_Zone::setMergeType( int theMergeType, QString theBathymetryName )
+{
+ Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( modelObject() );
+ if ( !aZone.IsNull() )
+ {
+ HYDROData_Zone::MergeBathymetriesType aMergeType =
+ ( HYDROData_Zone::MergeBathymetriesType )theMergeType;
+ aZone->SetMergeType( aMergeType );
+ if ( aMergeType == HYDROData_Zone::Merge_Object )
+ {
+ // Find a bathymetry by the given name and set it as the zone's merge bathymetry
+ HYDROData_SequenceOfObjects aSeq = aZone->GetGeometryObjects();
+ HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Object) aRefGeomObj =
+ Handle(HYDROData_Object)::DownCast( anIter.Value() );
+ if ( !aRefGeomObj.IsNull() )
+ {
+ // Get bathymetry name
+ Handle(HYDROData_Bathymetry) aBathymetry = aRefGeomObj->GetBathymetry();
+ if ( !aBathymetry.IsNull() && theBathymetryName == aBathymetry->GetName() )
+ {
+ aZone->SetMergeBathymetry( aBathymetry );
+ break;
+ }
+ }
+ }
+ }
+ }
+}
/**
* Returns the text for the specified column.
*/
- QString text( const int = NameId ) const override;
+ QString text( const int = NameId ) const override;
/**
* Returns the color for the specified column.
*/
- QColor color( const ColorRole, const int = NameId ) const override;
+ QColor color( const ColorRole, const int = NameId ) const override;
/**
* Returns true if it is a zone which needs merge of bathymetries.
*/
- bool isMergingNeed() const override;
+ bool isMergingNeed() const;
+ /**
+ * Returns the list of bathymetries names.
+ */
QStringList getBathymetries() const;
+ /**
+ * Returns the merging type for conflict bathymetries.
+ */
+ HYDROData_Zone::MergeBathymetriesType getMergeType() const;
+
+ /**
+ * Set the merging type for conflict bathymetries.
+ * If the type is Merge_Object then use the second parameter to set the merge bathymetry.
+ */
+ void setMergeType( int theMergeType, QString theBathymetryName = QString() );
+
private:
QString getRefObjectNames() const;
QString getBathimetryName() const;
<source>REMOVE</source>
<translation>Remove</translation>
</message>
+ <message>
+ <source>MERGE_UNKNOWN</source>
+ <translation>Unresolved Conflict</translation>
+ </message>
+ <message>
+ <source>MERGE_ZMIN</source>
+ <translation>ZMIN</translation>
+ </message>
+ <message>
+ <source>MERGE_ZMAX</source>
+ <translation>ZMAX</translation>
+ </message>
</context>
<context>