本文整理汇总了C++中region函数的典型用法代码示例。如果您正苦于以下问题:C++ region函数的具体用法?C++ region怎么用?C++ region使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了region函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: region
/**
* \brief Draws this surface on another surface.
* \param dst_surface The destination surface.
* \param dst_position Coordinates on the destination surface.
*/
void Surface::raw_draw(Surface& dst_surface, const Point& dst_position) {
Rectangle region(0, 0, width, height);
raw_draw_region(region, dst_surface, dst_position);
}
示例2: ui_color
void
KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
BRect rect, bool pressed)
{
rgb_color base = key->dark ? kDarkColor : kBrightColor;
rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
key_kind keyKind = kNormalKey;
int32 deadKey = 0;
bool secondDeadKey = false;
bool isDeadKeyEnabled = true;
char text[32];
if (fKeymap != NULL) {
_GetKeyLabel(key, text, sizeof(text), keyKind);
deadKey = fKeymap->DeadKey(key->code, fModifiers, &isDeadKeyEnabled);
secondDeadKey = fKeymap->IsDeadSecondKey(key->code, fModifiers,
fDeadKey);
} else {
// Show the key code if there is no keymap
snprintf(text, sizeof(text), "%02" B_PRIx32, key->code);
}
_SetFontSize(view, keyKind);
if (secondDeadKey)
base = kSecondDeadKeyColor;
else if (deadKey > 0 && isDeadKeyEnabled)
base = kDeadKeyColor;
if (key->shape == kRectangleKeyShape) {
_DrawKeyButton(view, rect, updateRect, base, background, pressed);
rect.InsetBy(1, 1);
_GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, sizeof(text));
be_control_look->DrawLabel(view, text, rect, updateRect,
base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
} else if (key->shape == kEnterKeyShape) {
BRect topLeft = rect;
BRect topRight = rect;
BRect bottomLeft = rect;
BRect bottomRight = rect;
// TODO: for some reason, this does not always equal the bottom of
// the other keys...
bottomLeft.top = floorf(rect.top
+ fLayout->DefaultKeySize().height * fFactor - fGap - 1);
bottomLeft.right = floorf(rect.left
+ (key->frame.Width() - key->second_row) * fFactor - fGap - 2);
topLeft.bottom = bottomLeft.top;
topLeft.right = bottomLeft.right + 1;
// add one to make the borders meet
topRight.bottom = topLeft.bottom;
topRight.left = topLeft.right;
bottomRight.top = bottomLeft.top;
bottomRight.left = bottomLeft.right;
// draw top left corner
be_control_look->DrawButtonFrame(view, topLeft, updateRect,
4.0f, 0.0f, 4.0f, 0.0f, base, background,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_LEFT_BORDER | BControlLook::B_TOP_BORDER
| BControlLook::B_BOTTOM_BORDER);
be_control_look->DrawButtonBackground(view, topLeft, updateRect,
4.0f, 0.0f, 4.0f, 0.0f, base,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_LEFT_BORDER | BControlLook::B_TOP_BORDER
| BControlLook::B_BOTTOM_BORDER);
// draw top right corner
be_control_look->DrawButtonFrame(view, topRight, updateRect,
0.0f, 4.0f, 0.0f, 0.0f, base, background,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_TOP_BORDER | BControlLook::B_RIGHT_BORDER);
be_control_look->DrawButtonBackground(view, topRight, updateRect,
0.0f, 4.0f, 0.0f, 0.0f, base,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_TOP_BORDER | BControlLook::B_RIGHT_BORDER);
// draw bottom right corner
be_control_look->DrawButtonFrame(view, bottomRight, updateRect,
0.0f, 0.0f, 4.0f, 4.0f, base, background,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER
| BControlLook::B_BOTTOM_BORDER);
be_control_look->DrawButtonBackground(view, bottomRight, updateRect,
0.0f, 0.0f, 4.0f, 4.0f, base,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER
| BControlLook::B_BOTTOM_BORDER);
// clip out the bottom left corner
bottomLeft.right += 1;
bottomLeft.top -= 2;
BRegion region(rect);
region.Exclude(bottomLeft);
view->ConstrainClippingRegion(®ion);
//.........这里部分代码省略.........
示例3: cleanRegion
// Print a RegionGraphNode
void RegionGraphNode::_print(std::ostream& os, const GraphGC& gc) const
{
cleanRegion(os, gc, region(gc));
}
示例4: region
QRegion ImageUI::region() const
{
QRect region( preview.rect() );
region.translate( preview_position.x(), preview_position.y() );
return region;
}
示例5: NS_ASSERTION
void
ContentHostBase::Composite(EffectChain& aEffectChain,
float aOpacity,
const gfx::Matrix4x4& aTransform,
const Filter& aFilter,
const Rect& aClipRect,
const nsIntRegion* aVisibleRegion,
TiledLayerProperties* aLayerProperties)
{
NS_ASSERTION(aVisibleRegion, "Requires a visible region");
AutoLockTextureHost lock(mTextureHost);
AutoLockTextureHost lockOnWhite(mTextureHostOnWhite);
if (!mTextureHost ||
!lock.IsValid() ||
!lockOnWhite.IsValid()) {
return;
}
RefPtr<NewTextureSource> source = mTextureHost->GetTextureSources();
RefPtr<NewTextureSource> sourceOnWhite = mTextureHostOnWhite
? mTextureHostOnWhite->GetTextureSources()
: nullptr;
if (!source) {
return;
}
RefPtr<TexturedEffect> effect =
CreateTexturedEffect(source, sourceOnWhite, aFilter);
aEffectChain.mPrimaryEffect = effect;
nsIntRegion tmpRegion;
const nsIntRegion* renderRegion;
if (PaintWillResample()) {
// If we're resampling, then the texture image will contain exactly the
// entire visible region's bounds, and we should draw it all in one quad
// to avoid unexpected aliasing.
tmpRegion = aVisibleRegion->GetBounds();
renderRegion = &tmpRegion;
} else {
renderRegion = aVisibleRegion;
}
nsIntRegion region(*renderRegion);
nsIntPoint origin = GetOriginOffset();
// translate into TexImage space, buffer origin might not be at texture (0,0)
region.MoveBy(-origin);
// Figure out the intersecting draw region
gfx::IntSize texSize = source->GetSize();
nsIntRect textureRect = nsIntRect(0, 0, texSize.width, texSize.height);
textureRect.MoveBy(region.GetBounds().TopLeft());
nsIntRegion subregion;
subregion.And(region, textureRect);
if (subregion.IsEmpty()) {
// Region is empty, nothing to draw
return;
}
nsIntRegion screenRects;
nsIntRegion regionRects;
// Collect texture/screen coordinates for drawing
nsIntRegionRectIterator iter(subregion);
while (const nsIntRect* iterRect = iter.Next()) {
nsIntRect regionRect = *iterRect;
nsIntRect screenRect = regionRect;
screenRect.MoveBy(origin);
screenRects.Or(screenRects, screenRect);
regionRects.Or(regionRects, regionRect);
}
TileIterator* tileIter = source->AsTileIterator();
TileIterator* iterOnWhite = nullptr;
if (tileIter) {
tileIter->BeginTileIteration();
}
if (mTextureHostOnWhite) {
iterOnWhite = sourceOnWhite->AsTileIterator();
MOZ_ASSERT(!tileIter || tileIter->GetTileCount() == iterOnWhite->GetTileCount(),
"Tile count mismatch on component alpha texture");
if (iterOnWhite) {
iterOnWhite->BeginTileIteration();
}
}
bool usingTiles = (tileIter && tileIter->GetTileCount() > 1);
do {
if (iterOnWhite) {
MOZ_ASSERT(iterOnWhite->GetTileRect() == tileIter->GetTileRect(),
"component alpha textures should be the same size.");
}
nsIntRect texRect = tileIter ? tileIter->GetTileRect()
: nsIntRect(0, 0,
texSize.width,
texSize.height);
//.........这里部分代码省略.........
示例6: TEST_F
TEST_F(TestRegionNoArgs,BasicRegion_ShallowHistory_Resume2)
{
typedef TestConcurrentCompositeStateNoArgsMock
< TestStateMachineNoEventArgsMock
> ConcurrentCompositeStateMockType;
typedef TestRegionNoArgsMock
< ConcurrentCompositeStateMockType
, sttcl::CompositeStateHistoryType::Shallow
> RegionMockType;
typedef TestRegionInnerStateNoArgsMock<ConcurrentCompositeStateMockType,RegionMockType> RegionInnerStateMockType;
::testing::NiceMock<TestStateMachineNoEventArgsMock> stateMachine("stateMachine");
::testing::NiceMock
< ConcurrentCompositeStateMockType
> compositeState(&stateMachine);
::testing::NiceMock
< RegionMockType
> region(&compositeState,"region");
::testing::NiceMock
< RegionInnerStateMockType
> innerState1("innerState1");
::testing::NiceMock
< RegionInnerStateMockType
> innerState2("innerState1");
::testing::NiceMock
< TestSimpleStateNoArgsMock<TestStateMachineNoEventArgsMock>
> outerState("outerState");
stateMachine.autoFinalize(false);
compositeState.setRegion(0,®ion);
region.initialState(&innerState1);
stateMachine.initialState(&compositeState);
// Setup mock call expectations
//----------------------------------------------------------------------------
EXPECT_CALL(compositeState,handleEvent1(&stateMachine))
.Times(1);
EXPECT_CALL(compositeState,handleEvent2(&stateMachine))
.Times(1)
.WillOnce( TRIGGER_STATE_CHANGE(ConcurrentCompositeStateMockType, handleEvent2, &compositeState, &outerState) );
EXPECT_CALL(compositeState,endDoImpl(&stateMachine))
.Times(2);
EXPECT_CALL(compositeState,exitImpl(&stateMachine))
.Times(2);
// Check region calls
EXPECT_CALL(region,enterRegionImpl(&compositeState))
.Times(2);
EXPECT_CALL(region,startingRegionThread())
.Times(2);
EXPECT_CALL(region,initializeImpl(_))
.Times(2);
// TODO: Eliminiate (superflous?) calls to finalize(Impl)
EXPECT_CALL(region,finalizeImpl(_))
.Times(3);
EXPECT_CALL(region,endingRegionThread())
.Times(2);
EXPECT_CALL(region,exitRegionImpl(&compositeState))
.Times(2);
EXPECT_CALL(outerState,entryImpl(&stateMachine))
.Times(1);
EXPECT_CALL(outerState,startDoImpl(&stateMachine))
.Times(1);
EXPECT_CALL(outerState,handleEvent3(&stateMachine))
.Times(1)
.WillOnce( TRIGGER_STATE_CHANGE(TestSimpleStateNoArgsMock<TestStateMachineNoEventArgsMock>, handleEvent3, &outerState, &compositeState) );
EXPECT_CALL(outerState,endDoImpl(&stateMachine))
.Times(1);
EXPECT_CALL(outerState,exitImpl(&stateMachine))
.Times(1);
EXPECT_CALL(innerState1,entryImpl(®ion))
.Times(1);
EXPECT_CALL(innerState1,startDoImpl(®ion))
.Times(1);
// TODO: Eliminiate (superflous?) calls to initSubStateMachinesImpl
EXPECT_CALL(innerState1,initSubStateMachinesImpl(true))
.Times(2);
// EXPECT_CALL(innerState1,initSubStateMachinesImpl(true))
// .Times(1);
EXPECT_CALL(innerState1,handleEvent1(&compositeState,®ion))
.Times(1)
.WillOnce( TRIGGER_STATE_CHANGE2(RegionInnerStateMockType, handleEvent1, &innerState1, &innerState2) );
EXPECT_CALL(innerState1,endDoImpl(®ion))
.Times(1);
EXPECT_CALL(innerState1,exitImpl(®ion))
.Times(1);
EXPECT_CALL(innerState2,entryImpl(®ion))
.Times(1);
EXPECT_CALL(innerState2,startDoImpl(®ion))
.Times(1);
// EXPECT_CALL(innerState2,initSubStateMachinesImpl(true))
// .Times(1);
EXPECT_CALL(innerState2,endDoImpl(®ion))
.Times(2);
EXPECT_CALL(innerState2,exitImpl(®ion))
.Times(2);
//.........这里部分代码省略.........
示例7: titleBarHeight
bool QDecorationStyled::paint(QPainter *painter, const QWidget *widget, int decorationRegion,
DecorationState state)
{
if (decorationRegion == None)
return false;
bool isActive = (widget == qApp->activeWindow());
QPalette pal = qApp->palette();
//ideally, the difference between Active and Inactive should be enough, so we shouldn't need to test this
if (!isActive) {
//pal.setCurrentColorGroup(QPalette::Disabled); //Can't do this either, because of palette limitations
//copied from Q3TitleBar:
pal.setColor(QPalette::Inactive, QPalette::Highlight,
pal.color(QPalette::Inactive, QPalette::Dark));
pal.setColor(QPalette::Inactive, QPalette::Base,
pal.color(QPalette::Inactive, QPalette::Dark));
pal.setColor(QPalette::Inactive, QPalette::HighlightedText,
pal.color(QPalette::Inactive, QPalette::Window));
}
Qt::WindowFlags flags = widget->windowFlags();
bool hasBorder = !widget->isMaximized();
bool hasTitle = flags & Qt::WindowTitleHint;
bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
bool paintAll = (DecorationRegion(decorationRegion) == All);
bool handled = false;
QStyle *style = QApplication::style();
// In the case of a borderless title bar, the title bar must be expanded one
// borderWidth to the left, right and up.
bool noTitleBorder = style->styleHint(QStyle::SH_TitleBar_NoBorder, 0, widget);
int borderWidth = style->pixelMetric(QStyle::PM_MDIFrameWidth, 0, 0);
int titleHeight = titleBarHeight(widget) + (noTitleBorder ? borderWidth : 0);
int titleExtra = noTitleBorder ? borderWidth : 0;
if ((paintAll || decorationRegion & Borders) && state == Normal && hasBorder) {
QRegion newClip = painter->clipRegion();
if (hasTitle) { // reduce flicker
QRect rect(widget->rect());
QRect r(rect.left() - titleExtra, rect.top() - titleHeight,
rect.width() + 2 * titleExtra, titleHeight);
newClip -= r;
}
if (!newClip.isEmpty()) {
QRect br = QDecoration::region(widget).boundingRect();
painter->save();
painter->setClipRegion(newClip);
QStyleOptionFrame opt;
opt.palette = pal;
opt.rect = br;
opt.lineWidth = borderWidth;
if (isActive)
opt.state |= QStyle::State_Active;
bool porterDuff = painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff);
if (porterDuff)
painter->setCompositionMode(QPainter::CompositionMode_Source);
painter->fillRect(br, pal.window());
if (porterDuff)
painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
style->drawPrimitive(QStyle::PE_FrameWindow, &opt, painter, 0);
painter->restore();
decorationRegion &= (~Borders);
handled |= true;
}
}
if (hasTitle) {
painter->save();
QStyleOptionTitleBar opt;
opt.subControls = (decorationRegion & Title
? QStyle::SC_TitleBarLabel : QStyle::SubControl(0))
| (decorationRegion & Menu
? QStyle::SC_TitleBarSysMenu : QStyle::SubControl(0))
| (decorationRegion & Help
? QStyle::SC_TitleBarContextHelpButton : QStyle::SubControl(0))
| (decorationRegion & Minimize
? QStyle::SC_TitleBarMinButton : QStyle::SubControl(0))
| (decorationRegion & Maximize
? QStyle::SC_TitleBarMaxButton : QStyle::SubControl(0))
| (decorationRegion & (Minimize | Maximize)
? QStyle::SC_TitleBarNormalButton : QStyle::SubControl(0))
| (decorationRegion & Close
? QStyle::SC_TitleBarCloseButton : QStyle::SubControl(0));
opt.titleBarFlags = widget->windowFlags();
opt.titleBarState = widget->windowState();
if (isActive)
opt.titleBarState |= QStyle::State_Active;
opt.text = windowTitleFor(widget);
opt.icon = widget->windowIcon();
opt.palette = pal;
opt.rect = QRect(widget->rect().x() - titleExtra, -titleHeight,
//.........这里部分代码省略.........
示例8: TestComputeMaskedImage1DHistogram
void TestComputeMaskedImage1DHistogram()
{
// // Single channel
// {
// typedef itk::Image<unsigned char, 2> ImageType;
// ImageType::Pointer image = ImageType::New();
// ImageType::IndexType corner = {{0,0}};
// ImageType::SizeType size = {{100,100}};
// ImageType::RegionType region(corner, size);
// image->SetRegions(region);
// image->Allocate();
// itk::ImageRegionIterator<ImageType> imageIterator(image,region);
// while(!imageIterator.IsAtEnd())
// {
// if(imageIterator.GetIndex()[0] < 70)
// {
// imageIterator.Set(255);
// }
// else
// {
// imageIterator.Set(0);
// }
// ++imageIterator;
// }
// ImageType::PixelType rangeMin = 0;
// ImageType::PixelType rangeMax = 255;
// unsigned int numberOfBins = 10;
// typedef int BinValueType;
// typedef Histogram<BinValueType>::HistogramType HistogramType;
// HistogramType histogram = Histogram<BinValueType>::ComputeImageHistogram1D(image.GetPointer(),
// image->GetLargestPossibleRegion(),
// numberOfBins, rangeMin, rangeMax);
// Histogram<BinValueType>::OutputHistogram(histogram);
// std::cout << std::endl;
// }
// Multi channel VectorImage
{
typedef itk::VectorImage<unsigned char, 2> ImageType;
ImageType::Pointer image = ImageType::New();
ImageType::IndexType corner = {{0,0}};
ImageType::SizeType size = {{100,100}};
ImageType::RegionType region(corner, size);
image->SetRegions(region);
image->SetNumberOfComponentsPerPixel(3);
image->Allocate();
Mask::Pointer mask = Mask::New();
mask->SetRegions(region);
mask->Allocate();
itk::ImageRegionIterator<ImageType> imageIterator(image,region);
while(!imageIterator.IsAtEnd())
{
ImageType::PixelType pixel(image->GetNumberOfComponentsPerPixel());
if(imageIterator.GetIndex()[0] < 70)
{
for(unsigned int i = 0; i < pixel.GetSize(); ++i)
{
pixel[i] = 255;
}
}
else
{
for(unsigned int i = 0; i < pixel.GetSize(); ++i)
{
pixel[i] = 0;
}
}
imageIterator.Set(pixel);
++imageIterator;
}
// TypeTraits<ImageType::PixelType>::ComponentType rangeMin = 0;
// TypeTraits<ImageType::PixelType>::ComponentType rangeMax = 255;
ImageType::PixelType rangeMins;
rangeMins.SetSize(image->GetNumberOfComponentsPerPixel());
rangeMins.Fill(0);
ImageType::PixelType rangeMaxs;
rangeMaxs.SetSize(image->GetNumberOfComponentsPerPixel());
rangeMaxs.Fill(255);
unsigned int numberOfBinsPerComponent = 10;
typedef int BinValueType;
//.........这里部分代码省略.........
示例9: switch
void pla_device::parse_fusemap()
{
jed_data jed;
int result = JEDERR_NONE;
// read pla file
switch (m_format)
{
case PLA_FMT_JEDBIN:
result = jedbin_parse(region()->base(), region()->bytes(), &jed);
break;
case PLA_FMT_BERKELEY:
result = pla_parse(region()->base(), region()->bytes(), &jed);
break;
}
if (result != JEDERR_NONE)
{
for (int p = 0; p < m_terms; p++)
{
m_term[p].and_mask = 0;
m_term[p].or_mask = 0;
}
logerror("%s PLA parse error %d!\n", tag(), result);
return;
}
// parse it
UINT32 fusenum = 0;
for (int p = 0; p < m_terms; p++)
{
term *term = &m_term[p];
// AND mask
term->and_mask = 0;
for (int i = 0; i < m_inputs; i++)
{
// complement
term->and_mask |= (UINT64)jed_get_fuse(&jed, fusenum++) << (i + 32);
// true
term->and_mask |= (UINT64)jed_get_fuse(&jed, fusenum++) << i;
}
// OR mask
term->or_mask = 0;
for (int f = 0; f < m_outputs; f++)
{
term->or_mask |= !jed_get_fuse(&jed, fusenum++) << f;
}
term->or_mask <<= 32;
}
// XOR mask
m_xor = 0;
for (int f = 0; f < m_outputs; f++)
{
m_xor |= jed_get_fuse(&jed, fusenum++) << f;
}
m_xor <<= 32;
}
示例10: region
/*
* Propagation proper
*
*/
ExecStatus
Pack::propagate(Space& home, const ModEventDelta& med) {
// Number of items
int n = bs.size();
// Number of bins
int m = l.size();
{
Region region(home);
// Possible sizes for bins
int* s = region.alloc<int>(m);
for (int j=m; j--; )
s[j] = 0;
// Compute sizes for bins
if (OffsetView::me(med) == ME_INT_VAL) {
// Also eliminate assigned items
int k=0;
for (int i=0; i<n; i++)
if (bs[i].assigned()) {
int j = bs[i].bin().val();
l[j].offset(l[j].offset() - bs[i].size());
t -= bs[i].size();
} else {
for (ViewValues<IntView> j(bs[i].bin()); j(); ++j)
s[j.val()] += bs[i].size();
bs[k++] = bs[i];
}
n=k; bs.size(n);
} else {
for (int i=n; i--; ) {
assert(!bs[i].assigned());
for (ViewValues<IntView> j(bs[i].bin()); j(); ++j)
s[j.val()] += bs[i].size();
}
}
// Propagate bin loads and compute lower and upper bound
int min = t, max = t;
for (int j=m; j--; ) {
GECODE_ME_CHECK(l[j].gq(home,0));
GECODE_ME_CHECK(l[j].lq(home,s[j]));
min -= l[j].max(); max -= l[j].min();
}
// Propagate that load must be equal to total size
for (bool mod = true; mod; ) {
mod = false; ModEvent me;
for (int j=m; j--; ) {
int lj_min = l[j].min();
me = l[j].gq(home, min + l[j].max());
if (me_failed(me))
return ES_FAILED;
if (me_modified(me)) {
max += lj_min - l[j].min(); mod = true;
}
int lj_max = l[j].max();
me = l[j].lq(home, max + l[j].min());
if (me_failed(me))
return ES_FAILED;
if (me_modified(me)) {
min += lj_max - l[j].max(); mod = true;
}
}
}
if (n == 0) {
assert(l.assigned());
return home.ES_SUBSUMED(*this);
}
{
TellCache tc(region,m);
int k=0;
for (int i=0; i<n; i++) {
for (ViewValues<IntView> j(bs[i].bin()); j(); ++j) {
if (bs[i].size() > l[j.val()].max())
tc.nq(j.val());
if (s[j.val()] - bs[i].size() < l[j.val()].min())
tc.eq(j.val());
}
GECODE_ES_CHECK(tc.tell(home,bs[i].bin()));
// Eliminate assigned bin
if (bs[i].assigned()) {
int j = bs[i].bin().val();
l[j].offset(l[j].offset() - bs[i].size());
t -= bs[i].size();
} else {
bs[k++] = bs[i];
}
}
n=k; bs.size(n);
//.........这里部分代码省略.........
示例11: country
bool PhysicalLocation::operator==(const PhysicalLocation& o) const
{
return country() == o.country() && region() == o.region() && locality() == o.locality() && area() == o.area() && street() == o.street() && building() == o.building() && floor() == o.floor() && room() == o.room() && postalcode() == o.postalcode() && text() == o.text();
}
示例12: TEST_F
TEST_F(LuaMobileTest, LuaSpawnManagerTest) {
Vector<String> zoneNames;
zoneNames.add("corellia");
zoneNames.add("dantooine");
zoneNames.add("dathomir");
zoneNames.add("endor");
zoneNames.add("lok");
zoneNames.add("naboo");
zoneNames.add("rori");
zoneNames.add("talus");
zoneNames.add("tatooine");
zoneNames.add("yavin4");
Lua* lua = new Lua();
lua->init();
for (int i = 0; i < zoneNames.size(); i++) {
lua->runFile("scripts/managers/spawn_manager/" + zoneNames.get(i) + ".lua");
// Verify regions
LuaObject regions = lua->getGlobalObject(zoneNames.get(i) + "_regions");
ASSERT_TRUE( regions.isValidTable() ) << "Regions table in " << zoneNames.get(i).toCharArray() << " spawn manager is invalid.";
for (int j = 1; j <= regions.getTableSize(); ++j) {
lua_rawgeti(regions.getLuaState(), -1, j);
LuaObject region(regions.getLuaState());
ASSERT_TRUE( region.isValidTable() ) << "Invalid region table #" << String::valueOf(j).toCharArray() << " in " << zoneNames.get(i).toCharArray() << "_regions.";
String area = region.getStringAt(1);
int tier = region.getIntAt(5);
if (tier & SpawnAreaMap::WORLDSPAWNAREA) {
EXPECT_TRUE( tier & SpawnAreaMap::SPAWNAREA ) << "World spawn area " << std::string(area.toCharArray()) << " on planet " << std::string(zoneNames.get(i).toCharArray()) << " is not a spawn area.";
}
if (tier & SpawnAreaMap::SPAWNAREA) {
LuaObject spawnGroups = region.getObjectAt(6);
ASSERT_TRUE( spawnGroups.isValidTable() ) << "Invalid spawnGroups table in spawn area " << std::string(area.toCharArray()) << " in " << zoneNames.get(i).toCharArray() << "_regions.";
for (int k = 1; k <= spawnGroups.getTableSize(); k++) {
String group = spawnGroups.getStringAt(k);
EXPECT_TRUE( CreatureTemplateManager::instance()->getSpawnGroup(group.hashCode()) != NULL ) << "Spawn group " << std::string(group.toCharArray()) << " for spawn area " << std::string(area.toCharArray()) << " on planet " << std::string(zoneNames.get(i).toCharArray()) << " does not exist.";
}
spawnGroups.pop();
}
region.pop();
}
regions.pop();
// Verify static spawns
LuaObject spawns = lua->getGlobalObject(zoneNames.get(i) + "_static_spawns");
ASSERT_TRUE( spawns.isValidTable() ) << "Static spawns table in " << zoneNames.get(i).toCharArray() << " spawn manager is invalid.";
for (int j = 1; j <= spawns.getTableSize(); ++j) {
lua_rawgeti(spawns.getLuaState(), -1, j);
LuaObject spawn(spawns.getLuaState());
ASSERT_TRUE( spawn.isValidTable() ) << "Invalid spawn table #" << String::valueOf(j).toCharArray() << " in " << zoneNames.get(i).toCharArray() << "_static_spawns.";
String name = spawn.getStringAt(1);
EXPECT_TRUE( CreatureTemplateManager::instance()->getTemplate(name) != NULL ) << "Static spawn " << std::string(name.toCharArray()) << " on planet " << std::string(zoneNames.get(i).toCharArray()) << " is not valid";
spawn.pop();
}
spawns.pop();
}
delete lua;
}
示例13: switch
void numeric_spinner::handle_event(event::ptr e)
{
switch (e->type())
{
case event::key_down:
{
key_event::ptr ke = boost::shared_static_cast<key_event>(e);
switch ( ke->fn_key() )
{
case key_enter:
case key_uparrow:
value_ = value_+increment_;
if (value_ > max_)
{
if (wrap_) value_ = min_;
else value_ = max_;
}
build_label();
on_change();
redraw(rect());
return;
break;
case key_downarrow:
value_ = value_-increment_;
if (value_ < min_)
{
if (wrap_) value_ = max_;
else value_ = min_;
}
build_label();
on_change();
redraw(rect());
return;
break;
}
break;
}
case event::mouse_up:
{
mouse_event::ptr me = boost::shared_static_cast<mouse_event>(e);
if (region(me->x(), me->y()) == DOWN_ARROW)
{
value_ = value_-increment_;
if (value_ < min_)
{
if (wrap_) value_ = max_;
else value_ = min_;
}
}
else
{
value_ = value_+increment_;
if (value_ > max_)
{
if (wrap_) value_ = min_;
else value_ = max_;
}
}
build_label();
on_change();
redraw(rect());
return;
}
}
widget::handle_event(e);
}
示例14: addTablePrintHeadingRow
void PrintLayout::printTable()
{
// create and setup a table
QTableView table;
table.setAttribute(Qt::WA_DontShowOnScreen);
table.setSelectionMode(QAbstractItemView::NoSelection);
table.setFocusPolicy(Qt::NoFocus);
table.horizontalHeader()->setVisible(false);
table.horizontalHeader()->setResizeMode(QHeaderView::Fixed);
table.verticalHeader()->setVisible(false);
table.verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
table.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
table.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
// fit table to one page initially
table.resize(scaledPageW, scaledPageH);
// create and fill a table model
TablePrintModel model;
struct dive *dive;
int i, row = 0;
addTablePrintHeadingRow(&model, row); // add one heading row
row++;
for_each_dive(i, dive) {
if (!dive->selected && printOptions->print_selected)
continue;
addTablePrintDataRow(&model, row, dive);
row++;
}
table.setModel(&model); // set model to table
// resize columns to percentages from page width
for (int i = 0; i < model.columns; i++) {
int pw = qCeil((qreal)(tablePrintColumnWidths.at(i) * table.width()) / 100);
table.horizontalHeader()->resizeSection(i, pw);
}
// reset the model at this point
model.callReset();
// a list of vertical offsets where pages begin and some helpers
QList<unsigned int> pageIndexes;
pageIndexes.append(0);
int tableHeight = 0, rowH = 0, accH = 0;
// process all rows
for (int i = 0; i < model.rows; i++) {
rowH = table.rowHeight(i);
accH += rowH;
if (accH > scaledPageH) { // push a new page index and add a heading
pageIndexes.append(pageIndexes.last() + (accH - rowH));
addTablePrintHeadingRow(&model, i);
accH = 0;
i--;
}
tableHeight += rowH;
}
pageIndexes.append(pageIndexes.last() + accH);
// resize the whole widget so that it can be rendered
table.resize(scaledPageW, tableHeight);
// attach a painter and render pages by using pageIndexes
QPainter painter(printer);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::SmoothPixmapTransform);
painter.scale(scaleX, scaleY);
for (int i = 0; i < pageIndexes.size() - 1; i++) {
if (i > 0)
printer->newPage();
QRegion region(0, pageIndexes.at(i) - 1,
table.width(),
pageIndexes.at(i + 1) - pageIndexes.at(i) + 2);
table.render(&painter, QPoint(0, 0), region);
}
}
示例15: TrackingScore
// Compute single tracking score
TrackingScore* TrackingEvaluator::computeScore(const TrackedObject& tracked_object, const Mat& frame, int frame_number, TrackingScoreHistory *history)
{
// Create score
TrackingScore* score = new TrackingScore(&nbc);
// Add score to history
history->addScore(score, frame_number);
// Get blob
const cvb::CvBlob& orig_blob = tracked_object.currentRegion();
// Random move blobs - to test certainties
cvb::CvBlob blob;
cvCloneBlob(orig_blob, blob);
// Save shape ratio
score->setShapeRatio(((float)blob.width())/((float)blob.height()));
// Save area
score->setArea(blob.width()*blob.height());
// Compute object's binary mask, for the histogram
Mat mask = drawBlob(blob, true, frame.cols, frame.rows);
// Get grayscale frame
Mat frame_gs;
cvtColor(frame, frame_gs, CV_BGR2GRAY);
// Split the color channels
Mat* channels = new Mat[3];
split(frame, channels);
Mat frame_b = channels[0];
Mat frame_g = channels[1];
Mat frame_r = channels[2];
delete [] channels;
// Compute histograms
Histogram hist_gs(frame_gs, mask);
Histogram hist_r(frame_r, mask);
Histogram hist_g(frame_g, mask);
Histogram hist_b(frame_b, mask);
// Save histogram
score->setHistograms(hist_gs, hist_r, hist_g, hist_b);
// Select part of frame on which to compute the texture features
Mat copy_gs = frame_gs.clone();
// Blacken non-mask pixels
for(unsigned int x=blob.x; x<=blob.maxx; x++)
{
for(unsigned int y=blob.y; y<=blob.maxy; y++)
{
if(mask.at<uchar>(y,x) == 0)
{
copy_gs.at<uchar>(y,x) = 0;
}
}
}
// Crop image
Rect region(blob.x, blob.y, blob.width(), blob.height());
Mat texture_input = copy_gs(region);
// Compute texture features for this object
vector<float> texture_features = GaborFilter::applyFilterSet(texture_input, gabor_scales, parameters.get<int>("num_orientations"), false, 1, 0.5, 101);
// Save texture features
score->setTextureFeatures(texture_features);
// Set temporal score to the number of appearances
score->temporal_score = history->numScores();
// Get the frame number of the previous detection of this object, if available
int prev_frame = -1;
TrackingScore* prev_score = NULL;
cvb::CvBlob prev_blob;
if(history->numScores() > 1)
{
// Read frame number
prev_frame = *(tracked_object.frameList().end() - 2);
// Get previous score
prev_score = (TrackingScore*) history->getScore(prev_frame);
// Get previous blob
prev_blob = *(tracked_object.regionList().end() - 2);
// Compute shape ratio score
score->shape_ratio_score = computeShapeRatioScore(prev_score->getShapeRatio(), score->getShapeRatio());
// Compute area score
score->area_score = computeAreaScore(prev_score->getArea(), score->getArea());
// Compute histogram difference score
score->histogram_diff_score = computeHistogramDiffScore(score, prev_score);
// Compute texture difference score
score->texture_diff_score = computeTextureDiffScore(score->getTextureFeatures(), prev_score->getTextureFeatures());
// Compute velocity for this score
Point2f prev_position((prev_blob.maxx+prev_blob.x)/2, (prev_blob.maxy+prev_blob.y)/2);
Point2f curr_position((blob.maxx+blob.x)/2, (blob.maxy+blob.y)/2);
float velocity = sqrt((prev_position.x-curr_position.x)*(prev_position.x-curr_position.x) + (prev_position.y-curr_position.y)*(prev_position.y-curr_position.y));
score->setVelocity(velocity);
// Add velocity to the accumulated velocity for this object (will be used to compute an average according to the number of detections)
history->accumulateVelocity(velocity);
// Check if the previous score has its velocity set
if(prev_score->getVelocity() > 0)
{
//cout << "computing ms: " << score->getVelocity() << ", " << history->getAverageVelocity() << endl;
// Compute motion smoothness score, based on current velocity and average velocity
score->motion_smoothness = computeMotionSmoothnessScore(score->getVelocity(), history->getAverageVelocity());
}
else
{
// Set score to 0
score->motion_smoothness = 0.0f;
// Mark score as not full
score->full = false;
}
// Compute direction for this score
float direction = fastAtan2(-curr_position.y + prev_position.y, curr_position.x - prev_position.x);
//.........这里部分代码省略.........