return aResColor;
}
+bool HYDROData_Entity::GetColor( QColor& theOutColor,
+ const int theTag ) const
+{
+ TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
+
+ Handle(TDataStd_IntegerArray) aColorArray;
+ if ( aLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
+ {
+ theOutColor.setRed( aColorArray->Value( 1 ) );
+ theOutColor.setGreen( aColorArray->Value( 2 ) );
+ theOutColor.setBlue( aColorArray->Value( 3 ) );
+ theOutColor.setAlpha( aColorArray->Value( 4 ) );
+ return true;
+ }
+
+ return false;
+}
+
+
QStringList HYDROData_Entity::dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const
{
QStringList aResList;
* \param theDefColor default color to return if attribute has not been set before
*/
HYDRODATA_EXPORT QColor GetColor( const QColor& theDefColor, const int theTag = 0 ) const;
+
+ /* Internal method that used to retreive the color attribute
+ * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
+ * \param theOutColor color to return if attribute has been set before
+ * \return true if attribute is present
+ */
+ HYDRODATA_EXPORT bool GetColor( QColor& theOutColor,
+ const int theTag ) const;
protected:
#include <TDataStd_ExtStringList.hxx>
#include <TDataStd_IntegerList.hxx>
#include <TDataStd_RealList.hxx>
+#include <TDataStd_IntegerArray.hxx>
#include <TopoDS_Shape.hxx>
#include <QColor>
aSectLabel.ForgetAllAttributes();
}
}
+
+void HYDROData_IPolyline::getSectionColor( const int theSectionIndex,
+ QColor& theColor,
+ const bool theIsCreate ) const
+{
+ TDF_Label aLabel = myLab.FindChild( DataTag_SectionColors, theIsCreate );
+ if ( aLabel.IsNull() )
+ return;
+
+ TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, theIsCreate );
+ if ( aSectLabel.IsNull() )
+ return;
+
+ Handle(TDataStd_IntegerArray) aColorArray;
+ if (theIsCreate)
+ {
+ if ( !aSectLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
+ aColorArray = TDataStd_IntegerArray::Set( aSectLabel, 1, 4 );
+
+ aColorArray->SetValue( 1, theColor.red() );
+ aColorArray->SetValue( 2, theColor.green() );
+ aColorArray->SetValue( 3, theColor.blue() );
+ aColorArray->SetValue( 4, theColor.alpha() );
+ }
+ else
+ {
+ Handle(TDataStd_IntegerArray) aColorArray;
+ if ( aSectLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
+ {
+ theColor.setRed( aColorArray->Value( 1 ) );
+ theColor.setGreen( aColorArray->Value( 2 ) );
+ theColor.setBlue( aColorArray->Value( 3 ) );
+ theColor.setAlpha( aColorArray->Value( 4 ) );
+ }
+ }
+}
+
+void HYDROData_IPolyline::removeSectionColor( const int theSectionIndex ) const
+{
+ TDF_Label aLabel = myLab.FindChild( DataTag_SectionColors, false );
+ if ( aLabel.IsNull() )
+ return;
+
+ if ( theSectionIndex < 0 )
+ {
+ aLabel.ForgetAllAttributes();
+ }
+ else
+ {
+ TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false );
+ if ( !aSectLabel.IsNull() )
+ aSectLabel.ForgetAllAttributes();
+ }
+}
class TDataStd_ExtStringList;
class TDataStd_BooleanList;
class TDataStd_IntegerList;
+class Quantity_Color;
/**\class HYDROData_IPolyline
DataTag_Sections,
DataTag_PolylineShape,
DataTag_WireColor,
+ DataTag_SectionColors,
};
public:
HYDRODATA_EXPORT TopoDS_Shape GetShape() const;
HYDRODATA_EXPORT void SetShape( const TopoDS_Shape& theShape );
+ HYDRODATA_EXPORT void getSectionColor( const int theSectionIndex,
+ QColor& theColor,
+ const bool theIsCreate = true ) const;
+
+ HYDRODATA_EXPORT void removeSectionColor( const int theSectionIndex = -1 ) const;
+
protected:
void RemovePolylineShape();
void removePointsLists( const int theSectionIndex = -1 ) const;
+
+
protected:
/**
}
// Remove points that belongs to removed section
- removePointsLists( theSectionIndex );
+ removePointsLists( theSectionIndex ); //TODO remove colors
}
Changed( Geom_2d );
return aRes;
}
+void HYDROData_Profile::SetProfileColor( const QColor& theColor )
+{
+ SetColor( theColor, DataTag_ProfileColor );
+}
+
+bool HYDROData_Profile::GetProfileColor(QColor& outColor) const
+{
+ return GetColor( outColor, DataTag_ProfileColor );
+}
+
int HYDROData_Profile::ImportFromFile( const Handle(HYDROData_Document)& theDoc,
const TCollection_AsciiString& theFileName,
NCollection_Sequence<int>& theBadProfilesIds,
DataTag_FirstPoint, ///< first(left) point
DataTag_LastPoint, ///< last(right) point
DataTag_ChildProfileUZ, ///< child parametric profile
- DataTag_FilePath ///< profile imported file path
+ DataTag_FilePath, ///< profile imported file path
+ DataTag_ProfileColor ///< color of profile
};
public:
*/
HYDRODATA_EXPORT TCollection_AsciiString GetFilePath() const;
+
+ HYDRODATA_EXPORT void SetProfileColor( const QColor& theColor );
+
+ HYDRODATA_EXPORT bool GetProfileColor(QColor&) const;
+
+
/**
* Imports Profile data from file. The supported file types:
* - parametric presentation of profile (2 points in line U,Z)
#include <CurveCreator_Displayer.hxx>
#include <CurveCreator_Section.hxx>
#include <QVector>
+#include <TopoDS_Shape.hxx>
+#include <CurveCreator_Utils.hxx>
+#include <AIS_Shape.hxx>
+#include <Prs3d_PointAspect.hxx>
HYDROGUI_CurveCreatorProfile::HYDROGUI_CurveCreatorProfile()
: CurveCreator_Curve( CurveCreator::Dim2d )
aSection->myName = getUniqSectionName();
aSection->myType = CurveCreator::Polyline;
aSection->myIsClosed = false;
+ myCurveColor = Quantity_NOC_RED;
mySections.push_back( aSection );
mySkipSorting = true;
return points;
}
+/*
+void HYDROGUI_CurveCreatorProfile::constructAISObject()
+{
+ TopoDS_Shape aShape;
+ CurveCreator_Utils::constructShape( this, aShape );
+ myAISShape = new AIS_Shape( aShape );
+ myAISShape->SetColor( myCurveColor );
+ myAISShape->SetWidth( myLineWidth );
+ Handle(Prs3d_PointAspect) anAspect = myAISShape->Attributes()->PointAspect();
+ anAspect->SetScale( 3.0 );
+ anAspect->SetTypeOfMarker(Aspect_TOM_O_POINT);
+ anAspect->SetColor(myPointAspectColor);
+ myAISShape->Attributes()->SetPointAspect( anAspect );
+}*/
+
#define HYDROGUI_CurveCreator_Profile_HeaderFile
#include "CurveCreator_Curve.hxx"
+#include <Quantity_Color.hxx>
/**
* The CurveCreator_Curve object is represented as one or more sets of
virtual bool addPoints( const CurveCreator::Coordinates &theCoords,
const int theISection,
const int theIPnt = -1 );
-
/**
* Indicates whether the points can be sorted.
*/
void convert( const CurveCreator::PosPointsList& thePoints,
std::list<int>& theConvPoints );
+ //virtual void constructAISObject();
+
+ Quantity_Color myCurveColor;
+
};
#endif
#include <CurveCreator_Curve.hxx>
#include <CurveCreator_Displayer.hxx>
+#include <CurveCreator_Utils.hxx>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
aCurveCoords.push_back( aSectPoint.Y() );
}
+ Quantity_Color aColor = CurveCreator_Utils::getRandColor();
+ QColor aQColor = CurveCreator_Utils::colorConv(aColor);
+ myEditedObject->getSectionColor(i-1, aQColor, false);
+
myCurve->addSectionInternal( aSectName.toStdString(),
- aCurveType, aSectClosure, aCurveCoords );
+ aCurveType, aSectClosure, aCurveCoords, CurveCreator_Utils::colorConv(aQColor) );
}
}
else
for (int aSI = 0; aSI < aSCount; ++aSI)
{
myCurve->addSectionInternal((aNamePrefix + (aSI + 1)).ToCString(),
- CurveCreator::Spline, isCloseds[aSI], aPs[aSI]);
+ CurveCreator::Spline, isCloseds[aSI], aPs[aSI], CurveCreator_Utils::getRandColor());
}
}
}
aPolylineObj->AddSection( aSectName, aSectType, aSectClosure );
+ Quantity_Color aColor = myCurve->getColorSection(i);
+ aPolylineObj->getSectionColor(i, CurveCreator_Utils::colorConv(aColor), true);
+
// Add the points from section
CurveCreator::Coordinates aCurveCoords = myCurve->getCoords( i );
#include <CurveCreator_ICurve.hxx>
#include <CurveCreator_Utils.hxx>
#include <HYDROGUI_CurveCreatorProfile.h>
+#include <HYDROData_Tool.h>
#include <CurveCreator_Displayer.hxx>
#include <OCCViewer_ViewPort3d.h>
#include <QListWidget>
#include <QPushButton>
#include <SUIT_MessageBox.h>
+#include <QColorDialog>
const QString splitter_key = "HYDROGUI_ProfileDlg::splitter";
myProfileNames = new QListWidget(this);
myProfileNames->setSelectionMode(QAbstractItemView::SingleSelection);
name_layout->addWidget(myProfileNames);
+
+ QVBoxLayout* btn_layout = new QVBoxLayout( name_frame );
+ btn_layout->setAlignment(Qt::AlignTop);
+
myAddProfBtn = new QPushButton(tr("ADD_PROFILES"), this);
myRemProfBtn = new QPushButton(tr("REMOVE_PROFILE"), this);
- name_layout->addWidget(myAddProfBtn);
- name_layout->addWidget(myRemProfBtn);
+ mySetColorProfBtn = new QPushButton(tr("SETCOLOR_PROFILE"), this);
+ btn_layout->addWidget(myAddProfBtn);
+ btn_layout->addWidget(myRemProfBtn);
+ btn_layout->addWidget(mySetColorProfBtn);
+
+ name_layout->addLayout(btn_layout);
+
}
insertWidget( name_frame, 0, 0 );
int anActionFlags =
CurveCreator_Widget::DisableNewSection | CurveCreator_Widget::DisableDetectionMode |
- CurveCreator_Widget::DisableClosedSection;
+ CurveCreator_Widget::DisableClosedSection | CurveCreator_Widget::DisableSetColor;
QStringList aCoordTitles;
aCoordTitles << tr( "U_TITLE" ) << tr( "Z_TITLE" );
myEditorWidget = new CurveCreator_Widget( this, NULL, anActionFlags, aCoordTitles );
connect( myProfileNames, SIGNAL( itemChanged(QListWidgetItem*)), this, SLOT( onProfileNameChanged(QListWidgetItem*)));
connect( myAddProfBtn, SIGNAL( clicked(bool)), this, SLOT( onAddBtnPressed(bool)));
connect( myRemProfBtn, SIGNAL( clicked(bool)), this, SLOT( onRemoveBtnPressed(bool)));
+ connect( mySetColorProfBtn, SIGNAL( clicked(bool)), this, SLOT( onSetColorBtnPressed(bool)));
}
myAddElementBox->hide();
emit RemoveProfile(theIndex);
}
+void HYDROGUI_ProfileDlg::onSetColorBtnPressed(bool)
+{
+ int theIndex = GetProfileSelectionIndex();
+ if (theIndex < 0)
+ return;
+
+ HYDROGUI_CurveCreatorProfile* aCurve = (*myProfilesPointer)[theIndex];
+
+ QColor aCurrentColor = HYDROData_Tool::toQtColor(/*aCurve->myCurveColor*/aCurve->getColorSection(0));
+ QColor newQCurCol = QColorDialog::getColor( aCurrentColor, this );
+ if( !newQCurCol.isValid() )
+ return;
+
+ Quantity_Color newOCCCol = HYDROData_Tool::toOccColor(newQCurCol);
+ aCurve->setColorSectionInternal(0, newOCCCol);
+ //Handle(AIS_InteractiveObject) anAISObject = aCurve->getAISObject();
+ //if (anAISObject)
+ // anAISObject->SetColor(newOCCCol);
+
+ QListWidgetItem* item = myProfileNames->item(theIndex);
+ QPixmap SPixmap(16, 16);
+ SPixmap.fill(newQCurCol);
+ QIcon SIcon(SPixmap);
+ item->setIcon( SIcon );
+
+ if( myProfilesPointer &&
+ myProfilesPointer->size()>0 &&
+ myProfilesPointer->at(0) &&
+ myProfilesPointer->at(0)->getDisplayer() )
+ myProfilesPointer->at(0)->getDisplayer()->Update();
+}
+
void HYDROGUI_ProfileDlg::onProfileNameChanged(QListWidgetItem* item)
{
int ind = GetProfileSelectionIndex();
void onProfileIndexChanged();
void onAddBtnPressed(bool);
void onRemoveBtnPressed(bool);
+ void onSetColorBtnPressed(bool);
void onProfileNameChanged(QListWidgetItem* item);
signals:
QListWidget* myProfileNames;
QPushButton* myAddProfBtn;
QPushButton* myRemProfBtn;
+ QPushButton* mySetColorProfBtn;
public:
CurveCreator_Widget* myEditorWidget;
QGroupBox* myAddElementBox;
#include <CurveCreator_Displayer.hxx>
#include <HYDROData_Entity.h>
#include <QSet>
+#include <set>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
{
HYDROGUI_CurveCreatorProfile* CC = myProfiles[i];
const Handle(HYDROData_Profile)& CP = myCurveToProfile.Find(CC);
- const QColor& CurCol = PColors[i];
+ QColor CurCol = PColors[i];
+ CP->GetProfileColor(CurCol);
CurveToColor[CC] = CurCol;
const QString& profName = CP->GetName();
const QColor& PColor = CurCol;
for (int i = ExistingProfLen + 1; i <= NewLen; i++)
{
Handle(HYDROData_Profile) aCProfile = Handle(HYDROData_Profile)::DownCast(myEditedObjects(i));
+
QString aProfileName;
if( !aCProfile.IsNull() )
{
{
HYDROGUI_CurveCreatorProfile* CC = myProfiles[i];
const Handle(HYDROData_Profile)& CP = myCurveToProfile.Find(CC);
- const QColor& CurCol = PColors[i-ExistingProfLen];
+ QColor CurCol = PColors[i-ExistingProfLen];
+ CP->GetProfileColor(CurCol);
CurveToColor[CC] = CurCol;
const QString& profName = CP->GetName();
const QColor& PColor = CurCol;
SLOT( onRemoveProfile(int) ) );
return aDlg;
}
-#include <set>
+
+
bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags,
QString& theErrorMsg,
QStringList& theBrowseObjectsEntries )
{
Handle(HYDROData_Profile) HProf = Handle(HYDROData_Profile)::DownCast(myEditedObjects(i));
int stat = CurveCrProfileToHProfile(myProfiles[i-1], HProf, aProfileNamesFiltered[i-1], true);
+ HProf->SetProfileColor(HYDROData_Tool::toQtColor(myProfiles[i-1]->getColorSection(0)));
if (stat == 0)
continue;
else if (stat == -1)
{
Handle(HYDROData_Profile) aNewProfileObj = Handle(HYDROData_Profile)::DownCast( doc()->CreateObject( KIND_PROFILE ) );
int stat = CurveCrProfileToHProfile(myProfiles[0], aNewProfileObj, aProfileNamesFiltered[0], false);
+ aNewProfileObj->SetProfileColor(HYDROData_Tool::toQtColor(myProfiles[0]->getColorSection(0)));
if (stat == 0)
return false;
else if (stat == -1)
Quantity_Color CurOCCCol = HYDROData_Tool::toOccColor(QCurCol);
CC->setDisplayer( myDisplayer );
CC->myPointAspectColor = CurOCCCol;
- CC->myCurveColor = CurOCCCol;
+ CC->setColorSectionInternal(0, CurOCCCol);
CC->myLineWidth = 1;
myDisplayer->display( CC->getAISObject( true ), true );
}
<source>REMOVE_PROFILE</source>
<translation>Remove Profile</translation>
</message>
+ <message>
+ <source>SETCOLOR_PROFILE</source>
+ <translation>Set Color</translation>
+ </message>
<message>
<source>PROFILE_ALREADY_EXISTS</source>
<translation>Profile with this name is already exists</translation>