From 4bb18a8f971e38d25612f346158d7c0ec99fb47a Mon Sep 17 00:00:00 2001 From: isn Date: Wed, 12 Oct 2016 15:04:35 +0300 Subject: [PATCH] dtm intersections >= 2 is colored in listview --- src/HYDROData/HYDROData_DTM.cxx | 6 ++--- src/HYDROData/HYDROData_DTM.h | 28 ++++++++++----------- src/HYDROGUI/HYDROGUI_ListModel.cxx | 28 +++++++++++++++++++++ src/HYDROGUI/HYDROGUI_ListModel.h | 7 ++++++ src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx | 25 ++++++++++++++++++ src/HYDROGUI/HYDROGUI_OrderedListWidget.h | 4 +++ src/HYDROGUI/HYDROGUI_StreamDlg.cxx | 23 ++++++++++++++--- src/HYDROGUI/HYDROGUI_StreamDlg.h | 4 +++ src/HYDROGUI/HYDROGUI_StreamOp.cxx | 5 +++- 9 files changed, 108 insertions(+), 22 deletions(-) diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx index 736c43b5..9ac801dc 100644 --- a/src/HYDROData/HYDROData_DTM.cxx +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -242,7 +242,7 @@ void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& In TopoDS_Shape& OutOutlet, bool Create3dPres, bool Create2dPres, - std::set InvInd) + std::set& InvInd) { int aLower = InpProfiles.Lower(), anUpper = InpProfiles.Upper(); @@ -341,7 +341,7 @@ void HYDROData_DTM::CreateProfiles(const std::vector& TopoDS_Shape& OutOutlet, bool Create3dPres, bool Create2dPres, - std::set InvInd) + std::set& InvInd) { if (theProfiles.empty()) return; @@ -774,7 +774,7 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate AltitudePoints& theLeft, AltitudePoints& theRight, std::vector& theMainProfiles, - std::set invalInd) + std::set& invalInd) { AltitudePoints points; size_t n = theProfiles.size(); diff --git a/src/HYDROData/HYDROData_DTM.h b/src/HYDROData/HYDROData_DTM.h index 0dc1a891..4835cef1 100644 --- a/src/HYDROData/HYDROData_DTM.h +++ b/src/HYDROData/HYDROData_DTM.h @@ -149,7 +149,7 @@ protected: AltitudePoints& theLeft, AltitudePoints& theRight, std::vector& theMainProfiles, - std::set invalInd ); + std::set& invalInd ); static void PointToWire(const AltitudePoints& pnts, TopoDS_Wire& W ); @@ -174,7 +174,7 @@ protected: TopoDS_Shape& OutOutlet, bool Create3dPres, bool Create2dPres, - std::set InvInd ); + std::set& InvInd ); static void Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF ); @@ -187,18 +187,18 @@ protected: public: HYDRODATA_EXPORT static void CreateProfilesFromDTM ( const HYDROData_SequenceOfObjects& InpProfiles, - double ddz, - double step, - AltitudePoints& points, - TopoDS_Shape& Out3dPres, - TopoDS_Shape& Out2dPres, - TopoDS_Shape& OutLeftB, - TopoDS_Shape& OutRightB, - TopoDS_Shape& OutInlet, - TopoDS_Shape& OutOutlet, - bool Create3dPres, - bool Create2dPres, - std::set InvInd ); + double ddz, + double step, + AltitudePoints& points, + TopoDS_Shape& Out3dPres, + TopoDS_Shape& Out2dPres, + TopoDS_Shape& OutLeftB, + TopoDS_Shape& OutRightB, + TopoDS_Shape& OutInlet, + TopoDS_Shape& OutOutlet, + bool Create3dPres, + bool Create2dPres, + std::set& InvInd ); }; diff --git a/src/HYDROGUI/HYDROGUI_ListModel.cxx b/src/HYDROGUI/HYDROGUI_ListModel.cxx index b112dd34..254cb7c3 100644 --- a/src/HYDROGUI/HYDROGUI_ListModel.cxx +++ b/src/HYDROGUI/HYDROGUI_ListModel.cxx @@ -63,6 +63,24 @@ HYDROGUI_ListModel::~HYDROGUI_ListModel() { } +void HYDROGUI_ListModel::setBackgroundColor(int theInd, QColor theColor) +{ + myColoredRow[theInd] = theColor; +} + +void HYDROGUI_ListModel::clearAllBackgroundColors() +{ + myColoredRow.clear(); +} + +QColor HYDROGUI_ListModel::getBackgroundColor(int theInd) const +{ + if (myColoredRow.count( theInd )) + return myColoredRow[theInd]; + else + return QColor(); +} + /** */ QVariant HYDROGUI_ListModel::data( const QModelIndex &theIndex, int theRole ) const @@ -82,6 +100,16 @@ QVariant HYDROGUI_ListModel::data( const QModelIndex &theIndex, int theRole ) co return QVariant(); } break; + case Qt::BackgroundRole: + { + if( aColumn==0 && aRow >=0 && aRow < myObjects.count() && myColoredRow.contains(aRow)) + { + QBrush aBackgr(myColoredRow[aRow]); + return aBackgr; + } + else + return QVariant(); + } case Qt::DecorationRole: { diff --git a/src/HYDROGUI/HYDROGUI_ListModel.h b/src/HYDROGUI/HYDROGUI_ListModel.h index adc0e42c..8216175a 100644 --- a/src/HYDROGUI/HYDROGUI_ListModel.h +++ b/src/HYDROGUI/HYDROGUI_ListModel.h @@ -23,6 +23,8 @@ #include #include #include +#include +#include const int HYDROGUI_VisibleRole = Qt::UserRole + 1; const int HYDROGUI_EntryRole = Qt::UserRole + 2; @@ -75,6 +77,10 @@ public: void undoLastMove(); + void setBackgroundColor(int theInd, const QColor theColor); + QColor getBackgroundColor(int theInd) const; + void clearAllBackgroundColors (); + protected: bool isObjectVisible( int theIndex ) const; bool isDragAndDropAllowed( const QList& theItems, const int theDropItem ) const; @@ -84,6 +90,7 @@ private: Object2VisibleList myObjects, myPrevObjects; QPixmap myEmpty, myEye; + QMap myColoredRow; bool myIsDecorationEnabled; }; diff --git a/src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx b/src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx index c17903a3..a6ef3229 100644 --- a/src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx +++ b/src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx @@ -137,6 +137,31 @@ void HYDROGUI_OrderedListWidget::setObjects( const HYDROGUI_ListModel::Object2Vi } } +void HYDROGUI_OrderedListWidget::setBackgroundColor (int theInd, QColor theColor) +{ + HYDROGUI_ListModel* aModel = getSourceModel(); + if( aModel ) { + aModel->setBackgroundColor( theInd, theColor ); + } +} + +void HYDROGUI_OrderedListWidget::clearAllBackgroundColors () +{ + HYDROGUI_ListModel* aModel = getSourceModel(); + if( aModel ) { + aModel->clearAllBackgroundColors( ); + } +} + + + QColor HYDROGUI_OrderedListWidget::getBackgroundColor (int theInd) const + { + HYDROGUI_ListModel* aModel = getSourceModel(); + if( aModel ) { + return aModel->getBackgroundColor( theInd ); + } + } + /** Returns the ordered list of objects. @return the list of objects diff --git a/src/HYDROGUI/HYDROGUI_OrderedListWidget.h b/src/HYDROGUI/HYDROGUI_OrderedListWidget.h index d0ac1262..7b1feab7 100644 --- a/src/HYDROGUI/HYDROGUI_OrderedListWidget.h +++ b/src/HYDROGUI/HYDROGUI_OrderedListWidget.h @@ -58,6 +58,10 @@ public: QStringList getSelectedNames() const; QStringList getAllNames() const; + void setBackgroundColor (int theInd, QColor theColor); + QColor getBackgroundColor (int theInd) const; + void clearAllBackgroundColors (); + void undoLastMove(); signals: diff --git a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx index 9693fd7f..06707d5f 100644 --- a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx @@ -57,13 +57,13 @@ HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QStrin myAxes = new QComboBox( aParamGroup ); myAxes->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myDDZ = new QDoubleSpinBox( aParamGroup ); - myDDZ->setRange( 1E-2, 100 ); - myDDZ->setSingleStep( 1E-2 ); + myDDZ->setRange( 0.1, 100 ); + myDDZ->setSingleStep( 0.1 ); myDDZ->setValue( 0.1 ); myDDZ->setDecimals( 2 ); mySpatialStep = new QDoubleSpinBox( aParamGroup ); - mySpatialStep->setRange( 1E-2, 100 ); - mySpatialStep->setSingleStep( 1.0 ); + mySpatialStep->setRange( 0.1, 100 ); + mySpatialStep->setSingleStep( 0.1 ); mySpatialStep->setValue( 1 ); mySpatialStep->setDecimals( 2 ); @@ -247,3 +247,18 @@ double HYDROGUI_StreamDlg::getSpatialStep() const return mySpatialStep->value(); } +void HYDROGUI_StreamDlg::setBackgroundColorForProfileList (int theInd, QColor theColor) +{ + myProfiles->setBackgroundColor(theInd, theColor); +} + +QColor HYDROGUI_StreamDlg::getBackgroundColorForProfileList (int theInd) const +{ + return myProfiles->getBackgroundColor(theInd); +} + +void HYDROGUI_StreamDlg::clearAllBackgroundColorsForProfileList () +{ + myProfiles->clearAllBackgroundColors(); +} + diff --git a/src/HYDROGUI/HYDROGUI_StreamDlg.h b/src/HYDROGUI/HYDROGUI_StreamDlg.h index 11a6fd90..2e4e4626 100644 --- a/src/HYDROGUI/HYDROGUI_StreamDlg.h +++ b/src/HYDROGUI/HYDROGUI_StreamDlg.h @@ -56,6 +56,10 @@ public: void setSpatialStep( const double ); double getSpatialStep() const; + void setBackgroundColorForProfileList (int theInd, QColor theColor); + QColor getBackgroundColorForProfileList (int theInd) const; + void clearAllBackgroundColorsForProfileList (); + signals: void AddProfiles(); void RemoveProfiles( const QStringList& ); diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index 2a1b43c9..ffbc32b0 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -359,7 +360,9 @@ void HYDROGUI_StreamOp::createPreview() HYDROData_DTM::CreateProfilesFromDTM( aRefProfiles, ddz, ss, HYDROData_Bathymetry::AltitudePoints(), Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, true, true, InvInd); - //TODO!! aPanel->my---; + aPanel->clearAllBackgroundColorsForProfileList(); + for (std::set::const_iterator it = InvInd.begin(); it != InvInd.end(); it++) + aPanel->setBackgroundColorForProfileList(*it, QColor(Qt::yellow)); aPrsDef.myInlet = TopoDS::Wire(OutInlet); aPrsDef.myOutlet = TopoDS::Wire(OutOutlet); -- 2.39.2