HYDROGUI_UpdateImageOp.h
HYDROGUI_VisualStateOp.h
HYDROGUI_Wizard.h
+ HYDROGUI_Zone.h
)
QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
HYDROGUI_UpdateImageOp.cxx
HYDROGUI_VisualStateOp.cxx
HYDROGUI_Wizard.cxx
+ HYDROGUI_Zone.cxx
)
add_definitions(
#include <HYDROData_Document.h>
#include <HYDROData_Entity.h>
-#include <HYDROData_Object.h>
+#include <HYDROGUI_DataObject.h>
#include <CAM_Application.h>
#include <LightApp_DataObject.h>
+#include <SUIT_DataObject.h>
#include <SUIT_FileDlg.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
aLayout->addWidget( myBrowser, 0, 0, 1, 2 );
- QLabel* aBatimetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
+ myBatimetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
myBathymetryChoice = new QComboBox( aFrame );
myBathymetryChoice->addItem( tr( "ZMIN" ) );
myBathymetryChoice->addItem( tr( "ZMAX" ) );
- aLayout->addWidget( aBatimetryLabel, 1, 0 );
+ myBathymetryChoice->setVisible( false );
+ myBatimetryLabel->setVisible( false );
+
+ aLayout->addWidget( myBatimetryLabel, 1, 0 );
aLayout->addWidget( myBathymetryChoice, 1, 1 );
aPage->setLayout( aLayout );
+ connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
+
return aPage;
}
+void HYDROGUI_CalculationDlg::onSelected( SUIT_DataObject* theObject )
+{
+ bool doShow = false;
+ HYDROGUI_DataObject* anObject = dynamic_cast<HYDROGUI_DataObject*>( theObject );
+ if ( anObject )
+ {
+ doShow = anObject->isMergingNeed();
+ }
+ myBathymetryChoice->setVisible( doShow );
+ myBatimetryLabel->setVisible( doShow );
+}
+
void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
{
myObjectName->setText( theName );
class QLineEdit;
class QListWidget;
class QComboBox;
+class QLabel;
class QStringList;
class HYDROGUI_DataBrowser;
class HYDROGUI_NameValidator;
+class SUIT_DataObject;
class HYDROGUI_CalculationDlg : public HYDROGUI_Wizard
{
QStringList getSelectedGeomObjects() const;
public slots:
- void onEmptyName();
- void onAlreadyExists( QString theName );
+ void onEmptyName();
+ void onAlreadyExists( QString theName );
+ /**
+ * Process items selection: hide/show bathymetry merge type selector.
+ */
+ void onSelected( SUIT_DataObject* theObject );
signals:
- void addObjects();
- void removeObjects();
- void splitZones();
+ void addObjects();
+ void removeObjects();
+ void splitZones();
private:
QListWidget* myGeomObjects;
- HYDROGUI_DataBrowser* myBrowser;
+ HYDROGUI_DataBrowser* myBrowser;
Handle(HYDROData_CalculationCase) myEditedObject;
- QComboBox* myBathymetryChoice;
+ QComboBox* myBathymetryChoice;
+ QLabel* myBatimetryLabel;
};
#endif
connect( aPanel, SIGNAL( addObjects() ), SLOT( onAddObjects() ) );
connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) );
connect( aPanel, SIGNAL( splitZones() ), SLOT( onSplitZones() ) );
+ connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
return aPanel;
}
#include "HYDROGUI_DataObject.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_Zone.h"
#include <HYDROData_Bathymetry.h>
#include <HYDROData_CalculationCase.h>
const QString& theParentEntry,
const bool theIsBuildTree )
{
- HYDROGUI_DataObject* aResObj =
- new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
+ HYDROGUI_DataObject* aResObj;
+ Handle(HYDROData_Zone) aRegionZone =
+ Handle(HYDROData_Zone)::DownCast( theModelObject );
+ if( !aRegionZone.IsNull() )
+ {
+ aResObj = new HYDROGUI_Zone( theParent, aRegionZone, theParentEntry );
+ }
+ else
+ {
+ aResObj = new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
+ }
if ( theIsBuildTree )
{
#include "HYDROGUI_DataObject.h"
#include <HYDROData_Image.h>
-#include <HYDROData_Zone.h>
-#include <HYDROData_Object.h>
-#include <HYDROData_Bathymetry.h>
-
#include <SUIT_DataObject.h>
-
#include <TDF_Tool.hxx>
HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent,
return aFont;
}
-QString HYDROGUI_DataObject::text( const int theColumnId ) const
-{
- QString aRes;
- if( !myData.IsNull() )
- {
- if ( theColumnId == RefObjectId || theColumnId == BathymetryId )
- {
- Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( myData );
- if ( !aZone.IsNull() )
- {
- 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() )
- {
- switch ( theColumnId )
- {
- case RefObjectId:
- // Get Ref.Object name
- aRes += aRefGeomObj->GetName() + ", ";
- break;
- case BathymetryId:
- // Get bathymetry name
- aRes += aRefGeomObj->GetBathymetry()->GetName() + ", ";
- }
- }
- }
- }
- if ( aRes.length() > 1 )
- {
- aRes.remove( aRes.length() - 2, 2 );
- }
- }
- else
- {
- aRes = LightApp_DataObject::text( theColumnId );
- }
- }
- return aRes;
-}
-
-QColor HYDROGUI_DataObject::color( const ColorRole theColorRole, const int theColumnId ) const
-{
- //TODO: Implement red color for bathymetry conflicts in case creation dialog
- return LightApp_DataObject::color( theColorRole, theColumnId );
-}
-
-
QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
const bool theWithPrefix )
{
const bool theWithPrefix = true );
/**
- * Returns the text for the specified column.
+ * Returns true if it is a zone which needs merge of bathymetries.
*/
- virtual QString text( const int = NameId ) const;
-
- /**
- * Returns the color for the specified column.
- */
- virtual QColor color( const ColorRole, const int = NameId ) const;
+ virtual bool isMergingNeed() const { return false; }
protected:
Handle(HYDROData_Entity) myData; ///< object from data model
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_Zone.h"
+
+#include <HYDROData_Zone.h>
+#include <HYDROData_Object.h>
+#include <HYDROData_Bathymetry.h>
+
+#include <SUIT_DataObject.h>
+
+HYDROGUI_Zone::HYDROGUI_Zone( SUIT_DataObject* theParent,
+ Handle(HYDROData_Zone) theData,
+ const QString& theParentEntry )
+: HYDROGUI_DataObject( theParent, theData, theParentEntry ), CAM_DataObject( theParent )
+{
+}
+
+QString HYDROGUI_Zone::text( const int theColumnId ) const
+{
+ QString aRes;
+ if( !modelObject().IsNull() )
+ {
+ switch ( theColumnId )
+ {
+ case RefObjectId:
+ // Get Ref.Object name
+ aRes = getRefObjectNames();
+ break;
+ case BathymetryId:
+ // Get bathymetry name
+ aRes = getBathimetryName();
+ break;
+ default:
+ aRes = LightApp_DataObject::text( theColumnId );
+ }
+ }
+ return aRes;
+}
+
+QString HYDROGUI_Zone::getRefObjectNames() const
+{
+ QString aRes;
+ Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( modelObject() );
+ if ( !aZone.IsNull() )
+ {
+ 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 Ref.Object name
+ aRes += aRefGeomObj->GetName() + ", ";
+ }
+ }
+ }
+ if ( aRes.length() > 1 )
+ {
+ aRes.remove( aRes.length() - 2, 2 );
+ }
+ return aRes;
+}
+
+QString HYDROGUI_Zone::getBathimetryName() const
+{
+ QString aRes;
+ Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( modelObject() );
+ if ( !aZone.IsNull() )
+ {
+ HYDROData_SequenceOfObjects aSeq = aZone->GetGeometryObjects();
+ if ( aZone->IsMergingNeed() || aSeq.Length() == 1 )
+ {
+ // 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 += aBathymetry->GetName() + ", ";
+ }
+ }
+ }
+ if ( aRes.length() > 1 )
+ {
+ aRes.remove( aRes.length() - 2, 2 );
+ }
+ }
+ else
+ {
+ switch( aZone->GetMergeType() )
+ {
+ case HYDROData_Zone::Merge_ZMIN: // The minimum values
+ aRes = QObject::tr( "MERGE_ZMIN" );
+ break;
+ case HYDROData_Zone::Merge_ZMAX: // The maximum values
+ aRes = QObject::tr( "MERGE_ZMAX" );
+ break;
+ case HYDROData_Zone::Merge_Object: // Only one bathymetry will be taken into account
+ {
+ Handle(HYDROData_Bathymetry) aBathymetry = aZone->GetMergeBathymetry();
+ if ( !aBathymetry.IsNull() )
+ {
+ aRes = aBathymetry->GetName();
+ }
+ break;
+ }
+ default:
+ aRes = QObject::tr( "MERGE_UNKNOWN" );
+ }
+ }
+ }
+ return aRes;
+}
+
+bool HYDROGUI_Zone::isMergingNeed() const
+{
+ bool aRes = false;
+ if( !modelObject().IsNull() )
+ {
+ Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( modelObject() );
+ if ( !aZone.IsNull() )
+ {
+ aRes = aZone->IsMergingNeed();
+ }
+ }
+ return aRes;
+}
+
+QColor HYDROGUI_Zone::color( const ColorRole theColorRole, const int theColumnId ) const
+{
+ // Implement red color for bathymetry conflicts in case creation dialog
+ QColor aRes;
+ if( isMergingNeed() )
+ {
+ switch( theColorRole )
+ {
+ case Text: // editor foreground (text) color
+ case Foreground: // foreground (text) color
+ aRes = Qt::red;
+ break;
+ case HighlightedText: // highlighted foreground (text) color
+ aRes = Qt::black;
+ break;
+ case Base: // editor background color
+ case Background: // background color
+ case Highlight: // highlight background color
+ default:
+ aRes = Qt::red;
+ }
+ }
+ else
+ {
+ aRes = LightApp_DataObject::color( theColorRole, theColumnId );
+ }
+ return aRes;
+}
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_ZONE_H
+#define HYDROGUI_ZONE_H
+
+#include "HYDROGUI_DataObject.h"
+
+#include <HYDROData_Zone.h>
+
+#include <QString>
+#include <QColor>
+
+/**
+ * \class HYDROGUI_Zone
+ * \brief Browser item presenting a zone, used for object browser tree creation.
+ *
+ * This is an Object Browser item that contains reference to a zone data structure
+ * element inside.
+ */
+class HYDROGUI_Zone : public HYDROGUI_DataObject
+{
+public:
+ /**
+ * Constructor.
+ * \param theParent parent data object
+ * \param theData reference to the corresponding object from data structure
+ * \param theParentEntry entry of the parent data object (for reference objects)
+ */
+ HYDROGUI_Zone( SUIT_DataObject* theParent,
+ Handle(HYDROData_Zone) theData,
+ const QString& theParentEntry );
+
+ /**
+ * Returns the text for the specified column.
+ */
+ QString text( const int = NameId ) const override;
+
+ /**
+ * Returns the color for the specified column.
+ */
+ 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;
+
+ QStringList getBathymetries() const;
+
+private:
+ QString getRefObjectNames() const;
+ QString getBathimetryName() const;
+};
+#endif