/// <summary> ///Get object color R/G/B /// </summary> void ObjectColor (int& theRed, int& theGreen, int& theBlue) { if (myAISContext().IsNull()) { return; } theRed = 255; theGreen = 255; theBlue = 255; myAISContext()->InitCurrent(); if (!myAISContext()->MoreCurrent()) { return; } Handle(AIS_InteractiveObject) aCurrent = myAISContext()->Current(); if (aCurrent->HasColor()) { Quantity_Color anObjCol = myAISContext()->Color (myAISContext()->Current()); theRed = int(anObjCol.Red() * 255.0); theGreen = int(anObjCol.Green() * 255.0); theBlue = int(anObjCol.Blue() * 255.0); } }
/// <summary> ///Set background color /// </summary> void BackgroundColor (int& theRed, int& theGreen, int& theBlue) { if (!myView().IsNull()) { Quantity_Color aColor = myView()->BackgroundColor(); theRed = (int )aColor.Red() * 255; theGreen = (int )aColor.Green() * 255; theBlue = (int )aColor.Blue() * 255; } }
int SMESHDS_GroupBase::GetColorGroup() const { Quantity_Color aColor = GetColor(); double aRed = aColor.Red(); double aGreen = aColor.Green(); double aBlue = aColor.Blue(); int aR = int( aRed *255 ); int aG = int( aGreen*255 ); int aB = int( aBlue *255 ); int aRet = (int)(aR*1000000 + aG*1000 + aB); return aRet; }
void DlgAttributes::OnColor() { Handle(AIS_InteractiveObject) Current ; Quantity_Color CSFColor ; COLORREF MSColor ; myAISContext->InitCurrent(); if (myAISContext->MoreCurrent()) { Current = myAISContext->Current() ; if ( Current->HasColor () ) { CSFColor = Current->Color () ; MSColor = RGB (CSFColor.Red()*255., CSFColor.Green()*255., CSFColor.Blue()*255.); } else { MSColor = RGB (255,255,255) ; } CColorDialog dlgColor(MSColor); if (dlgColor.DoModal() == IDOK) { MSColor = dlgColor.GetColor(); CSFColor = Quantity_Color (GetRValue(MSColor)/255., GetGValue(MSColor)/255., GetBValue(MSColor)/255.,Quantity_TOC_RGB); for (myAISContext->InitCurrent(); myAISContext->MoreCurrent (); myAISContext->NextCurrent ()) myAISContext->SetColor (myAISContext->Current(), CSFColor.Name()); } } TCollection_AsciiString Message ("\ \n\ for (myAISContext->InitCurrent(); myAISContext->MoreCurrent (); \n\ myAISContext->NextCurrent ()) \n\ myAISContext->SetColor (myAISContext->Current(), CSFColor.Name()); \n\ \n"); CString text(Message.ToCString()); (*myCResultDialog).SetTitle(CString("Setting Color")); (*myCResultDialog).SetText(text); }
//! Conversion of the Quantity_Color \p c to a QColor QColor toQtColor(const Quantity_Color& c) { return QColor(c.Red() * 255., c.Green() * 255., c.Blue() * 255.); }