当前位置: 首页>>代码示例>>C++>>正文


C++ TRegion类代码示例

本文整理汇总了C++中TRegion的典型用法代码示例。如果您正苦于以下问题:C++ TRegion类的具体用法?C++ TRegion怎么用?C++ TRegion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TRegion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkSegments

  //! Elimina i segmenti che non sono contenuti all'interno dello stroke!!!
  void checkSegments(std::vector<TAutocloser::Segment> &segments,
                     TStroke *stroke, const TRasterCM32P &ras,
                     const TPoint &delta) {
    TVectorImage vi;
    TStroke *app = new TStroke();
    *app         = *stroke;
    app->transform(TTranslation(convert(ras->getCenter())));
    vi.addStroke(app);
    vi.findRegions();
    std::vector<TAutocloser::Segment>::iterator it = segments.begin();
    for (; it < segments.end(); it++) {
      if (it == segments.end()) break;

      int i;
      bool isContained = false;
      for (i = 0; i < (int)vi.getRegionCount(); i++) {
        TRegion *reg = vi.getRegion(i);
        if (reg->contains(convert(it->first + delta)) &&
            reg->contains(convert(it->second + delta))) {
          isContained = true;
          break;
        }
      }
      if (!isContained) {
        it = segments.erase(it);
        if (it != segments.end() && it != segments.begin())
          it--;
        else if (it == segments.end())
          break;
      }
    }
  }
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:33,代码来源:rastertapetool.cpp

示例2: getRasterPoint

/*-- (StylePickerTool内で)LineとAreaを切り替えてPickできる。mode: 0=Area, 1=Line, 2=Line&Areas(default)  --*/
int StylePicker::pickStyleId(const TPointD &pos, double radius2, int mode) const
{
	int styleId = 0;
	if (TToonzImageP ti = m_image) {
		TRasterCM32P ras = ti->getRaster();
		TPoint point = getRasterPoint(pos);
		if (!ras->getBounds().contains(point))
			return -1;
		TPixelCM32 col = ras->pixels(point.y)[point.x];

		switch (mode) {
		case 0: //AREAS
			styleId = col.getPaint();
			break;
		case 1: //LINES
			styleId = col.getInk();
			break;
		case 2: //ALL (Line & Area)
		default:
			styleId = col.isPurePaint() ? col.getPaint() : col.getInk();
			break;
		}
	} else if (TRasterImageP ri = m_image) {
		const TPalette *palette = m_palette.getPointer();
		if (!palette)
			return -1;
		TRaster32P ras = ri->getRaster();
		if (!ras)
			return -1;
		TPoint point = getRasterPoint(pos);
		if (!ras->getBounds().contains(point))
			return -1;
		TPixel32 col = ras->pixels(point.y)[point.x];
		styleId = palette->getClosestStyle(col);
	} else if (TVectorImageP vi = m_image) {
		// prima cerca lo stile della regione piu' vicina
		TRegion *r = vi->getRegion(pos);
		if (r)
			styleId = r->getStyle();
		// poi cerca quello della stroke, ma se prima aveva trovato una regione, richiede che
		// il click sia proprio sopra la stroke, altrimenti cerca la stroke piu' vicina (max circa 10 pixel)
		const double maxDist2 = (styleId == 0) ? 100.0 * radius2 : 0;
		bool strokeFound;
		double dist2, w, thick;
		UINT index;
		//!funzionerebbe ancora meglio con un getNearestStroke che considera
		//la thickness, cioe' la min distance dalla outline e non dalla centerLine
		strokeFound = vi->getNearestStroke(pos, w, index, dist2);
		if (strokeFound) {
			TStroke *stroke = vi->getStroke(index);
			thick = stroke->getThickPoint(w).thick;
			if (dist2 - thick * thick < maxDist2) {
				assert(stroke);
				styleId = stroke->getStyle();
			}
		}
	}
	return styleId;
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:60,代码来源:stylepicker.cpp

示例3: Update

void RWindows::Update(const TRegion& aRgn,const TSize& aSize)
	{
	if(aRgn.CheckError())
		UpdateRect(TRect(aSize),aSize);
	else
		for(TInt count=0;count<aRgn.Count();count++)
			UpdateRect(aRgn[count],aSize);
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:8,代码来源:WINS.CPP

示例4: IsClipped

CHuiCanvasGc::TClipRectVisibility CHuiCanvasGc::IsClipped(const TRect& aRect, const TRegion& aClippingRegion) const
    {
    TClipRectVisibility isClipped = EFullyOutside;
    if (!aClippingRegion.Count())
        {
        return EFullyInside;
        }
    
    if (!aRect.IsEmpty() && aClippingRegion.Count())
        {    
#if 0            
        TBool test = EFalse;        
        if (test)
            {
            for (TInt i=0; i<aClippingRegion.Count(); i++)
                {
#ifdef _DEBUG
                RDebug::Print(_L("aClippingRegion Rect: %d %d %d %d"), 
                        aClippingRegion[i].iTl.iX, 
                        aClippingRegion[i].iTl.iY,
                        aClippingRegion[i].iBr.iX,
                        aClippingRegion[i].iBr.iY);
#endif
                }                            
            }
#endif        
        
        if (aClippingRegion.Intersects(aRect))
            {            
            iTempRegion.Clear();
            iTempRegion2.Clear();

            iTempRegion.AddRect(aRect);
            
            iTempRegion2.Intersection(aClippingRegion, iTempRegion);
            iTempRegion2.Tidy();
            
            // Assume it is only partially inside region -> Clipped
            isClipped = EPartialOverlap;
            
            if (iTempRegion2.Count() == 1)
                {
                if (iTempRegion2[0] == aRect)
                    {
                    // Fully inside region -> Not clipped
                    isClipped = EFullyInside;    
                    }                
                }
            
            }
        else
            {
            // No overlap -> aRect is completely outside region -> Clipped
            isClipped = EFullyOutside;    
            }                    
        }
    return isClipped;
    }
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:58,代码来源:huicanvasgc.cpp

示例5: CheckRectRegion

void TestRRegion::CheckRectRegion(const TRegion& region,const TRect& rect)
// Check the region matches the rectangle
	{
	const TRect* rlist;

	if (rect.IsEmpty())
		test(region.Count()==0);
	else
		{
		test(region.Count()==1);
		rlist=region.RectangleList();
		test(rlist[0]==rect);
		test(region[0]==rect);
		}
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:15,代码来源:t_regn.cpp

示例6: LogRegion

void CDataWrapperBase::LogRegion(const TDesC& aMessage, const TRegion& aRegion)
	{
	INFO_PRINTF2(KLogRegion, &aMessage);
	TInt	indCount = aRegion.Count();
	if ( indCount==0 )
		{
		INFO_PRINTF1(KLogEmpty);
		}
	else
		{
		const TRect*	rect=aRegion.RectangleList();
		for ( TInt index=0; index<indCount; ++index )
			{
			INFO_PRINTF6(KLogRegionsRect, index, rect[index].iTl.iX, rect[index].iTl.iY, rect[index].iBr.iX, rect[index].iBr.iY);
			}
		}
	}
开发者ID:fedor4ever,项目名称:default,代码行数:17,代码来源:DataWrapperBase.cpp

示例7: dsaRect

void CMMFTestVideoDecodeHwDevice::SetScreenClipRegion(const TRegion& aRegion)
	{
	TRect dsaRect(KTestDSARectA, KTestDSARectB, KTestDSARectC, KTestDSARectD);
	TRegionFix<1> dsaReg(dsaRect);

	__ASSERT_ALWAYS(dsaReg.BoundingRect() == aRegion.BoundingRect(), 
		DevVideoDecoderPanic(EDecoderPanicScreenClipRegion)); 
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:8,代码来源:decoder.cpp

示例8: GetRegionFromConfig

TBool CDataWrapperBase::GetRegionFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TRegion& aResult)
	{
	TBuf<KMaxTestExecuteCommandLength>	tempStore;
	TRect								rect;

	aResult.Clear();
	TBool	moreData=ETrue;
	for ( TInt index=0; moreData; )
		{
		tempStore.Format(KFormatFieldNumber, &aKeyName, ++index);
		moreData=GetRectFromConfig(aSectName, tempStore, rect);
		if ( moreData )
			{
			aResult.AddRect(rect);
			}
		}

	return aResult.Count()>0;
	}
开发者ID:fedor4ever,项目名称:default,代码行数:19,代码来源:DataWrapperBase.cpp

示例9: CalcRedrawRegion

void CWsSpriteBase::CalcRedrawRegion(const TRegion& aSourceRegion, TRegion& aTarget) const
	{
	aTarget.Copy(aSourceRegion);
	if (ClipSprite())
		{
		TPoint origin(0,0);
		if(iWin)
			origin = iWin->Origin();
		TRect rect(iBasePos + origin + iClipOffset, iClipSize);
		aTarget.ClipRect(rect);
		}
	aTarget.ClipRect(RootWindow()->Abs());

	// Only need to draw if the region being redrawn overlaps the sprite
	const TRect spriteRect(Pos(), iSize);
	STACK_REGION spriteRegion;
	spriteRegion.AddRect(spriteRect);
	aTarget.Intersect(spriteRegion);
	spriteRegion.Close();
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:20,代码来源:SPRITE.CPP

示例10: MarkDirtyAndSchedule

/** 
This function updates the window's dirty region and schedules a redraw if needed.
Only used when the screen is run in CHANGETRACKING mode. 
@param aRegion in window coordinates
*/
void CWsBackedUpWindow::MarkDirtyAndSchedule(const TRegion& aRegion)
	{
	WS_ASSERT_DEBUG(Screen()->ChangeTracking(),EWsPanicNoChangetracking);
	
	if(!aRegion.IsEmpty())
		{
		iWsWin->AddDirtyWindowRegion(aRegion);
		if (iWsWin->IsActive() && iWsWin->IsVisible())
			{
			Screen()->ScheduleWindow(iWsWin);
			}
		}
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:18,代码来源:backedupwindow.cpp

示例11: CalcFloatingSpriteRgn

void CWsSpriteManager::CalcFloatingSpriteRgn( TRegion& aResultRgn, const TRect& aDefaultRect )
	{
	aResultRgn.Clear();
	for (TInt i=0 ; i<iFloatingSprites.Count() && !aResultRgn.CheckError(); i++)
		{
		CWsSpriteBase* sprite = iFloatingSprites[i]; 
		if ( sprite->CanBeSeen() && ( sprite->IsActive() || sprite->IsActivated() ) )
			{
			aResultRgn.AddRect( sprite->Rect() );
			}
		}
	aResultRgn.Tidy();
	if ( aResultRgn.CheckError() && iFloatingSprites.Count() > 0 )
		{
		aResultRgn.Clear();
		aResultRgn.AddRect( aDefaultRect );
		}
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:18,代码来源:SPRITE.CPP

示例12: doDraw

void RWsTextCursor::doDraw(CFbsBitGc* aGc, const TRegion& aRegion)
	{
	TRegionFix<1> justInCase;
	const TRegion *pr= &aRegion;
	if (aRegion.CheckError())
		{
		justInCase.AddRect(iWin->AbsRect());
		pr= &justInCase;
		}
	if (!pr->IsEmpty())
		{
		aGc->SetUserDisplayMode(iWin->DisplayMode());
		aGc->SetDitherOrigin(iWin->Origin());
		aGc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
		switch (iType)
			{
			case TTextCursor::ETypeRectangle:
				{
				aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
				aGc->SetPenStyle(CGraphicsContext::ENullPen);
				aGc->SetBrushColor(iColor);
				}
				break;
			case TTextCursor::ETypeHollowRectangle:
				{
				aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
				aGc->SetPenStyle(CGraphicsContext::ESolidPen);
				aGc->SetPenColor(iColor);
				}
				break;
			default:
				WS_PANIC_ALWAYS(EWsPanicInvalidCursorType);
			}
		aGc->SetClippingRegion(pr);
		aGc->DrawRect(RectRelativeToScreen());
		aGc->SetUserDisplayMode(ENone);

		TWindowServerEvent::NotifyScreenDrawingEvent(pr);
		}
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:40,代码来源:TCURSOR.CPP

示例13: stroke_autofill_learn

void stroke_autofill_learn(const TVectorImageP &imgToLearn, TStroke *stroke) {
  if (!imgToLearn || !stroke || stroke->getControlPointCount() == 0) return;
  TVectorImage appImg;
  TStroke *appStroke = new TStroke(*stroke);
  appImg.addStroke(appStroke);
  appImg.findRegions();

  double pbx, pby;
  double totalArea = 0;
  pbx = pby = 0;

  if (!regionsReference.isEmpty()) regionsReference.clear();

  int i, j, index = 0;

  for (i = 0; i < (int)imgToLearn->getRegionCount(); i++) {
    TRegion *currentRegion = imgToLearn->getRegion(i);
    for (j = 0; j < (int)appImg.getRegionCount(); j++) {
      TRegion *region = appImg.getRegion(j);
      if (contains(region, currentRegion)) {
        scanRegion(currentRegion, index, regionsReference, region->getBBox());
        index++;
        int k, subRegionCount = currentRegion->getSubregionCount();
        for (k = 0; k < subRegionCount; k++) {
          TRegion *subRegion = currentRegion->getSubregion(k);
          if (contains(region, subRegion))
            scanSubRegion(subRegion, index, regionsReference,
                          region->getBBox());
        }
      }
    }
  }

  QMap<int, Region>::Iterator it;
  for (it = regionsReference.begin(); it != regionsReference.end(); it++) {
    pbx += it.value().m_barycentre.x;
    pby += it.value().m_barycentre.y;
    totalArea += it.value().m_area;
  }

  if (totalArea > 0)
    referenceB = TPointD(pbx / totalArea, pby / totalArea);
  else
    referenceB = TPointD(0.0, 0.0);
}
开发者ID:walkerka,项目名称:opentoonz,代码行数:45,代码来源:autofillpli.cpp

示例14: rect_autofill_learn

void rect_autofill_learn(const TVectorImageP &imgToLearn, const TRectD &rect)

{
  if (rect.getLx() * rect.getLy() < MIN_SIZE) return;

  double pbx, pby;
  double totalArea = 0;
  pbx = pby = 0;

  if (!regionsReference.isEmpty()) regionsReference.clear();

  int i, index = 0, regionCount = imgToLearn->getRegionCount();
  for (i = 0; i < regionCount; i++) {
    TRegion *region = imgToLearn->getRegion(i);
    if (rect.contains(region->getBBox())) {
      scanRegion(region, index, regionsReference, rect);
      index++;
    }
    int j, subRegionCount = region->getSubregionCount();
    for (j = 0; j < subRegionCount; j++) {
      TRegion *subRegion = region->getSubregion(j);
      if (rect.contains(subRegion->getBBox()))
        scanSubRegion(subRegion, index, regionsReference, rect);
    }
  }

  QMap<int, Region>::Iterator it;
  for (it = regionsReference.begin(); it != regionsReference.end(); it++) {
    pbx += it.value().m_barycentre.x;
    pby += it.value().m_barycentre.y;
    totalArea += it.value().m_area;
  }

  if (totalArea > 0)
    referenceB = TPointD(pbx / totalArea, pby / totalArea);
  else
    referenceB = TPointD(0.0, 0.0);
}
开发者ID:walkerka,项目名称:opentoonz,代码行数:38,代码来源:autofillpli.cpp

示例15: raster

//!Converts a TVectorImage into a TRasterImage. The input vector image
//!is transformed through the passed affine \b aff, and put into a
//!TRasterImage strictly covering the bounding box of the transformed
//!vector image. The output image has its lower-left position in the
//!world reference specified by the \b pos parameter, which is granted to
//!be an integer displacement of the passed value. Additional parameters
//!include an integer \b enlarge by which the output image is enlarged with
//!respect to the transformed image's bbox, and the bool \b transformThickness
//!to specify whether the transformation should involve strokes' thickensses
//!or not.
TRasterImageP TRasterImageUtils::vectorToFullColorImage(
	const TVectorImageP &vimage, const TAffine &aff, TPalette *palette,
	const TPointD &outputPos, const TDimension &outputSize,
	const std::vector<TRasterFxRenderDataP> *fxs, bool transformThickness)
{
	if (!vimage || !palette)
		return 0;

	//Transform the vector image through aff
	TVectorImageP vi = vimage->clone();
	vi->transform(aff, transformThickness);

	//Allocate the output ToonzImage
	TRaster32P raster(outputSize.lx, outputSize.ly);
	raster->clear();
	TRasterImageP ri(raster);
	ri->setPalette(palette->clone());

	//Shift outputPos to the origin
	vi->transform(TTranslation(-outputPos));

	int strokeCount = vi->getStrokeCount();
	std::vector<int> strokeIndex(strokeCount);
	std::vector<TStroke *> strokes(strokeCount);
	int i;
	for (i = 0; i < strokeCount; ++i) {
		strokeIndex[i] = i;
		strokes[i] = vi->getStroke(i);
	}
	vi->notifyChangedStrokes(strokeIndex, strokes);

	int maxStyleId = palette->getStyleCount() - 1;
	for (i = 0; i < (int)vi->getRegionCount(); ++i) {
		TRegion *region = vi->getRegion(i);
		fastAddPaintRegion(ri, region, tmin(maxStyleId, region->getStyle()), maxStyleId);
	}

	set<int> colors;
	if (fxs) {
		for (i = 0; i < (int)fxs->size(); i++) {
			SandorFxRenderData *sandorData = dynamic_cast<SandorFxRenderData *>((*fxs)[i].getPointer());
			if (sandorData && sandorData->m_type == BlendTz) {
				std::string indexes = toString(sandorData->m_blendParams.m_colorIndex);
				std::vector<std::string> items;
				parseIndexes(indexes, items);
				PaletteFilterFxRenderData paletteFilterData;
				insertIndexes(items, &paletteFilterData);
				colors = paletteFilterData.m_colors;
				break;
			}
		}
	}

	for (i = 0; i < strokeCount; ++i) {
		TStroke *stroke = vi->getStroke(i);

		bool visible = false;
		int styleId = stroke->getStyle();
		TColorStyleP style = palette->getStyle(styleId);
		assert(style);
		int colorCount = style->getColorParamCount();
		if (colorCount == 0)
			visible = true;
		else {
			visible = false;
			for (int j = 0; j < style->getColorParamCount() && !visible; j++) {
				TPixel32 color = style->getColorParamValue(j);
				if (color.m != 0)
					visible = true;
			}
		}
		if (visible)
			fastAddInkStroke(ri, stroke, TRectD(), 1, true);
	}
	return ri;
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:86,代码来源:trasterimageutils.cpp


注:本文中的TRegion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。