/// <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;
}
  /// <summary>
  ///Set color
  /// </summary>
  void SetColor (int theR, int theG, int theB)
  {
    if (myAISContext().IsNull())
    {
      return;
    }

    Quantity_Color aCol (theR / 255.0, theG / 255.0, theB / 255.0, Quantity_TOC_RGB);
    for (; myAISContext()->MoreCurrent(); myAISContext()->NextCurrent())
    {
      myAISContext()->SetColor (myAISContext()->Current(), aCol.Name());
    }
  }
Beispiel #5
0
void OCC_2dView::OnChangeBackground() 
{
  Standard_Real R1, G1, B1;
  Handle(Aspect_Window) aWindow = myV2dView->Window();
  Aspect_Background ABack = aWindow->Background();
  Quantity_Color aColor = ABack.Color();
  aColor.Values(R1,G1,B1,Quantity_TOC_RGB);
  COLORREF m_clr ;
  m_clr = RGB(R1*255,G1*255,B1*255);

  CColorDialog dlgColor(m_clr);
  if (dlgColor.DoModal() == IDOK)
  {
    m_clr = dlgColor.GetColor();
    R1 = GetRValue(m_clr)/255.;
    G1 = GetGValue(m_clr)/255.;
    B1 = GetBValue(m_clr)/255.;
    aColor.SetValues(R1,G1,B1,Quantity_TOC_RGB);
    myV2dView->SetBackgroundColor(aColor);
    myV2dView->Update();
  }	
}
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);
}
void AspMainTest::TestIsoFaceForPartCalculation(MainFrame* frame, AspMainTool *tool){

	auto aView = frame->myViewer;

	Handle_AIS_InteractiveContext context = frame->myViewer->getIC();

	std::vector<Part *> selectedParts = tool->GetSelectedPart(context);

	if (selectedParts.size()<2)
		return;

	/*auto &PartMap = */selectedParts[0]->UnitMap;
	

	
	AssemblyGraphBuilder builder;
	//auto NewPart = Part(*(selectedParts[0]));
	//for (new)
	auto p1G = builder.GetPartGraphsSet(selectedParts[0],false);
	auto p2G = builder.GetPartGraphsSet(selectedParts[1], false);
	
	std::vector<PartIsomorphism> res;
	bool result;
	bool isReversed = false;
	if (p1G.first.vertex_set().size() > p2G.first.vertex_set().size() ||
		p1G.second.vertex_set().size() > p2G.second.vertex_set().size())
	{
		result = builder.IsomorphismOfPartCompare(p2G, p1G, &res);
		isReversed= true;
	}
	else{
		result = builder.IsomorphismOfPartCompare(p1G, p2G, &res);
	}
	context->ClearSelected(false);
	
	if(!result)
		return;

	context->EraseAll();
	context->OpenLocalContext(true, true);
	if (!isReversed){
		res[0].isoPart.first = selectedParts[0]->GetUri();
		res[0].isoPart.second = selectedParts[1]->GetUri();
	}
	else{
		res[0].isoPart.first = selectedParts[1]->GetUri();
		res[0].isoPart.second = selectedParts[0]->GetUri();
	}

	_int cColor=0;
	for (auto &iso : res){
	auto partIter=	std::find_if(selectedParts.begin(), selectedParts.end(),[&iso](Part* p)->bool{return iso.isoPart.first==p->GetUri();});
	auto coPartIter = std::find_if(selectedParts.begin(), selectedParts.end(), [&iso](Part* p)->bool{return iso.isoPart.second == p->GetUri(); });
	auto end = selectedParts.end();

	if (partIter == end && coPartIter == end)
		continue;

	auto FaceSetEnd = iso.isoFaceSet.end();
		for (auto &surfP1: *(*partIter)){
			auto surfP1Uri = surfP1.uri;

			auto isoFacesPair = find_if(iso.isoFaceSet.begin(), FaceSetEnd, [&surfP1Uri](std::pair<FaceUri, FaceUri> &f)-> bool { return f.first == surfP1Uri; });

			if (isoFacesPair == FaceSetEnd)
				continue;

			auto surfP2Uri = isoFacesPair->second;

			auto &coPartSurfCol = (*coPartIter)->colOfSurf;

			auto surfP2 = find_if(coPartSurfCol.begin(), coPartSurfCol.end(), [&surfP2Uri](const SurfaceAttribute &att)->bool{return att.uri==surfP2Uri;});

			if (surfP2 == coPartSurfCol.end())
					continue;

			Handle_AIS_Shape S1 = new AIS_Shape(surfP1.surf.Face());
			Handle_AIS_Shape S2 = new AIS_Shape(surfP2->surf.Face());

			Quantity_Color shapeColor = Color::name(++cColor);

			_int DisplayMode= AIS_Shaded;
			
		
		
		context->LocalContext()->Display(S1, DisplayMode);
		context->LocalContext()->Display(S2, DisplayMode);

		context->SetColor(S1, shapeColor.Name(), false);
		context->SetColor(S2, shapeColor.Name(), false);

		
		}
	}

	aView->Update();

}
Beispiel #8
0
//! 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.);
}