X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FCurveCreator%2FCurveCreator_TreeView.cxx;h=3453ba20387eeae7eaf3d148f87dc8d0d243074d;hb=c52059c3f88890a936705180edf2bd54e88e160b;hp=77010c3491878c85298dea868b376ab047df7550;hpb=9157430337e6e7291578bcfd877621f8623654c1;p=modules%2Fgeom.git diff --git a/src/CurveCreator/CurveCreator_TreeView.cxx b/src/CurveCreator/CurveCreator_TreeView.cxx index 77010c349..3453ba203 100644 --- a/src/CurveCreator/CurveCreator_TreeView.cxx +++ b/src/CurveCreator/CurveCreator_TreeView.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2019 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013-2023 CEA, EDF, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -19,6 +19,8 @@ #include "CurveCreator_TreeView.h" #include "CurveCreator_ICurve.hxx" +#include "CurveCreator_Curve.hxx" +#include "CurveCreator_Utils.hxx" #include #include @@ -28,8 +30,8 @@ #define ID_SECTION -1 -CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_ICurve* theCurve, QObject* parent ) : - QAbstractItemModel(parent), myCurve(theCurve) +CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_ICurve* theCurve, QObject* parent, bool toDrawColorIcon ) : + QAbstractItemModel(parent), myCurve(theCurve), myDrawColorIcon(toDrawColorIcon) { SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); QPixmap aSplineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE"))); @@ -65,8 +67,8 @@ CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_ICurve* the int CurveCreator_TreeViewModel::columnCount(const QModelIndex & parent ) const { - if( parent.internalId() == ID_SECTION ) - return 2; + if( myDrawColorIcon ) + return 3; else return 2; } @@ -76,7 +78,7 @@ QVariant CurveCreator_TreeViewModel::data(const QModelIndex & index, int role ) int aRow = index.row(); int aColumn = index.column(); if( myCurve ){ - if( index.internalId() == ID_SECTION ){ + if( index.internalId() == (quintptr)ID_SECTION ){ if( role == Qt::DisplayRole ){ if( aColumn == 0 ) return QString::fromStdString(myCurve->getSectionName(aRow)); @@ -104,6 +106,13 @@ QVariant CurveCreator_TreeViewModel::data(const QModelIndex & index, int role ) } } } + else if (myDrawColorIcon && aColumn == 2) + { + Quantity_Color color = ((CurveCreator_Curve*)myCurve)->getColorSection(aRow); + QPixmap pixmap(16,16); + pixmap.fill( CurveCreator_Utils::colorConv(color)); + return pixmap; + } } } /* else{ @@ -150,7 +159,7 @@ QModelIndex CurveCreator_TreeViewModel::parent(const QModelIndex & theIndex) con if( !theIndex.isValid() ) return QModelIndex(); - if( theIndex.internalId() == ID_SECTION ){ + if( theIndex.internalId() == (quintptr)ID_SECTION ){ return QModelIndex(); } return createIndex( theIndex.internalId(), 0, ID_SECTION ); @@ -165,7 +174,7 @@ int CurveCreator_TreeViewModel::rowCount(const QModelIndex & parent ) const aRowCnt = myCurve->getNbSections(); } else{ - if( parent.internalId() == ID_SECTION ){ + if( parent.internalId() == (quintptr)ID_SECTION ){ //Points level aRowCnt = myCurve->getNbPoints(parent.row()); } @@ -191,21 +200,21 @@ QModelIndex CurveCreator_TreeViewModel::pointIndex( int theSection, int thePoint bool CurveCreator_TreeViewModel::isSection( const QModelIndex& theIndx ) const { - if( theIndx.internalId() == ID_SECTION ) + if( theIndx.internalId() == (quintptr)ID_SECTION ) return true; return false; } int CurveCreator_TreeViewModel::getSection( const QModelIndex& theIndx ) const { - if( theIndx.internalId() == ID_SECTION ) + if( theIndx.internalId() == (quintptr)ID_SECTION ) return theIndx.row(); return theIndx.internalId(); } int CurveCreator_TreeViewModel::getPoint( const QModelIndex& theIndx ) const { - if( theIndx.internalId() == ID_SECTION ) + if( theIndx.internalId() == (quintptr)ID_SECTION ) return -1; return theIndx.row(); } @@ -218,14 +227,14 @@ void CurveCreator_TreeViewModel::setCurve( CurveCreator_ICurve* theCurve ) } /*****************************************************************************************/ -CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent) : +CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent, bool toDrawColorIcon) : QTreeView(parent) { header()->hide(); header()->setSectionResizeMode(QHeaderView::ResizeToContents); setUniformRowHeights(true); setContextMenuPolicy( Qt::CustomContextMenu ); - CurveCreator_TreeViewModel* aModel = new CurveCreator_TreeViewModel(theCurve, this); + CurveCreator_TreeViewModel* aModel = new CurveCreator_TreeViewModel(theCurve, this, toDrawColorIcon); setModel(aModel); setSelectionBehavior(SelectRows); setSelectionMode(SingleSelection); @@ -320,7 +329,7 @@ void CurveCreator_TreeView::sectionsRemoved( int theSection, int theSectionCnt ) } } -void CurveCreator_TreeView::setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent ) +void CurveCreator_TreeView::setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& /*isCurrent*/ ) // todo: isCurrent is not set! { setExpanded( theIndx, isExpanded ); QItemSelectionModel::SelectionFlags aFlag = QItemSelectionModel::Select;