static bool TestEqualityOperator() { RectType rect1(10, 20, 30, 40); RectType rect2(rect1); // Test the equality operator EXPECT_TRUE(rect1 == rect2) << "[1] Test the equality operator"; EXPECT_FALSE(!rect1.IsEqualInterior(rect2)) << "[2] Test the inequality operator"; // Make sure that two empty rects are equal rect1.SetEmpty(); rect2.SetEmpty(); EXPECT_TRUE(rect1 == rect2) << "[3] Make sure that two empty rects are equal"; return true; }
void UBGraphicsRuler::fillBackground(QPainter *painter) { QRectF rect1(rect().topLeft(), QSizeF(rect().width(), rect().height() / 4)); QLinearGradient linearGradient1( rect1.topLeft(), rect1.bottomLeft()); linearGradient1.setColorAt(0, edgeFillColor()); linearGradient1.setColorAt(1, middleFillColor()); painter->fillRect(rect1, linearGradient1); QRectF rect2(rect1.bottomLeft(), QSizeF(rect().width(), rect().height() / 2)); painter->fillRect(rect2, middleFillColor()); QRectF rect3(rect2.bottomLeft(), rect1.size()); QLinearGradient linearGradient3( rect3.topLeft(), rect3.bottomLeft()); linearGradient3.setColorAt(0, middleFillColor()); linearGradient3.setColorAt(1, edgeFillColor()); painter->fillRect(rect3, linearGradient3); }
void CCollegeTimeTableView::OnInitialUpdate() { CString wdays[]={"MON","TUE","WED","THU","FRI","SAT"}; LinesPerPage=35; PageArray.SetSize(100); /// 100 pages, large enough to avoid mem alloc CRect rect(0,0,509,630); m_master.Create(rect,this, 21111); m_master.SetRowCount(ROWS); m_master.SetColumnCount(COLS); m_master.SetFixedRowCount(); //m_master.SetFixedColumnCount(); for(int i=1;i<7;i++) { m_master.SetColumnWidth(i,68); m_master.SetItemText(0,i,wdays[i-1]); m_master.SetItemFormat(0,i-1,ES_CENTER | ES_UPPERCASE); } m_master.SetItemFormat(0,6,ES_CENTER | ES_UPPERCASE); CRect rect1(509,80,1018,580); m_indiv.Create(rect1,this, 21112); m_indiv.SetRowCount(RO); m_indiv.SetColumnCount(7); m_indiv.SetFixedRowCount(); //m_indiv.SetFixedColumnCount(); for(i=1;i<7;i++) { m_indiv.SetColumnWidth(i,68); m_indiv.SetItemText(0,i,wdays[i-1]); m_indiv.SetItemFormat(0,i-1,ES_CENTER | ES_UPPERCASE | ES_READONLY); } m_indiv.SetColumnWidth(6,68); m_indiv.SetItemFormat(0,6,ES_CENTER | ES_UPPERCASE); m_indiv.SetColumnWidth(0,84); CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(); }
void ClientWidget::contextMenuEvent(QContextMenuEvent *event) { QPoint left = groupBox->pos() + clientTable->pos(); QPoint dx = QPoint( clientTable->verticalHeader()->width(), clientTable->horizontalHeader()->height() ); left += dx; QPoint right = clientTable->rect().bottomRight(); QRect rect1( left, right ); left = groupBox->pos() + splitter->pos() + clientTable->pos() + accountTable->pos(); dx = QPoint( accountTable->verticalHeader()->width(), accountTable->horizontalHeader()->height() ); left += dx; right = accountTable->rect().bottomRight(); QRect rect2( left, right ); if( !rect1.contains( event->pos() ) && !rect2.contains( event->pos() ) ) return; QMenu *menu = new QMenu( this ); if( rect1.contains( event->pos() ) ) { menu->addAction( newClientAction ); menu->addAction( editClientAction ); menu->addAction( removeClientAction ); menu->addAction( newClientAccountAction ); } if( rect2.contains( event->pos() ) ) { menu->addAction( newClientAccountAction ); menu->addAction( removeClientAccountAction ); } menu->addSeparator(); menu->addAction( reloadAction ); menu->exec( event->globalPos() ); }
void TestRRegion::TestSubRect() { TRect rect1(-rect[0].iBr.iX,-rect[0].iBr.iY,rect[0].iBr.iX,rect[0].iBr.iY); RRegion rgn; RRegion subRgn; RRegion rgn2; TInt index; if (!rect[0].IsEmpty()) { rgn.AddRect(rect1); for(index=0;index<4;index++) rgn.SubRect(rect[index],&subRgn); if (rect[0].iTl.iX==0) // Special case region, all rects join in the middle { test(rgn.Count()==0); test(subRgn.Count()==4); } else { test(rgn.Count()==3); test(subRgn.Count()==4); test(rgn.BoundingRect()==subRgn.BoundingRect()); rgn.SubRect(xrect); test(rgn.Count()==4); rgn2.Copy(rgn); subRgn.Clear(); rgn.SubRect(rgn.BoundingRect(),&subRgn); test(rgn.Count()==0); rgn2.SubRegion(subRgn,&rgn); test(rgn2.Count()==0); subRgn.SubRegion(rgn); test(subRgn.Count()==0); } } rgn.Close(); rgn2.Close(); subRgn.Close(); }
void object::test<17>() { // // test the stretch() method // LLRectf rect1(-1.0f, 1.0f, 1.0f, -1.0f); LLRectf rect2(rect1); rect1.stretch(0.0f); ensure("stretch(0)", rect1 == rect2); rect1.stretch(0.0f, 0.0f); ensure("stretch(0, 0)", rect1 == rect2); rect1.stretch(10.0f); rect1.stretch(-10.0f); ensure("stretch(10) + stretch(-10)", rect1 == rect2); rect1.stretch(2.0f, 1.0f); rect2.set(-3.0f, 2.0f, 3.0f, -2.0f); ensure("stretch(2, 1)", rect1 == rect2); }
void FieldLineDetector::detectCorners(vector<Vec4i> &lines) { for (int i = 0; i < lines.size(); i++) { for (int j = i + 1; j < lines.size(); j++) { Point2f o1(lines[i][0], lines[i][1]); Point2f p1(lines[i][2], lines[i][3]); Point2f o2(lines[j][0], lines[j][1]); Point2f p2(lines[j][2], lines[j][3]); Point2f pt; GeoUtil::intersection(o1, p1, o2, p2, pt); Rect rect1(o1, p1); Rect rect2(o2, p2); if (!rect1.contains(pt) || !rect2.contains(pt)) { continue; } float angle = fabsf(GeoUtil::computeAngle(lines[i], lines[j])); if (pt.x >= 0 && pt.y >= 0 && angle > 0.2f) { cornerBuffer.push_back(pt); } } } cout << "cornerBuffer.size=" << cornerBuffer.size() << endl; // remove old corners if (cornerBuffer.size() > cornerBufferSize) { cornerBuffer = vector<Point2f>(cornerBuffer.end() - cornerBufferSize, cornerBuffer.end()); } }
/************************************************ Issue #18: Panel clock plugin changes your size ************************************************/ void LxQtClock::updateMinWidth() { QFontMetrics timeLabelMetrics(mTimeLabel->font()); QFontMetrics dateLabelMetrics(mDateLabel->font()); QDate maxDate = getMaxDate(mDateOnNewLine ? dateLabelMetrics : timeLabelMetrics, mDateFormat); QTime maxTime = getMaxTime(timeLabelMetrics, mTimeFormat); QDateTime dt(maxDate, maxTime); //qDebug() << "T:" << metrics.boundingRect(dt.toString(mTimeFormat)).width(); //qDebug() << "C:" << metrics.boundingRect(QTime::currentTime().toString(mTimeFormat)).width() << QTime::currentTime().toString(mTimeFormat); //qDebug() << "D:" << metrics.boundingRect(dt.toString(mDateFormat)).width(); int width; int height; if (mDateOnNewLine) { QRect rect1(timeLabelMetrics.boundingRect(dt.toString(mTimeFormat))); mTimeLabel->setMinimumSize(rect1.size()); QRect rect2(dateLabelMetrics.boundingRect(dt.toString(mDateFormat))); mDateLabel->setMinimumSize(rect2.size()); width = qMax(rect1.width(), rect2.width()); height = rect1.height() + rect2.height(); // qDebug() << "LxQtClock Recalc size" << width << height << dt.toString(mTimeFormat) << dt.toString(mDateFormat); } else { QRect rect(timeLabelMetrics.boundingRect(dt.toString(mClockFormat))); mTimeLabel->setMinimumSize(rect.size()); mDateLabel->setMinimumSize(0, 0); width = rect.width(); height = rect.height(); // qDebug() << "LxQtClock Recalc size" << width << height << dt.toString(mClockFormat); } mContent->setMinimumSize(width, height); }
void CropWidget::paintEvent(QPaintEvent *e) { QWidget::paintEvent(e); QRect rubberRect = rubberBand->geometry(); QRect useRect; if(rubberRect.width() < 0 && rubberRect.height() < 0) { useRect.setTopLeft(rubberRect.bottomRight()); useRect.setBottomRight(rubberRect.topLeft()); } else if(rubberRect.width() < 0) { useRect.setTopRight(rubberRect.topLeft()); useRect.setBottomLeft(rubberRect.bottomRight()); } else if(rubberRect.height() < 0) { useRect.setTopRight(rubberRect.bottomRight()); useRect.setBottomLeft(rubberRect.topLeft()); } else useRect = rubberRect; QRect rect1(0,0,useRect.x(),this->height()); QRect rect2(useRect.x()+useRect.width(),0,this->width()-useRect.x()-useRect.width(),this->height()); QRect rect3(useRect.x(),0,useRect.width(), useRect.y()); QRect rect4(useRect.x(),useRect.y()+useRect.height(), useRect.width(), this->height()-useRect.y()-useRect.height()); QPainter painter(this); painter.setPen(QPen(QBrush(QColor(0,0,0,180)),1,Qt::NoPen)); painter.setBrush(QBrush(QColor(0,0,0,220))); painter.drawRect(rect1); painter.drawRect(rect2); painter.drawRect(rect3); painter.drawRect(rect4); painter.end(); }
void MainWindow::paintEvent(QPaintEvent *) { QPainter painter(this); QRect rect0(10, 10, 20, 20); painter.setPen(Qt::red); // painter.setClipRect(rect0); painter.drawRect(rect0); QRect rect1(10, 35, 20, 20); painter.setPen(Qt::NoPen); painter.setClipRect(rect1); painter.fillRect(rect1, Qt::red); QRect rect2(10, 60, 20, 20); painter.setClipRect(rect2); painter.fillRect(rect2, Qt::red); QRect rect3(10, 85, 20, 20); painter.setPen(Qt::blue); painter.setClipRect(rect3); painter.drawLine(0, 90, 100, 90); painter.drawLine(20, 0, 20, 200); }
void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, int32_t multiple, int32_t& e) { if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; } int32_t leftPadding = 7 * multiple; int32_t leftPosition = 10 * multiple + leftPadding; CFX_ByteString str = FX_UTF8Encode(contents); int32_t iLen = str.GetLength(); FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); CFX_ByteString tempStr = str.Mid(1, 5); FX_FLOAT strWidth = (FX_FLOAT)35 * multiple; FX_FLOAT blank = 0.0; CFX_FxgeDevice geBitmap; if (pOutBitmap) geBitmap.Attach(pOutBitmap, false, nullptr, false); iLen = tempStr.GetLength(); int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; if (!pOutBitmap) { CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect( (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); matr.Concat(*matrix); matr.TransformRect(rect); FX_RECT re = rect.GetOutterRect(); device->FillRect(&re, m_backgroundColor); CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect1( (FX_FLOAT)(leftPosition + 40 * multiple), (FX_FLOAT)(m_Height - iTextHeight), (FX_FLOAT)((leftPosition + 40 * multiple) + strWidth - 0.5), (FX_FLOAT)m_Height); matr1.Concat(*matrix); matr1.TransformRect(rect1); re = rect1.GetOutterRect(); device->FillRect(&re, m_backgroundColor); FX_FLOAT strWidth1 = (FX_FLOAT)multiple * 7; CFX_Matrix matr2(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect2(0.0, (FX_FLOAT)(m_Height - iTextHeight), (FX_FLOAT)strWidth1 - 1, (FX_FLOAT)m_Height); matr2.Concat(*matrix); matr2.TransformRect(rect2); re = rect2.GetOutterRect(); device->FillRect(&re, m_backgroundColor); CFX_Matrix matr3(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect3( (FX_FLOAT)(leftPosition + 85 * multiple), (FX_FLOAT)(m_Height - iTextHeight), (FX_FLOAT)((leftPosition + 85 * multiple) + strWidth1 - 0.5), (FX_FLOAT)m_Height); matr3.Concat(*matrix); matr3.TransformRect(rect3); re = rect3.GetOutterRect(); device->FillRect(&re, m_backgroundColor); } if (!pOutBitmap) strWidth = strWidth * m_outputHScale; CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank); CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); CFX_FxgeDevice ge; if (pOutBitmap) { ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); } else { CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, (FX_FLOAT)leftPosition * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText( iLen, pCharPos + 1, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } tempStr = str.Mid(6, 5); iLen = tempStr.GetLength(); CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { FX_RECT rect2(0, 0, (int)strWidth, iTextHeight); ge.FillRect(&rect2, m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple, m_Height - iTextHeight); } else { CFX_Matrix affine_matrix1( 1.0, 0.0, 0.0, -1.0, (FX_FLOAT)(leftPosition + 40 * multiple) * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText( iLen, pCharPos + 6, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } tempStr = str.Mid(0, 1); iLen = tempStr.GetLength(); strWidth = (FX_FLOAT)multiple * 7; if (!pOutBitmap) strWidth = strWidth * m_outputHScale; CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { delete ge.GetBitmap(); ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); } else { CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText( iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } tempStr = str.Mid(11, 1); iLen = tempStr.GetLength(); CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { delete ge.GetBitmap(); ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple, m_Height - iTextHeight); } else { CFX_Matrix affine_matrix1( 1.0, 0.0, 0.0, -1.0, (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText( iLen, pCharPos + 11, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } FX_Free(pCharPos); }
int Events::handleOneShot(Event *event) { Rect rect; if (event->time > 0) { return kEvStContinue; } // Event has been signaled switch (event->code & EVENT_MASK) { case kTextEvent: switch (event->op) { case kEventDisplay: ((TextListEntry *)event->data)->display = true; break; case kEventRemove: { TextListEntry entry = *((TextListEntry *)event->data); _vm->_scene->_textList.remove(entry); } break; default: break; } break; case kSoundEvent: _vm->_sound->stopSound(); if (event->op == kEventPlay) _vm->_sndRes->playSound(event->param, event->param2, event->param3 != 0); break; case kVoiceEvent: _vm->_sndRes->playVoice(event->param); break; case kMusicEvent: if (event->op == kEventPlay) _vm->_music->play(event->param, (MusicFlags)event->param2); break; case kBgEvent: { Surface *backGroundSurface = _vm->_render->getBackGroundSurface(); BGInfo bgInfo; if (!(_vm->_scene->getFlags() & kSceneFlagISO)) { _vm->_scene->getBGInfo(bgInfo); backGroundSurface->blit(bgInfo.bounds, bgInfo.buffer); // If it is inset scene then draw black border if (bgInfo.bounds.width() < _vm->getDisplayInfo().width || bgInfo.bounds.height() < _vm->_scene->getHeight()) { Common::Rect rect1(2, bgInfo.bounds.height() + 4); Common::Rect rect2(bgInfo.bounds.width() + 4, 2); Common::Rect rect3(2, bgInfo.bounds.height() + 4); Common::Rect rect4(bgInfo.bounds.width() + 4, 2); rect1.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.top - 2); rect2.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.top - 2); rect3.moveTo(bgInfo.bounds.right, bgInfo.bounds.top - 2); rect4.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.bottom); backGroundSurface->drawRect(rect1, kITEColorBlack); backGroundSurface->drawRect(rect2, kITEColorBlack); backGroundSurface->drawRect(rect3, kITEColorBlack); backGroundSurface->drawRect(rect4, kITEColorBlack); } if (event->param == kEvPSetPalette) { PalEntry *palPointer; #ifdef ENABLE_IHNM if (_vm->getGameId() == GID_IHNM) { PalEntry portraitBgColor = _vm->_interface->_portraitBgColor; byte portraitColor = (_vm->getLanguage() == Common::ES_ESP) ? 253 : 254; // Set the portrait bg color, in case a saved state is restored from the // launcher. In this case, sfSetPortraitBgColor is not called, thus the // portrait color will always be 0 (black). if (portraitBgColor.red == 0 && portraitBgColor.green == 0 && portraitBgColor.blue == 0) portraitBgColor.green = 255; if (_vm->_spiritualBarometer > 255) _vm->_gfx->setPaletteColor(portraitColor, 0xff, 0xff, 0xff); else _vm->_gfx->setPaletteColor(portraitColor, _vm->_spiritualBarometer * portraitBgColor.red / 256, _vm->_spiritualBarometer * portraitBgColor.green / 256, _vm->_spiritualBarometer * portraitBgColor.blue / 256); } #endif _vm->_scene->getBGPal(palPointer); _vm->_gfx->setPalette(palPointer); } } _vm->_render->clearFlag(RF_DISABLE_ACTORS); } break; case kPsychicProfileBgEvent: { ResourceContext *context = _vm->_resource->getContext(GAME_RESOURCEFILE); ByteArray resourceData; _vm->_resource->loadResource(context, _vm->getResourceDescription()->psychicProfileResourceId, resourceData); ByteArray image; int width; int height; _vm->decodeBGImage(resourceData, image, &width, &height); const PalEntry *palette = (const PalEntry *)_vm->getImagePal(resourceData); const Rect profileRect(width, height); _vm->_render->getBackGroundSurface()->blit(profileRect, image.getBuffer()); _vm->_render->addDirtyRect(profileRect); _vm->_frameCount++; _vm->_gfx->setPalette(palette); // Draw the scene. It won't be drawn by Render::drawScene(), as a placard is up _vm->_scene->draw(); } break; case kAnimEvent: switch (event->op) { case kEventPlay: _vm->_anim->play(event->param, event->time, true); break; case kEventStop: _vm->_anim->stop(event->param); break; case kEventFrame: _vm->_anim->play(event->param, event->time, false); break; case kEventSetFlag: _vm->_anim->setFlag(event->param, event->param2); break; case kEventClearFlag: _vm->_anim->clearFlag(event->param, event->param2); break; case kEventResumeAll: _vm->_anim->resumeAll(); break; default: break; } break; case kSceneEvent: switch (event->op) { case kEventDraw: { BGInfo bgInfo; _vm->_scene->getBGInfo(bgInfo); _vm->_render->getBackGroundSurface()->blit(bgInfo.bounds, bgInfo.buffer); _vm->_render->addDirtyRect(bgInfo.bounds); _vm->_scene->draw(); } break; case kEventEnd: _vm->_scene->nextScene(); return kEvStBreak; default: break; } break; case kPalAnimEvent: switch (event->op) { case kEventCycleStart: _vm->_palanim->cycleStart(); break; case kEventCycleStep: _vm->_palanim->cycleStep(event->time); break; default: break; } break; case kInterfaceEvent: switch (event->op) { case kEventActivate: _vm->_interface->activate(); break; case kEventDeactivate: _vm->_interface->deactivate(); break; case kEventSetStatus: _vm->_interface->setStatusText((const char*)event->data); _vm->_interface->drawStatusBar(); break; case kEventClearStatus: _vm->_interface->setStatusText(""); _vm->_interface->drawStatusBar(); break; case kEventSetFadeMode: _vm->_interface->setFadeMode(event->param); break; case kEventRestoreMode: _vm->_interface->restoreMode(); break; case kEventSetMode: _vm->_interface->setMode(event->param); break; default: break; } break; case kScriptEvent: switch (event->op) { case kEventExecBlocking: case kEventExecNonBlocking: { debug(6, "Exec module number %ld script entry number %ld", event->param, event->param2); ScriptThread &sthread = _vm->_script->createThread(event->param, event->param2); sthread._threadVars[kThreadVarAction] = event->param3; sthread._threadVars[kThreadVarObject] = event->param4; sthread._threadVars[kThreadVarWithObject] = event->param5; sthread._threadVars[kThreadVarActor] = event->param6; if (event->op == kEventExecBlocking) _vm->_script->completeThread(); break; } case kEventThreadWake: _vm->_script->wakeUpThreads(event->param); break; } break; case kCursorEvent: switch (event->op) { case kEventShow: _vm->_gfx->showCursor(true); break; case kEventHide: _vm->_gfx->showCursor(false); break; case kEventSetNormalCursor: // in ITE and IHNM demo there is just one cursor // ITE never makes this call if (!_vm->isIHNMDemo()) _vm->_gfx->setCursor(kCursorNormal); break; case kEventSetBusyCursor: // in ITE and IHNM demo there is just one cursor // ITE never makes this call if (!_vm->isIHNMDemo()) _vm->_gfx->setCursor(kCursorBusy); break; default: break; } break; case kGraphicsEvent: switch (event->op) { case kEventFillRect: rect.top = event->param2; rect.bottom = event->param3; rect.left = event->param4; rect.right = event->param5; _vm->_gfx->drawRect(rect, event->param); break; case kEventSetFlag: _vm->_render->setFlag(event->param); break; case kEventClearFlag: _vm->_render->clearFlag(event->param); break; default: break; } #ifdef ENABLE_IHNM case kCutawayEvent: switch (event->op) { case kEventClear: _vm->_anim->clearCutaway(); break; case kEventShowCutawayBg: _vm->_anim->showCutawayBg(event->param); break; default: break; } #endif case kActorEvent: switch (event->op) { case kEventMove: // TODO (check Actor::direct) break; default: break; } default: break; } return kEvStDelete; }
int Events::handleOneShot(Event *event) { Surface *backBuffer; ScriptThread *sthread; Rect rect; if (event->time > 0) { return kEvStContinue; } // Event has been signaled switch (event->code & EVENT_MASK) { case kTextEvent: switch (event->op) { case kEventDisplay: ((TextListEntry *)event->data)->display = true; break; case kEventRemove: _vm->_scene->_textList.remove((TextListEntry *)event->data); break; default: break; } break; case kSoundEvent: _vm->_sound->stopSound(); if (event->op == kEventPlay) _vm->_sndRes->playSound(event->param, event->param2, event->param3 != 0); break; case kVoiceEvent: _vm->_sndRes->playVoice(event->param); break; case kMusicEvent: _vm->_music->stop(); if (event->op == kEventPlay) _vm->_music->play(event->param, (MusicFlags)event->param2); break; case kBgEvent: { Surface *backGroundSurface; BGInfo bgInfo; if (!(_vm->_scene->getFlags() & kSceneFlagISO)) { backBuffer = _vm->_gfx->getBackBuffer(); backGroundSurface = _vm->_render->getBackGroundSurface(); _vm->_scene->getBGInfo(bgInfo); backGroundSurface->blit(bgInfo.bounds, bgInfo.buffer); // If it is inset scene then draw black border if (bgInfo.bounds.width() < _vm->getDisplayWidth() || bgInfo.bounds.height() < _vm->_scene->getHeight()) { Common::Rect rect1(2, bgInfo.bounds.height() + 4); Common::Rect rect2(bgInfo.bounds.width() + 4, 2); Common::Rect rect3(2, bgInfo.bounds.height() + 4); Common::Rect rect4(bgInfo.bounds.width() + 4, 2); rect1.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.top - 2); rect2.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.top - 2); rect3.moveTo(bgInfo.bounds.right, bgInfo.bounds.top - 2); rect4.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.bottom); backGroundSurface->drawRect(rect1, kITEColorBlack); backGroundSurface->drawRect(rect2, kITEColorBlack); backGroundSurface->drawRect(rect3, kITEColorBlack); backGroundSurface->drawRect(rect4, kITEColorBlack); } if (event->param == kEvPSetPalette) { PalEntry *palPointer; _vm->_scene->getBGPal(palPointer); _vm->_gfx->setPalette(palPointer); } } } break; case kAnimEvent: switch (event->op) { case kEventPlay: _vm->_anim->play(event->param, event->time, true); break; case kEventStop: _vm->_anim->stop(event->param); break; case kEventFrame: _vm->_anim->play(event->param, event->time, false); break; case kEventSetFlag: _vm->_anim->setFlag(event->param, event->param2); break; case kEventClearFlag: _vm->_anim->clearFlag(event->param, event->param2); break; default: break; } break; case kSceneEvent: switch (event->op) { case kEventEnd: _vm->_scene->nextScene(); return kEvStBreak; default: break; } break; case kPalAnimEvent: switch (event->op) { case kEventCycleStart: _vm->_palanim->cycleStart(); break; case kEventCycleStep: _vm->_palanim->cycleStep(event->time); break; default: break; } break; case kInterfaceEvent: switch (event->op) { case kEventActivate: _vm->_interface->activate(); break; case kEventDeactivate: _vm->_interface->deactivate(); break; case kEventSetStatus: _vm->_interface->setStatusText((const char*)event->data); _vm->_interface->drawStatusBar(); break; case kEventClearStatus: _vm->_interface->setStatusText(""); _vm->_interface->drawStatusBar(); break; case kEventSetFadeMode: _vm->_interface->setFadeMode(event->param); break; default: break; } break; case kScriptEvent: switch (event->op) { case kEventExecBlocking: case kEventExecNonBlocking: debug(6, "Exec module number %ld script entry number %ld", event->param, event->param2); sthread = _vm->_script->createThread(event->param, event->param2); if (sthread == NULL) { _vm->_console->DebugPrintf("Thread creation failed.\n"); break; } sthread->_threadVars[kThreadVarAction] = event->param3; sthread->_threadVars[kThreadVarObject] = event->param4; sthread->_threadVars[kThreadVarWithObject] = event->param5; sthread->_threadVars[kThreadVarActor] = event->param6; if (event->op == kEventExecBlocking) _vm->_script->completeThread(); break; case kEventThreadWake: _vm->_script->wakeUpThreads(event->param); break; } break; case kCursorEvent: switch (event->op) { case kEventShow: _vm->_gfx->showCursor(true); break; case kEventHide: _vm->_gfx->showCursor(false); break; default: break; } break; case kGraphicsEvent: switch (event->op) { case kEventFillRect: rect.top = event->param2; rect.bottom = event->param3; rect.left = event->param4; rect.right = event->param5; ((Surface *)event->data)->drawRect(rect, event->param); break; case kEventSetFlag: _vm->_render->setFlag(event->param); break; case kEventClearFlag: _vm->_render->clearFlag(event->param); break; default: break; } default: break; } return kEvStDelete; }
static bool TestIntersection() { RectType rect1(10, 10, 50, 50); RectType rect2(rect1); RectType dest; // Test against a rect that's the same as rect1 EXPECT_FALSE(!dest.IntersectRect(rect1, rect2) || !(dest.IsEqualInterior(rect1))) << "[1] Test against a rect that's the same as rect1"; // Test against a rect that's enclosed by rect1 rect2.Inflate(-1, -1); EXPECT_FALSE(!dest.IntersectRect(rect1, rect2) || !(dest.IsEqualInterior(rect2))) << "[2] Test against a rect that's enclosed by rect1"; rect2.Inflate(1, 1); // Test against a rect that overlaps the left edge of rect1 rect2.x--; EXPECT_FALSE(!dest.IntersectRect(rect1, rect2) || !(dest.IsEqualInterior(RectType(rect1.x, rect1.y, rect1.width - 1, rect1.height)))) << "[3] Test against a rect that overlaps the left edge of rect1"; rect2.x++; // Test against a rect that's outside of rect1 on the left rect2.x -= rect2.width; EXPECT_FALSE(dest.IntersectRect(rect1, rect2)) << "[4] Test against a rect that's outside of rect1 on the left"; // Make sure an empty rect is returned EXPECT_FALSE(!dest.IsEmpty()) << "[4] Make sure an empty rect is returned"; EXPECT_TRUE(dest.IsFinite()) << "[4b] Should be finite"; rect2.x += rect2.width; // Test against a rect that overlaps the top edge of rect1 rect2.y--; EXPECT_FALSE(!dest.IntersectRect(rect1, rect2) || !(dest.IsEqualInterior(RectType(rect1.x, rect1.y, rect1.width, rect1.height - 1)))) << "[5] Test against a rect that overlaps the top edge of rect1"; EXPECT_TRUE(dest.IsFinite()) << "[5b] Should be finite"; rect2.y++; // Test against a rect that's outside of rect1 on the top rect2.y -= rect2.height; EXPECT_FALSE(dest.IntersectRect(rect1, rect2)) << "[6] Test against a rect that's outside of rect1 on the top"; // Make sure an empty rect is returned EXPECT_FALSE(!dest.IsEmpty()) << "[6] Make sure an empty rect is returned"; EXPECT_TRUE(dest.IsFinite()) << "[6b] Should be finite"; rect2.y += rect2.height; // Test against a rect that overlaps the right edge of rect1 rect2.x++; EXPECT_FALSE(!dest.IntersectRect(rect1, rect2) || !(dest.IsEqualInterior(RectType(rect1.x + 1, rect1.y, rect1.width - 1, rect1.height)))) << "[7] Test against a rect that overlaps the right edge of rect1"; rect2.x--; // Test against a rect that's outside of rect1 on the right rect2.x += rect2.width; EXPECT_FALSE(dest.IntersectRect(rect1, rect2)) << "[8] Test against a rect that's outside of rect1 on the right"; // Make sure an empty rect is returned EXPECT_FALSE(!dest.IsEmpty()) << "[8] Make sure an empty rect is returned"; EXPECT_TRUE(dest.IsFinite()) << "[8b] Should be finite"; rect2.x -= rect2.width; // Test against a rect that overlaps the bottom edge of rect1 rect2.y++; EXPECT_FALSE(!dest.IntersectRect(rect1, rect2) || !(dest.IsEqualInterior(RectType(rect1.x, rect1.y + 1, rect1.width, rect1.height - 1)))) << "[9] Test against a rect that overlaps the bottom edge of rect1"; EXPECT_TRUE(dest.IsFinite()) << "[9b] Should be finite"; rect2.y--; // Test against a rect that's outside of rect1 on the bottom rect2.y += rect2.height; EXPECT_FALSE(dest.IntersectRect(rect1, rect2)) << "[10] Test against a rect that's outside of rect1 on the bottom"; // Make sure an empty rect is returned EXPECT_FALSE(!dest.IsEmpty()) << "[10] Make sure an empty rect is returned"; EXPECT_TRUE(dest.IsFinite()) << "[10b] Should be finite"; rect2.y -= rect2.height; // Test against a rect with zero width or height rect1.SetRect(100, 100, 100, 100); rect2.SetRect(150, 100, 0, 100); EXPECT_FALSE(dest.IntersectRect(rect1, rect2) || !dest.IsEmpty()) << "[11] Intersection of rects with zero width or height should be empty"; EXPECT_TRUE(dest.IsFinite()) << "[11b] Should be finite"; // Tests against a rect with negative width or height // // Test against a rect with negative width rect1.SetRect(100, 100, 100, 100); rect2.SetRect(100, 100, -100, 100); EXPECT_FALSE(dest.IntersectRect(rect1, rect2) || !dest.IsEmpty()) << "[12] Intersection of rects with negative width or height should be empty"; EXPECT_TRUE(dest.IsFinite()) << "[12b] Should be finite"; // Those two rects exactly overlap in some way... // but we still want to return an empty rect rect1.SetRect(100, 100, 100, 100); rect2.SetRect(200, 200, -100, -100); EXPECT_FALSE(dest.IntersectRect(rect1, rect2) || !dest.IsEmpty()) << "[13] Intersection of rects with negative width or height should be empty"; EXPECT_TRUE(dest.IsFinite()) << "[13b] Should be finite"; // Test against two identical rects with negative height rect1.SetRect(100, 100, 100, -100); rect2.SetRect(100, 100, 100, -100); EXPECT_FALSE(dest.IntersectRect(rect1, rect2) || !dest.IsEmpty()) << "[14] Intersection of rects with negative width or height should be empty"; EXPECT_TRUE(dest.IsFinite()) << "[14b] Should be finite"; return true; }
void JTimerObj::draw(JGraphics g, int x, int y, int w, int h) { JRect rect1(x, y+h/6, w, h/3); JRect rect2(x, y+h/2, w, h/3); drawText(g, "Timer", rect1); drawText(g, JInteger::toJString(delay)+"ms", rect2); }
void StereogramWidget::paintEvent(QPaintEvent* event) { m_radius = 0; //means that nothing has been drawn (yet ;) QLabel::paintEvent(event); QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing, true); //pen QPen pen; pen.setStyle(Qt::SolidLine); pen.setBrush(QColor(Qt::black)); int diameter = std::min(width(),height()); int halfW = width()/2; int halfH = height()/2; QPoint center(halfW,halfH); int hsvThickness = 0; if (m_showHSVRing) { int newDiameter = static_cast<int>(ceil(0.9*static_cast<double>(diameter))); hsvThickness = diameter - newDiameter; //TODO if (hsvThickness > 0) { QRect rectangle(center.x()-diameter/2+1,center.y()-diameter/2+1,diameter-2,diameter-2); int angle_span = static_cast<int>(m_angularStep_deg * 16.0); //see QPainter::drawPie QBrush brush; brush.setStyle(Qt::SolidPattern); painter.setPen(Qt::NoPen); //dip direction steps (dip dir. in [0,360]) unsigned ddSteps = static_cast<unsigned>(ceil(360.0 / std::max(m_angularStep_deg,1.0))); for (unsigned j=0; j<ddSteps; ++j) { double dipDir_deg = static_cast<double>(j) * m_angularStep_deg; //set family color ccColor::Rgb col; FacetsClassifier::GenerateSubfamilyColor(col, 90.0, dipDir_deg + 0.5 * m_angularStep_deg, 0, 1); brush.setColor(QColor( static_cast<int>(col.r), static_cast<int>(col.g), static_cast<int>(col.b), 255)); painter.setBrush(brush); int angle_start = static_cast<int>((360.0 - dipDir_deg - m_angularStep_deg + 90.0) * 16.0); //see QPainter::drawPie painter.drawPie(rectangle,angle_start,angle_span); } } diameter = newDiameter; } //outer circle pen.setWidth(2); painter.setPen(pen); painter.setBrush(Qt::white); int radius = diameter/2 - 2; painter.drawEllipse(center,radius,radius); painter.setBrush(Qt::NoBrush); //keep track of the circle position m_radius = radius; m_center = center; //main axes painter.drawLine(center-QPoint(radius,0),center+QPoint(radius,0)); painter.drawLine(center-QPoint(0,radius),center+QPoint(0,radius)); //draw circles if (m_angularStep_deg > 0) { //dip steps (dip in [0,90]) unsigned dSteps = static_cast<unsigned>(ceil(90.0 / m_angularStep_deg)); //dip direction steps (dip dir. in [0,360]) unsigned ddSteps = static_cast<unsigned>(ceil(360.0 / m_angularStep_deg)); //draw inner circles pen.setWidth(1); pen.setColor(Qt::gray); painter.setPen(pen); for (unsigned i=1; i<dSteps; ++i) { double dip_deg = static_cast<double>(i) * m_angularStep_deg; if (dip_deg < 90.0) { int R = static_cast<int>(static_cast<double>(radius) * (dip_deg/90.0)); if (R > 1) painter.drawEllipse(center,R-1,R-1); } } //draw rays (+ 'm_ticksFreq' times more ticks) int ticksFreq = std::max(m_ticksFreq,1); for (unsigned j=1; j<=ddSteps*ticksFreq; ++j) { double dipDir_deg = static_cast<double>(j) * m_angularStep_deg / static_cast<double>(ticksFreq); if (dipDir_deg < 360.0) { QPoint X( static_cast<int>(sin(dipDir_deg * CC_DEG_TO_RAD) * static_cast<double>(radius)), -static_cast<int>(cos(dipDir_deg * CC_DEG_TO_RAD) * static_cast<double>(radius)) ); if ((j % ticksFreq) == 0) //long ticks painter.drawLine(center,center+X); else painter.drawLine(center+X*0.93,center+X); } } } //draw density map if (m_densityGrid && m_densityColorScale && m_densityGrid->grid && m_densityGrid->minMaxDensity[1] != 0) { assert(m_densityColorScale); assert(m_densityGrid->grid); QBrush brush; brush.setStyle(Qt::SolidPattern); painter.setPen(Qt::NoPen); QPolygon poly(4); const double* d = m_densityGrid->grid; for (unsigned j=0; j<m_densityGrid->ddSteps; ++j) { double dipDir0_rad = static_cast<double>(j) * m_densityGrid->step_deg * CC_DEG_TO_RAD; double dipDir1_rad = static_cast<double>(j+1) * m_densityGrid->step_deg * CC_DEG_TO_RAD; double cos_dipDir0 = cos(dipDir0_rad); double sin_dipDir0 = sin(dipDir0_rad); double cos_dipDir1 = cos(dipDir1_rad); double sin_dipDir1 = sin(dipDir1_rad); for (unsigned i=0; i<m_densityGrid->rSteps; ++i, ++d) { if (*d != 0) { double relPos = static_cast<double>(*d)/static_cast<double>(m_densityGrid->minMaxDensity[1]); const colorType* col = m_densityColorScale->getColorByRelativePos(relPos,m_densityColorScaleSteps); brush.setColor(QColor( static_cast<int>(col[0]), static_cast<int>(col[1]), static_cast<int>(col[2]), 255)); painter.setBrush(brush); //stereographic projection //double dip0_rad = static_cast<double>(i) * m_densityGrid->step_deg * CC_DEG_TO_RAD; //double dip1_rad = static_cast<double>(i+1) * m_densityGrid->step_deg * CC_DEG_TO_RAD; //double R0 = static_cast<double>(radius) * cos(dip0_rad) / (1.0 + sin(dip0_rad)); //double R1 = static_cast<double>(radius) * cos(dip1_rad) / (1.0 + sin(dip1_rad)); double R0 = static_cast<double>(radius) * static_cast<double>(i) * m_densityGrid->step_R; double R1 = static_cast<double>(radius) * static_cast<double>(i+1) * m_densityGrid->step_R; poly.setPoint(0,center+QPoint(static_cast<int>(sin_dipDir0 * R0),-static_cast<int>(cos_dipDir0 * R0))); poly.setPoint(1,center+QPoint(static_cast<int>(sin_dipDir0 * R1),-static_cast<int>(cos_dipDir0 * R1))); poly.setPoint(2,center+QPoint(static_cast<int>(sin_dipDir1 * R1),-static_cast<int>(cos_dipDir1 * R1))); poly.setPoint(3,center+QPoint(static_cast<int>(sin_dipDir1 * R0),-static_cast<int>(cos_dipDir1 * R0))); painter.drawPolygon(poly); } } } } //draw main 'dip direction' if (m_meanDipDir_deg >= 0) { pen.setWidth(2); pen.setColor(Qt::red); painter.setPen(pen); //draw main direction QPoint X( static_cast<int>(sin(m_meanDipDir_deg * CC_DEG_TO_RAD) * static_cast<double>(radius)), -static_cast<int>(cos(m_meanDipDir_deg * CC_DEG_TO_RAD) * static_cast<double>(radius)) ); pen.setStyle(Qt::DashLine); painter.setPen(pen); painter.drawLine(center,center+X); //draw orthogonal to main direction QPoint Y( static_cast<int>(cos(m_meanDipDir_deg * CC_DEG_TO_RAD) * static_cast<double>(radius)), static_cast<int>(sin(m_meanDipDir_deg * CC_DEG_TO_RAD) * static_cast<double>(radius)) ); pen.setStyle(Qt::SolidLine); painter.setPen(pen); painter.drawLine(center-Y,center+Y); } //draw filter window around last cliked point if (m_trackMouseClick) { pen.setWidth(2); pen.setColor(Qt::magenta); painter.setPen(pen); //QBrush brush; //brush.setStyle(Qt::Dense6Pattern); //brush.setColor(Qt::red); //painter.setBrush(brush); painter.setBrush(Qt::NoBrush); double R0 = static_cast<double>(radius) * (std::max(0.0,m_clickDip_deg-m_clickDipSpan_deg/2)/90.0); double R1 = static_cast<double>(radius) * (std::min(90.0,m_clickDip_deg+m_clickDipSpan_deg/2)/90.0); //draw radial limits { QPoint X0( static_cast<int>(sin((m_clickDipDir_deg-m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R0), -static_cast<int>(cos((m_clickDipDir_deg-m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R0) ); QPoint X1( static_cast<int>(sin((m_clickDipDir_deg-m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R1), -static_cast<int>(cos((m_clickDipDir_deg-m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R1) ); painter.drawLine(center+X0,center+X1); } { QPoint X0( static_cast<int>(sin((m_clickDipDir_deg+m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R0), -static_cast<int>(cos((m_clickDipDir_deg+m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R0) ); QPoint X1( static_cast<int>(sin((m_clickDipDir_deg+m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R1), -static_cast<int>(cos((m_clickDipDir_deg+m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R1) ); painter.drawLine(center+X0,center+X1); } //draw concentric limits { int angle_start = static_cast<int>((360.0 - m_clickDipDir_deg - m_clickDipDirSpan_deg/2 + 90.0) * 16.0); //see QPainter::drawPie int angle_span = static_cast<int>(m_clickDipDirSpan_deg * 16.0); //see QPainter::drawPie QRectF rect0(static_cast<double>(center.x()) - R0, static_cast<double>(center.y()) - R0, 2*R0, 2*R0); painter.drawArc(rect0,angle_start,angle_span); QRectF rect1(static_cast<double>(center.x()) - R1, static_cast<double>(center.y()) - R1, 2*R1, 2*R1); painter.drawArc(rect1,angle_start,angle_span); } } }
// // Draws the item, which might contain an icon and a text. // The format of the item text shall look like one of the following formats: // - "\ttext" (text only) // - "icon\ttext" (icon and text) // - "\theading\ttext" (heading and text) // - "icon\theading\ttext" (icon, heading and text) // void CMediaScreenListItemDrawer::DrawActualItem(TInt aItemIndex, const TRect& aActualItemRect, TBool aItemIsCurrent, TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/, TBool aItemIsSelected) const { const MDesCArray* itemArray = iListBox.Model()->ItemTextArray(); if ((!itemArray) || (itemArray->MdcaCount() <= aItemIndex)) return; // Gets the item text if the conditions above are met. TPtrC itemText = itemArray->MdcaPoint(aItemIndex); // We have to find the position of tabs to decide the components // available in the item text (icon, heading and text). TInt tabPosition1 = itemText.Locate('\t'); TInt tabPosition2 = itemText.Mid(tabPosition1 + 1).Locate('\t'); if (tabPosition2 >= 0) { // We need to add tabPosition1 because the return value of // Locate() is relative to tabPosition1. tabPosition2 += tabPosition1 + 1; } TInt tabPosition3 = itemText.Mid(tabPosition2 + 1).Locate('\t'); if (tabPosition3 >= 0) { // We need to add tabPosition2 because the return value of // Locate() is relative to tabPosition2. tabPosition3 += tabPosition2 + 1; } TInt tabPosition4 = itemText.Mid(tabPosition3 + 1).Locate('\t'); if (tabPosition4 >= 0) { // We need to add tabPosition2 because the return value of // Locate() is relative to tabPosition2. tabPosition4 += tabPosition3 + 1; } // Sets the attributes to draw the icon. iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); if ((aItemIsCurrent) || (aItemIsSelected)) { iGc->SetBrushColor(iHighlightedBackColor); } else { iGc->SetBrushColor(iBackColor); } // Gets the icon index, i.e. the number in the text item before // the first tab. TInt iconIndex = 0; if (tabPosition1 > 0) { TLex(itemText.Mid(0, tabPosition1)).Val(iconIndex); } TRect aActualItemRect2 = aActualItemRect; aActualItemRect2.iBr.iX = aActualItemRect2.iBr.iX + 0; aActualItemRect2.iBr.iY = aActualItemRect2.iBr.iY + 0; aActualItemRect2.iTl.iX = aActualItemRect2.iTl.iX + 0; aActualItemRect2.iTl.iY = aActualItemRect2.iTl.iY + 10; if ((iIconArray) && (iIconArray->Count() > iconIndex) && (tabPosition1 > 0)) { // Draws the icon. CFbsBitmap* bitmap = (*iIconArray)[iconIndex]->Bitmap(); iGc->BitBltMasked( aActualItemRect2.iTl, bitmap, TRect(TPoint(0, 0), bitmap->Header().iSizeInPixels), (*iIconArray)[iconIndex]->Mask(), ETrue); // Draws the rectangle, just in case there are some icons that are // smaller than the height of item width and/or height. iGc->SetPenStyle(CGraphicsContext::ENullPen); if (bitmap->Header().iSizeInPixels.iHeight < aActualItemRect2.Height()) { TRect rect( aActualItemRect2.iTl.iX, aActualItemRect2.iTl.iY + bitmap->Header().iSizeInPixels.iHeight, aActualItemRect2.iTl.iX + iMaxIconSize.iWidth, aActualItemRect2.iBr.iY); TRect rect1( aActualItemRect2.iTl.iX, aActualItemRect2.iTl.iY - 10, aActualItemRect2.iTl.iX + iMaxIconSize.iWidth, aActualItemRect2.iBr.iY - 40 ); iGc->DrawRect(rect); iGc->DrawRect(rect1); } if (bitmap->Header().iSizeInPixels.iWidth < iMaxIconSize.iWidth) { TRect rect = TRect( aActualItemRect2.iTl.iX + bitmap->Header().iSizeInPixels.iWidth, aActualItemRect2.iTl.iY, aActualItemRect2.iTl.iX + iMaxIconSize.iWidth, aActualItemRect2.iBr.iY); iGc->DrawRect(rect); } } else { iGc->SetPenStyle(CGraphicsContext::ENullPen); TRect rect( aActualItemRect.iTl.iX, aActualItemRect.iTl.iY, aActualItemRect.iTl.iX + iMaxIconSize.iWidth, aActualItemRect.iBr.iY); iGc->DrawRect(rect); } // Sets the attributes to draw text, except the font. const CFont* font = Font(aItemIndex); iGc->SetPenStyle(CGraphicsContext::ESolidPen); iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); if ((aItemIsCurrent) || (aItemIsSelected)) { iGc->SetPenColor(iHighlightedTextColor); iGc->SetBrushColor(iHighlightedBackColor); } else { iGc->SetPenColor(iTextColor); iGc->SetBrushColor(iBackColor); } // If there is only one tab, it means we have to display single line item if (tabPosition2 < 0) { if (!font) { font = CEikonEnv::Static()->TitleFont(); } iGc->UseFont(font); TRect textRect( TPoint(aActualItemRect.iTl.iX + iMaxIconSize.iWidth, aActualItemRect.iTl.iY), aActualItemRect.iBr); TInt baseline = (textRect.iBr.iY - textRect.iTl.iY - font->HeightInPixels()) / 2 + font->AscentInPixels(); TBuf<2000> text; text.Copy(_L(" ")); if (tabPosition1 < 0) { text.Append(itemText); iGc->DrawText(text, textRect, baseline, CGraphicsContext::ELeft, 1); } else { text.Append(itemText.Mid(tabPosition1 + 1)); iGc->DrawText(text, textRect, baseline,CGraphicsContext::ELeft, 1); } } else { // If there are more than one tab, then we have to display double line // item text TRect textRect( TPoint(aActualItemRect.iTl.iX + iMaxIconSize.iWidth, aActualItemRect.iTl.iY), aActualItemRect.iBr); textRect.iBr.iY -= aActualItemRect.Height() / 2; // Draws the first line. if (!font) { font = CEikonEnv::Static()->LegendFont(); } iGc->UseFont(font); TInt baseline = (textRect.iBr.iY - textRect.iTl.iY - font->HeightInPixels()) / 2 + font->AscentInPixels(); TBuf<2000> text; text.Copy(_L(" ")); text.Append(itemText.Mid(tabPosition1 + 1, tabPosition2 - tabPosition1 - 1)); iGc->DrawText(text,textRect, baseline, CGraphicsContext::ELeft, 1); // Draws the second line. For the second line, we use normal font. font = CCoeEnv::Static()->NormalFont(); iGc->UseFont(font); textRect.Move(0, aActualItemRect.Height() / 2); baseline = (textRect.iBr.iY - textRect.iTl.iY - font->HeightInPixels()) / 2 + font->AscentInPixels();/// text.Copy(_L(" ")); //text.Append(itemText.Mid(tabPosition2 + 1)); text.Append(itemText.Mid(tabPosition2 + 1, tabPosition3 - tabPosition2 - 1)); iGc->DrawText(text, textRect, baseline, CGraphicsContext::ELeft, 1); //Loads 2nd bitmap TRect aActualItemRect1 = aActualItemRect; aActualItemRect1.iBr.iX = aActualItemRect1.iBr.iX + 0; aActualItemRect1.iBr.iY = aActualItemRect1.iBr.iY + 0; if (tabPosition4 >= 0) aActualItemRect1.iTl.iX = aActualItemRect1.iTl.iX + 160; else aActualItemRect1.iTl.iX = aActualItemRect1.iTl.iX + 180; aActualItemRect1.iTl.iY = aActualItemRect1.iTl.iY + 0; text.Copy(_L("")); text.Append(itemText.Mid((tabPosition3 + 1),1)); TInt type; TLex lex(text); lex.Val(type); // Draws the icon. CFbsBitmap* bitmap = (*iIconArray)[type]->Bitmap(); iGc->BitBltMasked(aActualItemRect1.iTl, bitmap,TRect(TPoint(0,0), bitmap->Header().iSizeInPixels), (*iIconArray)[type]->Mask(), ETrue); // Draws the rectangle, just in case there are some icons that are // smaller than the height of item width and/or height. iGc->SetPenStyle(CGraphicsContext::ENullPen); if (bitmap->Header().iSizeInPixels.iHeight < aActualItemRect1.Height()) { TRect rect( aActualItemRect1.iTl.iX, aActualItemRect1.iTl.iY + bitmap->Header().iSizeInPixels.iHeight, aActualItemRect1.iTl.iX + iMaxIconSize.iWidth, aActualItemRect1.iBr.iY); iGc->DrawRect(rect); } if (bitmap->Header().iSizeInPixels.iWidth < iMaxIconSize.iWidth) { TRect rect = TRect( aActualItemRect1.iTl.iX + bitmap->Header().iSizeInPixels.iWidth, aActualItemRect1.iTl.iY, aActualItemRect1.iTl.iX + iMaxIconSize.iWidth, aActualItemRect1.iBr.iY); iGc->DrawRect(rect); } if (tabPosition4 >= 0) { //load 3rd bitmap TRect aActualItemRect2 = aActualItemRect; aActualItemRect2.iBr.iX = aActualItemRect2.iBr.iX + 0; aActualItemRect2.iBr.iY = aActualItemRect2.iBr.iY + 0; aActualItemRect2.iTl.iX = aActualItemRect2.iTl.iX + 180; aActualItemRect2.iTl.iY = aActualItemRect2.iTl.iY + 0; text.Copy(_L("")); text.Append(itemText.Mid((tabPosition4 + 1),1)); type = 0; TLex lex1(text); lex1.Val(type); // Draws the icon. CFbsBitmap* bitmap1 = (*iIconArray)[type]->Bitmap(); iGc->BitBltMasked(aActualItemRect2.iTl, bitmap1,TRect(TPoint(0,0), bitmap1->Header().iSizeInPixels), (*iIconArray)[type]->Mask(), ETrue); // Draws the rectangle, just in case there are some icons that are // smaller than the height of item width and/or height. iGc->SetPenStyle(CGraphicsContext::ENullPen); if (bitmap1->Header().iSizeInPixels.iHeight < aActualItemRect2.Height()) { TRect rect( aActualItemRect2.iTl.iX, aActualItemRect2.iTl.iY + bitmap1->Header().iSizeInPixels.iHeight, aActualItemRect2.iTl.iX + iMaxIconSize.iWidth, aActualItemRect2.iBr.iY); iGc->DrawRect(rect); } if (bitmap1->Header().iSizeInPixels.iWidth < iMaxIconSize.iWidth) { TRect rect = TRect( aActualItemRect2.iTl.iX + bitmap1->Header().iSizeInPixels.iWidth, aActualItemRect2.iTl.iY, aActualItemRect2.iTl.iX + iMaxIconSize.iWidth, aActualItemRect2.iBr.iY); iGc->DrawRect(rect); } } } }
FlattenTestImage() : refRect(0,0,512,512) , p(refRect) { image = p.image; layer1 = p.layer; layer5 = new KisPaintLayer(p.image, "paint5", 0.4 * OPACITY_OPAQUE_U8); layer5->disableAlphaChannel(true); layer2 = new KisPaintLayer(p.image, "paint2", OPACITY_OPAQUE_U8); tmask = new KisTransparencyMask(); // check channel flags // make addition composite op group1 = new KisGroupLayer(p.image, "group1", OPACITY_OPAQUE_U8); layer3 = new KisPaintLayer(p.image, "paint3", OPACITY_OPAQUE_U8); layer4 = new KisPaintLayer(p.image, "paint4", OPACITY_OPAQUE_U8); layer6 = new KisPaintLayer(p.image, "paint6", OPACITY_OPAQUE_U8); layer7 = new KisPaintLayer(p.image, "paint7", OPACITY_OPAQUE_U8); layer8 = new KisPaintLayer(p.image, "paint8", OPACITY_OPAQUE_U8); layer7->setCompositeOp(COMPOSITE_ADD); layer8->setCompositeOp(COMPOSITE_ADD); QRect rect1(100, 100, 100, 100); QRect rect2(150, 150, 150, 150); QRect tmaskRect(200,200,100,100); QRect rect3(400, 100, 100, 100); QRect rect4(500, 100, 100, 100); QRect rect5(50, 50, 100, 100); QRect rect6(50, 250, 100, 100); QRect rect7(50, 350, 50, 50); QRect rect8(50, 400, 50, 50); layer1->paintDevice()->fill(rect1, KoColor(Qt::red, p.image->colorSpace())); layer2->paintDevice()->fill(rect2, KoColor(Qt::green, p.image->colorSpace())); tmask->testingInitSelection(tmaskRect); layer3->paintDevice()->fill(rect3, KoColor(Qt::blue, p.image->colorSpace())); layer4->paintDevice()->fill(rect4, KoColor(Qt::yellow, p.image->colorSpace())); layer5->paintDevice()->fill(rect5, KoColor(Qt::green, p.image->colorSpace())); layer6->paintDevice()->fill(rect6, KoColor(Qt::cyan, p.image->colorSpace())); layer7->paintDevice()->fill(rect7, KoColor(Qt::red, p.image->colorSpace())); layer8->paintDevice()->fill(rect8, KoColor(Qt::green, p.image->colorSpace())); KisPSDLayerStyleSP style(new KisPSDLayerStyle()); style->dropShadow()->setEffectEnabled(true); style->dropShadow()->setDistance(10.0); style->dropShadow()->setSpread(80.0); style->dropShadow()->setSize(10); style->dropShadow()->setNoise(0); style->dropShadow()->setKnocksOut(false); style->dropShadow()->setOpacity(80.0); layer2->setLayerStyle(style); layer2->setCompositeOp(COMPOSITE_ADD); group1->setCompositeOp(COMPOSITE_ADD); p.image->addNode(layer5); p.image->addNode(layer2); p.image->addNode(tmask, layer2); p.image->addNode(group1); p.image->addNode(layer3, group1); p.image->addNode(layer4, group1); p.image->addNode(layer6); p.image->addNode(layer7); p.image->addNode(layer8); p.image->initialRefreshGraph(); // dbgKrita << ppVar(layer1->exactBounds()); // dbgKrita << ppVar(layer5->exactBounds()); // dbgKrita << ppVar(layer2->exactBounds()); // dbgKrita << ppVar(group1->exactBounds()); // dbgKrita << ppVar(layer3->exactBounds()); // dbgKrita << ppVar(layer4->exactBounds()); TestUtil::ExternalImageChecker chk("flatten", "imagetest"); QVERIFY(chk.checkDevice(p.image->projection(), p.image, "00_initial")); }
void CTimeAxis::drawTimeBrev(CDC* pDC) { if (pDC == NULL) return; if (m_pSyr == NULL) return; int num = m_pSyr->getYYerCount(); if (num < 1) return; CRect rect; this->GetWindowRect(&rect); ScreenToClient(&rect); rect.top += 4; rect.bottom = rect.top + 6; CPen pen(PS_SOLID, 3, RGB(0, 255, 255)); CPen pen1(PS_SOLID, 1, RGB(255, 0, 0)); CPen *pOldPen = NULL; int maxTime = 2*m_pSyr->getMaxTime(); if (maxTime >= m_allTime) { // pOldPen = pDC->SelectObject(&pen); // pDC->MoveTo(rect.left, rect.top + 3); // pDC->LineTo(rect.right-1, rect.top + 3); CRect rect1; rect1.left = rect.Width() * m_minTime / maxTime + rect.left; rect1.right = rect.Width() * m_maxTime / maxTime + rect.left; rect1.top = rect.top; rect1.bottom = rect.bottom; pDC->SelectObject(&pen1); // pDC->Rectangle(&rect1); pDC->MoveTo(rect1.left, rect1.top); pDC->LineTo(rect1.left, rect1.bottom-1); pDC->LineTo(rect1.right-1, rect1.bottom-1); pDC->LineTo(rect1.right-1, rect1.top); pDC->LineTo(rect1.left, rect1.top); pDC->SelectObject(pOldPen); } else if (maxTime > m_minTime) { CRect rect1(rect); rect1.left = rect.Width() * m_minTime / m_maxTime + rect.left; rect1.right = rect.Width() * maxTime / m_maxTime + rect.left; // pOldPen = pDC->SelectObject(&pen); // pDC->MoveTo(rect1.left, rect1.top + 3); // pDC->LineTo(rect1.right-1, rect1.top + 3); pDC->SelectObject(&pen1); // pDC->Rectangle(&rect); pDC->MoveTo(rect.left, rect.top); pDC->LineTo(rect.left, rect.bottom-1); pDC->LineTo(rect.right-1, rect.bottom-1); pDC->LineTo(rect.right-1, rect.top); pDC->LineTo(rect.left, rect.top); pDC->SelectObject(pOldPen); } // Invalidate(); }
static void test_CRect() { CRect empty; ok(empty.left == 0, "Expected left to be 0, was %ld\n", empty.left); ok(empty.top == 0, "Expected top to be 0, was %ld\n", empty.top); ok(empty.Width() == 0, "Expected Width to be 0, was %i\n", empty.Width()); ok(empty.Height() == 0, "Expected Height to be 0, was %i\n", empty.Height()); CRect rect(0, 0, 100, 50); ok(rect.Width() == 100, "Expected Width to be 100, was %i\n", rect.Width()); ok(rect.Height() == 50, "Expected Height to be 50, was %i\n", rect.Height()); RECT sdkRect; sdkRect.left = 0; sdkRect.top = 0; sdkRect.right = 100; sdkRect.bottom = 50; CRect rect2(sdkRect); CRect rect3(&sdkRect); ok_rect(rect2, rect); ok_rect(rect3, rect); CPoint pt(0, 0); CSize sz(100, 50); CRect rect4(pt, sz); ok_rect(rect4, rect2); CPoint ptBottomRight(100, 50); CRect rect5(pt, ptBottomRight); ok_rect(rect5, rect4); rect = CRect(210, 150, 350, 900); CPoint ptDown; ptDown = rect.BottomRight(); pt = CPoint(350, 900); ok_point(ptDown, pt); rect2 = CRect(10, 10, 350, 350); CPoint ptLow(180, 180); rect2.BottomRight() = ptLow; rect = CRect(10, 10, 180, 180); ok_rect(rect2, rect); pt = CPoint(95, 95); CPoint pt2 = rect2.CenterPoint(); ok_point(pt2, pt); pt2 = rect2.BottomRight(); pt = CPoint(180, 180); ok_point(pt2, pt); pt2 = rect2.TopLeft(); pt = CPoint(10, 10); ok_point(pt2, pt); rect2.TopLeft().Offset(3, 3); rect3 = CRect(13, 13, 180, 180); ok_rect(rect3, rect2); CRect rectSource(35, 10, 125, 10); CRect rectDest; rectDest.CopyRect(&rectSource); RECT rectSource2; rectSource2.left = 0; rectSource2.top = 0; rectSource2.bottom = 480; rectSource2.right = 640; rectDest.CopyRect(&rectSource2); rect = CRect(10, 10, 50, 50); rect.DeflateRect(1, 2); rect2 = CRect(11, 12, 49, 48); ok_rect(rect2, rect); rect2 = CRect(10, 10, 50, 50); CRect rectDeflate(1, 2, 3, 4); rect2.DeflateRect(&rectDeflate); rect = CRect(11, 12, 47, 46); ok_rect(rect2, rect); rect2.DeflateRect(sz); rect = CRect(111, 62, -53, -4); ok_rect(rect2, rect); rect2.OffsetRect(sz); rect = CRect(211, 112, 47, 46); ok_rect(rect2, rect); CRect rect1(35, 150, 10, 25); rect2 = CRect(35, 150, 10, 25); rect3 = CRect(98, 999, 6, 3); ok(rect1.EqualRect(rect2), "Expected EqualRect to return TRUE for %s, %s\n", wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&rect2)); ok(!rect1.EqualRect(rect3), "Expected EqualRect to return FALSE for %s, %s\n", wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&rect3)); RECT test; test.left = 35; test.top = 150; test.right = 10; test.bottom = 25; ok(rect1.EqualRect(&test), "Expected EqualRect to return TRUE for %s, %s\n", wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&test)); rect = test; rect2 = CRect(35, 150, 10, 25); ok_rect(rect, rect2); rect = CRect(0, 0, 300, 300); rect.InflateRect(50, 200); rect2 = CRect(-50, -200, 350, 500); ok_rect(rect, rect2); rect.InflateRect(sz); rect2 = CRect(-150, -250, 450, 550); ok_rect(rect, rect2); rect = CRect(20, 30, 80, 70); int nHt = rect.Height(); ok(nHt == 40, "Expected nHt to be 40, was %i\n", nHt); CRect rectOne(125, 0, 150, 200); CRect rectTwo(0, 75, 350, 95); CRect rectInter; rectInter.IntersectRect(rectOne, rectTwo); rect = CRect(125, 75, 150, 95); ok_rect(rectInter, rect); CRect rectInter2 = rectOne; rectInter2 &= rectTwo; rect = CRect(125, 75, 150, 95); ok_rect(rectInter2, rect); CRect rectNone(0, 0, 0, 0); CRect rectSome(35, 50, 135, 150); ok(rectNone.IsRectEmpty(), "Expected IsRectEmpty to return TRUE for %s\n", wine_dbgstr_rect(&rectNone)); ok(!rectSome.IsRectEmpty(), "Expected IsRectEmpty to return FALSE for %s\n", wine_dbgstr_rect(&rectSome)); CRect rectEmpty(35, 35, 35, 35); ok(rectEmpty.IsRectEmpty(), "Expected IsRectEmpty to return TRUE for %s\n", wine_dbgstr_rect(&rectEmpty)); ok(rectNone.IsRectNull(), "Expected IsRectNull to return TRUE for %s\n", wine_dbgstr_rect(&rectNone)); ok(!rectSome.IsRectNull(), "Expected IsRectNull to return FALSE for %s\n", wine_dbgstr_rect(&rectSome)); CRect rectNotNull(0, 0, 35, 50); ok(!rectNotNull.IsRectNull(), "Expected IsRectNull to return FALSE for %s\n", wine_dbgstr_rect(&rectNotNull)); rect1 = CRect(35, 150, 10, 25); rect2 = CRect(35, 150, 10, 25); rect3 = CRect(98, 999, 6, 3); ok_rect(rect1, rect2); test.left = 35; test.top = 150; test.right = 10; test.bottom = 25; ok_rect(rect1, test); nok_rect(rect1, rect3); nok_rect(rect3, test); rect1 = CRect(100, 235, 200, 335); pt = CPoint(35, 65); rect2 = CRect(135, 300, 235, 400); rect1 += pt; ok_rect(rect1, rect2); rect1 = CRect(100, 235, 200, 335); rect2 = rect1 + pt; CRect rectResult(135, 300, 235, 400); ok_rect(rectResult, rect2); rect2 = rect1 + &test; rectResult = CRect(65, 85, 210, 360); ok_rect(rectResult, rect2); rect2 = rect1 - (LPCRECT)&test; rectResult = CRect(135, 385, 190, 310); ok_rect(rectResult, rect2); rect2 = rect1 - pt; rectResult = CRect(65, 170, 165, 270); ok_rect(rect2, rectResult); rect1 -= pt; ok_rect(rect1, rectResult); rect1 = CRect(100, 0, 200, 300); rect2 = CRect(0, 100, 300, 200); rect3 = rect1 & rect2; rectResult = CRect(100, 100, 200, 200); ok_rect(rectResult, rect3); rect3 = rect1 | rect2; rectResult = CRect(0, 0, 300, 300); ok_rect(rectResult, rect3); rect1 |= rect2; ok_rect(rectResult, rect1); rect1 += sz; rectResult = CRect(100, 50, 400, 350); ok_rect(rectResult, rect1); rect1 += &test; rectResult = CRect(65, -100, 410, 375); ok_rect(rectResult, rect1); rect1 -= sz; rectResult = CRect(-35, -150, 310, 325); ok_rect(rectResult, rect1); rect1 -= &test; rectResult = CRect(0, 0, 300, 300); ok_rect(rectResult, rect1); rect2 = rect1 + sz; rectResult = CRect(100, 50, 400, 350); ok_rect(rectResult, rect2); rect2 = rect1 - sz; rectResult = CRect(-100, -50, 200, 250); ok_rect(rectResult, rect2); }
BOOL CTLSentenceDlg::OnInitDialog() { CString T,strFontName; CHARFORMAT2 cf; CWnd* pWnd; CDialog::OnInitDialog(); m_nSourceText=m_pDoc->m_nSourceText; CWnd* pDlg=this; if (m_nType==2) //showing the target verse and the english for where a rule applied { T=L""; } else if (m_nType==3) //entering an expression and gloss for Vocabulary Quizzer { T=L"Enter an expression and its gloss"; } else if (m_nType==4) //if editing a saved target verse { T=L"Edit the Target Text"; } else if (m_nType==5) //if displaying the English and target text from the Word doc { T=L"English and Target Texts from the Word document"; } else if (m_nSourceText>2 && m_nSourceText!=5) //if an English source text { if (m_nSourceText==3) T=L"Enter a proposition and its gloss for this English Missions Document verse."; else if (m_nSourceText==4) T=L"Enter the text and its gloss for this English Bible verse."; else if (m_nSourceText==6) T=L"Enter a proposition and its gloss for this English Grammar Introduction verse."; else if (m_nSourceText==7) T=L"Enter the text and its gloss for this English Document verse."; } pDlg->SetWindowText(T); //set up the edit control that will display the target text CRect rect1(9,32,740,165); m_recTarget.Create(ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL | WS_VISIBLE | WS_BORDER, rect1, this, 1); if (m_nType==2 || m_nType==3 || m_nType==4 || m_nType==5 || m_nSourceText==5) strFontName=m_pDoc->GetTargetLanguageFontName(); //if TLText else strFontName=m_pDoc->GetSourceLanguageFontName(m_nSourceText); //else English Bible or English Grammar Introduction cf.dwMask=CFM_FACE | CFM_BOLD | CFM_SIZE; wcscpy_s(cf.szFaceName,strFontName); //target font used as default because its text extent is probably > extent of Arial cf.dwEffects=!CFE_BOLD; cf.yHeight=220; m_recTarget.SetDefaultCharFormat(cf); //set default to target font if (m_nType==2 || m_nType==5) //if showing a verse where a rule applied { pWnd=&m_recTarget; pWnd->SetWindowText(m_strTarget); pWnd=&m_butOK; pWnd->ShowWindow(SW_HIDE); if (m_nRedFontStart>-1) ChangeColorOfCharacters(m_nRedFontStart,m_nRedFontEnd); } else if (m_nType==4) //if editing the target text { pWnd=&m_recTarget; pWnd->SetWindowText(m_strTarget); } //set up the edit control that will display the gloss CRect rect(9,185,740,310); m_recGloss.Create(ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL | WS_VISIBLE | WS_BORDER, rect, this, 1); wcscpy_s(cf.szFaceName,L"Arial"); m_recGloss.SetDefaultCharFormat(cf); //set default to Arial font pWnd=&m_recGloss; pWnd->SetWindowText(m_strGloss); //UpdateData(FALSE); //if editing gloss for English Bible so m_strGloss loaded, send it to the edit control if (m_nType==2 || m_nType==5) pWnd=GetDlgItem(IDCANCEL); //showing popup from rule's references else pWnd=&m_recTarget; pWnd->SetFocus(); return FALSE; // return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CAlfPerfAppAvkonTestCaseBasic::NextAnimFrameL() { // Begin drawing RWindow& window = static_cast< RWindow& >( *iAvkonControl->DrawableWindow() ); CWindowGc& gc = iAvkonControl->SystemGc(); TRect updateRect(iAvkonControl->Rect()); window.Invalidate( updateRect ); window.BeginRedraw( updateRect ); gc.Activate(window); // Draw background TRgb color (KRgbWhite); gc.SetBrushColor(color); gc.SetBrushStyle(CGraphicsContext::ESolidBrush); gc.SetPenStyle(CGraphicsContext::ESolidPen); gc.SetPenSize(TSize(10,10)); gc.SetPenColor(color); gc.DrawRect(updateRect); // Calc timeline TTime now; now.UniversalTime(); TUint millisecondFromCycleStart = now.MicroSecondsFrom(iCycleStartTime).Int64() / 1000; double timelinePercentage = (double)millisecondFromCycleStart / KCycleDurationMs; timelinePercentage *= 0.5; // scale it a bit... // Calc rect TRect fullRect(updateRect); TSize size(fullRect.Width()*(1.0 - timelinePercentage), fullRect.Height()*(1.0 - timelinePercentage)); TPoint windowCenter = fullRect.Center(); TPoint tl(windowCenter.iX - size.iWidth/2, windowCenter.iY - size.iHeight/2); TRect rect(tl, size); // Draw gc.SetPenColor(KRgbBlue); gc.SetBrushColor(KRgbRed); const TPoint Point1(rect.iTl); const TPoint Point2(rect.iBr.iX, rect.iTl.iY); const TPoint Point3(rect.iBr); const TPoint Point4(rect.iTl.iX, rect.iBr.iY); const TPoint center(rect.Center()); switch (iCycleCounter) { case 1: // DrawEllipse { gc.DrawEllipse(rect); break; } case 2: // DrawRect { gc.DrawRect(rect); break; } case 3: // DrawRoundRect { TSize corner(rect.Width()/5, rect.Height()/5); gc.DrawRoundRect(rect, corner); break; } case 4: // Draw lines { gc.SetPenColor(TRgb(255,0,0)); gc.DrawLine(Point1, Point2); gc.SetPenColor(TRgb(200,50,0)); gc.DrawLineTo(Point3); gc.SetPenColor(TRgb(150,100,0)); gc.DrawLineTo(Point4); gc.SetPenColor(TRgb(100,150,0)); gc.DrawLineBy(TPoint(0, -rect.Height())); gc.SetPenColor(TRgb(50,200,0)); gc.MoveTo(Point2); gc.DrawLineTo(Point4); gc.SetPenColor(TRgb(0,255,0)); gc.MoveBy(TPoint(0, -rect.Height())); gc.DrawLineTo(Point3); gc.SetPenColor(TRgb(255,0,0)); gc.Plot(center); break; } case 5: // Draw { gc.SetPenColor(TRgb(255,0,0)); gc.DrawArc(rect, Point2, Point1); gc.DrawPie(rect, Point4, Point3); break; } case 6: // Draw polygons { const TInt KNumPoints = 9; TPoint pointList[KNumPoints]; pointList[0] = TPoint(Point1.iX+rect.Width()*0.25, Point1.iY); pointList[1] = TPoint(Point1.iX+rect.Width()*0.75, Point1.iY); pointList[2] = TPoint(Point2.iX, Point2.iY+rect.Height()*0.25); pointList[3] = TPoint(Point2.iX, Point2.iY+rect.Height()*0.75); pointList[4] = TPoint(Point3.iX-rect.Width()*0.25, Point3.iY); pointList[5] = TPoint(Point3.iX-rect.Width()*0.75, Point3.iY); pointList[6] = TPoint(Point4.iX, Point4.iY-rect.Height()*0.25); pointList[7] = TPoint(Point4.iX, Point4.iY-rect.Height()*0.75); pointList[8] = TPoint(Point1.iX+rect.Width()*0.25, Point1.iY); CArrayFix<TPoint>* mypoints = new CArrayFixFlat<TPoint>(KNumPoints); CleanupStack::PushL(mypoints); for(TInt i=0; i<KNumPoints; i++) { mypoints->AppendL(pointList[i]); } gc.SetPenColor(TRgb(255,0,0)); gc.SetPenSize(TSize(20,20)); gc.DrawPolyLine(mypoints); gc.SetPenColor(TRgb(0,255,0)); gc.SetPenSize(TSize(15,15)); gc.DrawPolyLine(pointList, KNumPoints); gc.SetPenColor(TRgb(255,255,0)); gc.SetPenSize(TSize(10,10)); gc.DrawPolygon(mypoints); gc.SetPenColor(TRgb(0,0,255)); gc.SetPenSize(TSize(5,5)); gc.DrawPolygon(pointList, KNumPoints); CleanupStack::PopAndDestroy(); // mypoints break; } case 7: // Draw texts { gc.UseFont(iFont); gc.SetDrawMode(CGraphicsContext::EDrawModePEN); gc.SetPenStyle(CGraphicsContext::ESolidPen); gc.SetBrushStyle(CGraphicsContext::ESolidBrush); TInt h = rect.Height() / 3; TInt y = rect.iTl.iY; TRect tinyBox(rect); tinyBox.SetHeight(h); TInt fontDescent=iFont->DescentInPixels(); gc.SetBrushColor(TRgb(0, 0, 255)); // blue gc.SetPenColor(TRgb(0,255,0)); // green gc.DrawText(_L("Ilves"), tinyBox.iTl+TPoint(0, fontDescent)); tinyBox.Move(0,h); TInt posY = tinyBox.Height()-fontDescent; gc.SetPenColor(TRgb(255,0,0)); gc.DrawText(_L("Tappara"), tinyBox, posY); gc.SetPenColor(TRgb(0,255,0)); // green gc.DrawTextVertical(_L("Ilves"), tinyBox.iTl+TPoint(fontDescent, 0 ), ETrue); tinyBox.Move(0,h); posY = tinyBox.Height()-fontDescent; gc.SetPenColor(TRgb(255,0,0)); gc.DrawTextVertical(_L("Tappara"), tinyBox, posY, ETrue); break; } case 8: // Draw bitmaps { TPoint pos(rect.iTl); gc.BitBlt(pos, iPictureBm); pos = TPoint(rect.iTl.iX + rect.Width()/3, rect.iTl.iY); gc.BitBlt(pos, iPictureBm, TRect(iPictureBm->SizeInPixels())); pos = TPoint(rect.iTl.iX + rect.Width()*2/3, rect.iTl.iY); gc.BitBltMasked(pos, iPictureBm, TRect(iPictureBm->SizeInPixels()), iMaskBm, EFalse); pos = TPoint(rect.iTl.iX, rect.iTl.iY+ rect.Height()/3); TRect dstRect(pos, TSize(rect.Width()/3, rect.Height()/3)); gc.DrawBitmap(dstRect, iPictureBm, TRect(iPictureBm->SizeInPixels())); pos = TPoint(rect.iTl.iX + rect.Width()/3, rect.iTl.iY+ rect.Height()/3); dstRect = TRect(pos, dstRect.Size()); gc.DrawBitmap(dstRect, iPictureBm); pos = TPoint(rect.iTl.iX, rect.iTl.iY+ rect.Height()*2/3); gc.DrawBitmap(pos, iPictureBm); pos = TPoint(rect.iTl.iX + rect.Width()/3, rect.iTl.iY+ rect.Height()*2/3); dstRect = TRect(pos, dstRect.Size()); gc.DrawBitmapMasked(dstRect, iPictureBm, TRect(iPictureBm->SizeInPixels()), iMaskBm, EFalse); break; } case 9: // Miscellanious { TRect rect1(rect); rect1.SetWidth(rect.Width()/2); rect1.SetHeight(rect.Height()/2); TRect rect2(rect1); rect2.Move(rect1.Width(),0); TRect rect3(rect1); rect3.Move(0, rect1.Height()); TRect rect4(rect1); rect4.Move(rect1.Width(), rect1.Height()); // Clear gc.Clear(); // Brush pattern gc.UseBrushPattern(iPictureBm); gc.SetBrushStyle(CGraphicsContext::EPatternedBrush); gc.DrawRect(rect1); gc.DiscardBrushPattern(); // Fading & copy rect gc.SetFaded(ETrue); gc.CopyRect(rect2.iTl, rect1); gc.SetFadingParameters(255,0); gc.CopyRect(rect3.iTl, rect1); // Map colors gc.SetPenColor(KRgbBlue); gc.SetBrushColor(KRgbRed); gc.DrawRect(rect4); TRgb colors[2] = {KRgbRed, KRgbGreen}; // change brush color gc.MapColors(rect4,colors,1,ETrue); break; } default: gc.DrawRect(rect); } // End drawing gc.Deactivate(); window.EndRedraw(); iTestCaseFrameCount++; }
void wxSheetCellBitmapRendererRefData::AlignBmpTextRects(const wxRect& rect, int bmp_align, int WXUNUSED(txt_align), int margin, wxRect& bmpRect, wxRect& txtRect) { bool txt1st = ((bmp_align & wxSHEET_BMPREN_BMPRIGHT) != 0) || ((bmp_align & wxSHEET_BMPREN_BMPBELOW) != 0); bool expand1st = (!txt1st && ((bmp_align & wxSHEET_BMPREN_BMPEXPAND) != 0)) || ( txt1st && ((bmp_align & wxSHEET_BMPREN_BMPEXPAND) == 0)); wxSize size1(txt1st ? txtRect.GetSize() : bmpRect.GetSize()); wxSize size2(txt1st ? bmpRect.GetSize() : txtRect.GetSize()); wxRect rect1(rect); wxRect rect2(rect); if (((bmp_align & wxSHEET_BMPREN_BMPABOVE) != 0) || ((bmp_align & wxSHEET_BMPREN_BMPBELOW) != 0)) { // too tall if (size1.y + size2.y + margin > rect.height) { rect1.height = size1.y + 1; // only push second to bottom if it doesn't fall off if (size2.y < rect.height) { rect2.y = rect.GetBottom() - size2.y - 1; rect2.height = size2.y; } } else // fits within rect { // 1st will take any extra area, else pin to edge if (expand1st) { rect1.height -= size2.y + margin; rect2.y = rect1.GetBottom() + margin + 1; rect2.height = size2.y + 1; } else { rect1.height = size1.y + 1; rect2.y = rect1.GetBottom() + margin + 1; rect2.height = rect.GetBottom() - rect2.y + 1; } } } else // RIGHT or LEFT { // too wide if (size1.x + size2.x + margin > rect.width) { rect1.width = size1.x + 1; // only push second to right if it doesn't fall off if (size2.x < rect.width) { rect2.x = rect.GetRight() - size2.x - 1; rect2.width = size2.x; } } else // fits within rect { // 1st will take any extra area, else pin to edge if (expand1st) { rect1.width -= size2.x + margin; rect2.x = rect1.GetRight() + margin + 1; rect2.width = size2.x + 1; } else { rect1.width = size1.x + 1; rect2.x = rect1.GetRight() + margin + 1; rect2.width = rect.GetRight() - rect2.x + 1; } } } txtRect = txt1st ? rect1 : rect2; bmpRect = txt1st ? rect2 : rect1; }
static void drawEpipolarLines(const std::string& title, const cv::Matx<T1,3,3> F, const cv::Mat& img1, const cv::Mat& img2, const std::vector<cv::Point_<T2>> points1, const std::vector<cv::Point_<T2>> points2, const float inlierDistance = -1) { CV_Assert(img1.size() == img2.size() && img1.type() == img2.type()); cv::Mat outImg(img1.rows, img1.cols*2, CV_8UC3); cv::Rect rect1(0,0, img1.cols, img1.rows); cv::Rect rect2(img1.cols, 0, img1.cols, img1.rows); /* * Allow color drawing */ if (img1.type() == CV_8U) { cv::cvtColor(img1, outImg(rect1), CV_GRAY2BGR); cv::cvtColor(img2, outImg(rect2), CV_GRAY2BGR); } else { img1.copyTo(outImg(rect1)); img2.copyTo(outImg(rect2)); } std::vector<cv::Vec<T2,3>> epilines1, epilines2; cv::computeCorrespondEpilines(points1, 1, F, epilines1); //Index starts with 1 cv::computeCorrespondEpilines(points2, 2, F, epilines2); CV_Assert(points1.size() == points2.size() && points2.size() == epilines1.size() && epilines1.size() == epilines2.size()); cv::RNG rng(0); for(size_t i=0; i<points1.size(); i++) { if(inlierDistance > 0) { if(distancePointLine(points1[i], epilines2[i]) > inlierDistance || distancePointLine(points2[i], epilines1[i]) > inlierDistance) { //The point match is no inlier continue; } } /* * Epipolar lines of the 1st point set are drawn in the 2nd image and vice-versa */ cv::Scalar color(rng(256),rng(256),rng(256)); cv::line(outImg(rect2), cv::Point(0,-epilines1[i][2]/epilines1[i][1]), cv::Point(img1.cols,-(epilines1[i][2]+epilines1[i][0]*img1.cols)/epilines1[i][1]), color); cv::circle(outImg(rect1), points1[i], 3, color, -1, CV_AA); cv::line(outImg(rect1), cv::Point(0,-epilines2[i][2]/epilines2[i][1]), cv::Point(img2.cols,-(epilines2[i][2]+epilines2[i][0]*img2.cols)/epilines2[i][1]), color); cv::circle(outImg(rect2), points2[i], 3, color, -1, CV_AA); } cv::imshow(title, outImg); cv::waitKey(1); }
void Procesadora :: recibir_imagen(const QImage& imagen ) { //qDebug() << Q_FUNC_INFO << QThread::currentThreadId(); // channels == 0 significa autodetección cv::Mat imagenmat= QtOcv::image2Mat(imagen); // std::vector<cv::Mat> images = <vector de imágenes en cv::Mat> // Definimos algunos tipos para que el código se lea mejor typedef std::vector<cv::Mat> ImagesType; typedef std::vector<std::vector<cv::Point> > ContoursType; // Instancia de la clase del sustractor de fondo // cv::BackgroundSubtractorMOG2(history=500, // varThreshold=16, // bShadowDetection=true) // Sustracción del fondo: // 1. El objeto sustractor compara la imagen en i con su // estimación del fondo y devuelve en foregroundMask una // máscara (imagen binaria) con un 1 en los píxeles de // primer plano. // 2. El objeto sustractor actualiza su estimación del fondo // usando la imagen en i. cv::Mat foregroundMask; backgroundSubtractor(imagenmat, foregroundMask); // Operaciones morfolóficas para eliminar las regiones de // pequeño tamaño. Erode() las encoge y dilate() las vuelve a // agrandar. cv::erode(foregroundMask, foregroundMask, cv::Mat()); cv::dilate(foregroundMask, foregroundMask, cv::Mat()); // Obtener los contornos que bordean las regiones externas // (CV_RETR_EXTERNAL) encontradas. Cada contorno es un vector // de puntos y se devuelve uno por región en la máscara. ContoursType contours; cv::findContours(foregroundMask, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); //Qvect vector cv::Rect rect; QVector<QRect> vector_rectangulo; qRegisterMetaType< QVector<QRect> >("QVector<QRect>"); for( ContoursType::const_iterator i = contours.begin() ; i < contours.end(); i++){ rect = cv::boundingRect(*i); QRect rect1(rect.x, rect.y,rect.width, rect.height); vector_rectangulo.push_back(rect1); } // Aquí va el código ódigo que usa los contornos encontrados... // P. ej. usar para obtener el cuadro // delimitador de cada uno y pintarlo en la imagen original emit devolver_senal(imagen,vector_rectangulo); // se devuelve la imagen y el vector de rectangulos }
void CLineNode::InsertMMLFormulaNode_MTABLE_readAttr( AST_TXML_Tag *node, CFormulaNode *new_node ) { struct HMathMLAttr mml_attr( _T(""), _T("") ); // not one of the predefined tokens mml_attr.set( ::getCurrentFormulatorStyle().getUnit2PX(), node, _T("") /*has no body*/ ); mml_attr.accountAttr( FBL_ATTR_align ); mml_attr.accountAttr( FBL_ATTR_columnalign ); mml_attr.accountAttr( FBL_ATTR_rowalign ); new_node->CNodeInfo_Property::setUnfilteredAttr( mml_attr ); AST_TXML_Attribute *tblAttr = 0; long i, j, idx; tblAttr = node->getAttribute( FBL_ATTR_align ); if( tblAttr && tblAttr->getStringValue().length() > 0 ) { idx = -1; i = 0; QString tmp = _T(""), body = tblAttr->getStringValue(); do { while( i < body.length() && body.at(i).isSpace() ) i++; while( i < body.length() && body.at(i).isLetter() ) { tmp.append( body.at(i) ); i++; } if( tmp.length() == 0 ) break; while( i < body.length() && body.at(i).isSpace() ) i++; if( i >= body.length() ) break; if( !(body.at(i).isDigit() || body.at(i) == QChar('-')) ) break; LSDigit ldigit; long result = ldigit.Analisys( body.midRef(i) ); if( result != LSDigit::Integer ) break; if( ldigit.mnt_int >= 1 && ((long) ldigit.mnt_int) <= new_node->GetNumLine() ) { if( ldigit.asign < 0 ) idx = (new_node->GetNumLine() - ldigit.mnt_int) * new_node->GetNumColumn(); else idx = (ldigit.mnt_int - 1) * new_node->GetNumColumn(); } } while( 0 ); if( tmp == FBL_VAL_top ) new_node->setSpecialVerticalCenter( FBtnChildPos::TableTop2Baseline, idx + 1 ); else if( tmp == FBL_VAL_bottom ) new_node->setSpecialVerticalCenter( FBtnChildPos::TableBottom2Baseline, idx + 1 ); else if( tmp == FBL_VAL_center || tmp == FBL_VAL_baseline ) new_node->setSpecialVerticalCenter( FBtnChildPos::TableCenter2Baseline, idx + 1 ); else new_node->setSpecialVerticalCenter( FBtnChildPos::TableAxis, idx + 1 ); } std::vector<long> vAlign, hAlign; long v = TO_BASELINE, h = HORISONTAL_CENTER; ::bb_read_attr_align_horizontal( node, FBL_ATTR_columnalign, hAlign, h ); ::bb_read_attr_align_vertical( node, FBL_ATTR_rowalign, vAlign, v ); if( hAlign.size() > 0 ) h = hAlign[ hAlign.size() - 1 ]; if( vAlign.size() > 0 ) v = vAlign[ vAlign.size() - 1 ]; vAlign.resize( new_node->GetNumLine(), v ); hAlign.resize( new_node->GetNumColumn(), h ); long effV, cellEffV, cellEffH; AST_TXML_Tag *mtr = 0, *mtd = 0; idx = 0; for( i = 0; i < new_node->GetNumLine() && i < (long) vAlign.size(); i++ ) { mtr = ::mml_get_table_tag_mtr( node, i ); std::vector<long> hRowAlign; long rowH = LONG_MAX; ::bb_read_attr_align_horizontal( mtr, FBL_ATTR_columnalign, hRowAlign, LONG_MAX ); if( hRowAlign.size() > 0 ) rowH = hRowAlign[ hRowAlign.size() - 1 ]; hRowAlign.resize( hAlign.size(), rowH ); for( j = 0; j < (long) hRowAlign.size() && j < (long) hAlign.size(); j++ ) if( hRowAlign[ j ] == LONG_MAX ) hRowAlign[ j ] = hAlign[ j ]; effV = LONG_MAX; ::bb_read_attr_align_vertical( mtr, FBL_ATTR_rowalign, effV ); if( effV == LONG_MAX ) effV = vAlign[ i ]; for( j = 0; j < new_node->GetNumColumn() && j < (long) hAlign.size(); j++ ) { mtd = ::mml_get_table_tag_mtd( node, i, j ); cellEffH = LONG_MAX; ::bb_read_attr_align_horizontal( mtd, FBL_ATTR_columnalign, cellEffH ); if( cellEffH == LONG_MAX ) cellEffH = hRowAlign[ j ]; cellEffV = LONG_MAX; ::bb_read_attr_align_vertical( mtd, FBL_ATTR_rowalign, cellEffV ); if( cellEffV == LONG_MAX ) cellEffV = effV; Q_ASSERT( cellEffV != LONG_MAX && cellEffH != LONG_MAX ); new_node->SetChildFrameAlignType( idx, cellEffV | cellEffH ); idx++; } } std::vector<FBtnGraphics> frameLine; RealFde x0 = 0.0; RealFde y0 = 0.0; RealFde x100 = -1;//HF_BINBUTTON_VERTICAL_SCALE; RealFde y100 = -1;//HF_BINBUTTON_VERTICAL_SCALE; tblAttr = node->getAttribute( FBL_ATTR_frame ); if( tblAttr && tblAttr->getStringValue().length() > 0 ) { int penStyle = -1; if( tblAttr->getStringValue() == FBL_VAL_solid ) penStyle = Qt::SolidLine; else if ( tblAttr->getStringValue() == FBL_VAL_dashed ) penStyle = Qt::DashLine; if( penStyle != -1 ) { FBtnGraphics oneLine; RectFde rect1( PointFde(x0, y0), PointFde(x100, y0) ); RectFde rect2( PointFde(x100, y0), PointFde(x100, y100) ); RectFde rect3( PointFde(x100, y100), PointFde(x0, y100) ); RectFde rect4( PointFde(x0, y100), PointFde(x0, y0) ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyle, rect1 ); frameLine.push_back( oneLine ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyle, rect2 ); frameLine.push_back( oneLine ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyle, rect3 ); frameLine.push_back( oneLine ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyle, rect4 ); frameLine.push_back( oneLine ); } } RealFde pos; std::vector<long> penStyleList; if( new_node->GetNumLine() > 1 ) { ::bb_read_attr_table_lines( node, FBL_ATTR_rowlines, penStyleList ); if( penStyleList.size() > 0 ) { penStyleList.resize( new_node->GetNumLine() - 1, penStyleList[ penStyleList.size() - 1 ] ); FBtnGraphics oneLine; for( i = 0; i < (long) penStyleList.size(); i++ ) { RectFde rc( x0, 0.0, x100, 0.0 ); if( penStyleList[ i ] == -1 ) continue; pos = new_node->GetSlot( i * new_node->GetNumColumn() ).GetPecentPosition().bottom(); pos += new_node->GetSlot( (i + 1) * new_node->GetNumColumn() ).GetPecentPosition().top(); rc.setTop( pos / 2.0 ); rc.setBottom( pos / 2.0 ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyleList[ i ], rc ); frameLine.push_back( oneLine ); } } } if( new_node->GetNumColumn() > 1 ) { ::bb_read_attr_table_lines( node, FBL_ATTR_columnlines, penStyleList ); if( penStyleList.size() > 0 ) { penStyleList.resize( new_node->GetNumColumn() - 1, penStyleList[ penStyleList.size() - 1 ] ); FBtnGraphics oneLine; for( i = 0; i < (long) penStyleList.size(); i++ ) { RectFde rc( 0.0, y0, 0.0, y100 ); if( penStyleList[ i ] == -1 ) continue; pos = new_node->GetSlot( i ).GetPecentPosition().left(); pos += new_node->GetSlot( i + 1 ).GetPecentPosition().right(); rc.setLeft( pos / 2.0 ); rc.setRight( pos / 2.0 ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyleList[ i ], rc ); frameLine.push_back( oneLine ); } } } if( frameLine.size() > 0 ) { CGraphPrimFormula *primList = new CGraphPrimFormula[ frameLine.size() ]; new_node->FlushAltGroup(); for( i = 0; i < (long) frameLine.size(); i++ ) { primList[ i ].Create( frameLine[ i ] ); new_node->AddAltGroup( frameLine[ i ].altGroup ); } new_node->CreateGraphPrimIndirect( (int) frameLine.size(), primList ); delete[] primList; } }
// The start of the Application int Raycasting::start(const std::vector<std::string> &args) { //Remove the need to send physic world to every object. Instead send just the description. //Fix having two fixtures working weirdly. quit = false; int window_x_size = 640; int window_y_size = 480; // Set the window DisplayWindowDescription desc; desc.set_title("ClanLib Raycasting Example"); desc.set_size(Size(window_x_size, window_y_size), true); desc.set_allow_resize(false); DisplayWindow window(desc); // Connect the Window close event Slot slot_quit = window.sig_window_close().connect(this, &Raycasting::on_window_close); // Connect a keyboard handler to on_key_up() Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &Raycasting::on_input_up); // Create the canvas Canvas canvas(window); //Setup physic world PhysicsWorldDescription phys_desc; phys_desc.set_gravity(0.0f,10.0f); phys_desc.set_sleep(true); phys_desc.set_physic_scale(100); phys_desc.set_timestep(1.0f/200.0f); PhysicsWorld phys_world(phys_desc); //Get the Physics Context PhysicsContext pc = phys_world.get_pc(); //Setup ground body BodyDescription ground_desc(phys_world); ground_desc.set_position(Vec2f((float)window_x_size/2.0f,(float)window_y_size)); ground_desc.set_type(body_static); Body ground(pc, ground_desc); //Setup ground fixture PolygonShape ground_shape(phys_world); ground_shape.set_as_box((float)window_x_size/2,20.0f); FixtureDescription fixture_desc(phys_world); fixture_desc.set_shape(ground_shape); Fixture ground_fixture(pc, ground, fixture_desc); //Setup box body BodyDescription box_desc(phys_world); box_desc.set_position(Vec2f(10.0f,10.0f)); box_desc.set_type(body_dynamic); box_desc.set_linear_velocity(Vec2f(100.0f,0.0f)); Body box(pc, box_desc); box_desc.set_position(Vec2f((float)window_x_size-50.0f,100.0f)); box_desc.set_linear_velocity(Vec2f(-80.0f,0.0f)); Body box2(pc, box_desc); //Setup box fixture PolygonShape box_shape(phys_world); box_shape.set_as_box(30.0f, 30.0f); FixtureDescription fixture_desc2(phys_world); fixture_desc2.set_shape(box_shape); fixture_desc2.set_restitution(0.6f); fixture_desc2.set_friction(0.0005f); Fixture box_fixture(pc, box, fixture_desc2); Fixture box_fixture2(pc, box2, fixture_desc2); Vec2f ground_pos = ground.get_position(); unsigned int last_time = System::get_time(); //Setup debug draw. PhysicsDebugDraw debug_draw(phys_world); debug_draw.set_flags(f_shape|f_aabb); GraphicContext gc = canvas.get_gc(); PhysicsQueryAssistant qa = phys_world.get_qa(); clan::Font font(canvas, "Tahoma", 12); // Set raycast points Pointf p1(300,500); Pointf p2(100,100); // Set query rect; Rectf rect1(400.0f, 380.0f, Sizef(50.0f,50.0f)); // Run until someone presses escape while (!quit) { unsigned int current_time = System::get_time(); float time_delta_ms = static_cast<float> (current_time - last_time); last_time = current_time; canvas.clear(); //Raycast font.draw_text(canvas, 10,20, "Raycasting..."); qa.raycast_first(p1, p2); if(qa.has_query_result()) { font.draw_text(canvas, 100,20, "Found object !"); canvas.draw_line(p1,p2, Colorf::green); } else canvas.draw_line(p1, p2, Colorf::red); //Raycast //Query font.draw_text(canvas, 10,35, "Querying..."); qa.query_any(rect1); if(qa.has_query_result()) { font.draw_text(canvas, 100,35, "Found object !"); canvas.draw_box(rect1, Colorf::green); } else canvas.draw_box(rect1, Colorf::red); //Query phys_world.step(); debug_draw.draw(canvas); canvas.flush(); window.flip(1); // This call processes user input and other events KeepAlive::process(0); System::sleep(10); } return 0; }
void CalendarControl::Draw(BRect r) { #ifdef __UNIVERSAL_INTERFACE if(interface==CC_ZETA_INTERFACE) { #endif #ifdef __ZETA_INTERFACE BRect rect1(Bounds()); rect1.bottom--; rect1.right=pb->Frame().left-2; BRect rect2(rect1); BPoint p1, p2; rgb_color color; if(IsEnabled()) { if(dtvc->IsFocus() && wc) // window is active and control is focused // (control is enabled) { SetHighColor(170,50,184,0); StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); SetHighColor(255,255,255,0); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeLine(rect1.LeftBottom(),rect1.RightBottom()); StrokeLine(rect1.RightTop(),rect1.RightBottom()); SetHighColor(218,218,218,0); StrokeLine(rect1.LeftTop(),rect1.LeftBottom()); StrokeLine(rect1.LeftTop(),rect1.RightTop()); SetHighColor(114,114,114,0); StrokeLine(rect1.LeftTop(),rect1.LeftTop()); StrokeLine(rect1.LeftBottom(),rect1.LeftBottom()); StrokeLine(rect1.RightTop(),rect1.RightTop()); StrokeLine(rect1.RightBottom(),rect1.RightBottom()); // outward borders color.red=170+(uint8)((229-170)*(view_color.red-170)/(255-170)); color.green=50+(uint8)((194-50)*(view_color.green-50)/(255-50)); color.blue=184+(uint8)((233-184)*(view_color.blue-184)/(255-184)); color.alpha=255; SetHighColor(color); p1.Set(rect2.left,rect2.top+1); p2.Set(rect2.left+1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.top+1); p2.Set(rect2.right-1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.bottom-1); p2.Set(rect2.right-1,rect2.bottom); StrokeLine(p1,p2); p1.Set(rect2.left,rect2.bottom-1); p2.Set(rect2.left+1,rect2.bottom); StrokeLine(p1,p2); SetHighColor(view_color); StrokeLine(rect2.LeftTop(),rect2.LeftTop()); StrokeLine(rect2.LeftBottom(),rect2.LeftBottom()); StrokeLine(rect2.RightTop(),rect2.RightTop()); StrokeLine(rect2.RightBottom(),rect2.RightBottom()); } else // window is not active or control is unfocused (control is enabled) { SetHighColor(255,255,255,0); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1=rect2; SetHighColor(0,0,0,0); StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeLine(rect1.LeftTop(),rect1.LeftTop()); StrokeLine(rect1.LeftBottom(),rect1.LeftBottom()); StrokeLine(rect1.RightTop(),rect1.RightTop()); StrokeLine(rect1.RightBottom(),rect1.RightBottom()); SetHighColor(180,180,180,0); p1.Set(rect2.left+2,rect2.top+1); p2.Set(rect2.right-2,rect2.top+1); StrokeLine(p1,p2); p1.Set(rect2.left+1,rect2.top+2); p2.Set(rect2.left+1,rect2.bottom-2); StrokeLine(p1,p2); p1.Set(rect2.left+2,rect2.top+2); StrokeLine(p1,p1); SetHighColor(218,218,218,0); p1.Set(rect2.left+2,rect2.top+3); p2.Set(rect2.left+2,rect2.bottom-1); StrokeLine(p1,p2); p1.Set(rect2.left+3,rect2.top+2); p2.Set(rect2.right-1,rect2.top+2); StrokeLine(p1,p2); // outward borders color.red=(uint8)(218*view_color.red/255); color.green=(uint8)(218*view_color.green/255); color.blue=(uint8)(218*view_color.blue/255); color.alpha=255; SetHighColor(color); p1.Set(rect2.left,rect2.top+1); p2.Set(rect2.left+1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.top+1); p2.Set(rect2.right-1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.bottom-1); p2.Set(rect2.right-1,rect2.bottom); StrokeLine(p1,p2); p1.Set(rect2.left,rect2.bottom-1); p2.Set(rect2.left+1,rect2.bottom); StrokeLine(p1,p2); SetHighColor(view_color); StrokeLine(rect2.LeftTop(),rect2.LeftTop()); StrokeLine(rect2.LeftBottom(),rect2.LeftBottom()); StrokeLine(rect2.RightTop(),rect2.RightTop()); StrokeLine(rect2.RightBottom(),rect2.RightBottom()); } } else // control is disabled { if(dtvc->IsFocus() && wc) // window is active and control is focused // (control is disabled) { SetHighColor(255,255,255,0); rect1.left+=2; rect1.top+=2; rect1.right-=2; rect1.bottom-=2; StrokeRect(rect1); rect1=rect2; SetHighColor(231,198,235,0); StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeLine(rect1.LeftTop(),rect1.LeftTop()); StrokeLine(rect1.LeftBottom(),rect1.LeftBottom()); StrokeLine(rect1.RightTop(),rect1.RightTop()); StrokeLine(rect1.RightBottom(),rect1.RightBottom()); // outward borders color.red=231+(uint8)((251-231)*(view_color.red-231)/(255-231)); color.green=198+(uint8)((246-198)*(view_color.green-198)/(255-198)); color.blue=235+(uint8)((251-235)*(view_color.blue-235)/(255-235)); color.alpha=255; SetHighColor(color); p1.Set(rect2.left,rect2.top+1); p2.Set(rect2.left+1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.top+1); p2.Set(rect2.right-1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.bottom-1); p2.Set(rect2.right-1,rect2.bottom); StrokeLine(p1,p2); SetHighColor(view_color); p1.Set(rect2.left,rect2.bottom-1); p2.Set(rect2.left+1,rect2.bottom); StrokeLine(p1,p2); StrokeLine(rect2.LeftTop(),rect2.LeftTop()); StrokeLine(rect2.LeftBottom(),rect2.LeftBottom()); StrokeLine(rect2.RightTop(),rect2.RightTop()); StrokeLine(rect2.RightBottom(),rect2.RightBottom()); } else // window is not active or control is unfocused (control is disabled) { SetHighColor(255,255,255,0); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1=rect2; SetHighColor(185,185,185,0); StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeLine(rect1.LeftTop(),rect1.LeftTop()); StrokeLine(rect1.LeftBottom(),rect1.LeftBottom()); StrokeLine(rect1.RightTop(),rect1.RightTop()); StrokeLine(rect1.RightBottom(),rect1.RightBottom()); // outward borders color.red=185+(uint8)((245-185)*(view_color.red-185)/(255-185)); color.green=185+(uint8)((245-185)*(view_color.green-185)/(255-185)); color.blue=185+(uint8)((245-185)*(view_color.blue-185)/(255-185)); color.alpha=255; SetHighColor(color); p1.Set(rect2.left,rect2.top+1); p2.Set(rect2.left+1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.top+1); p2.Set(rect2.right-1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.bottom-1); p2.Set(rect2.right-1,rect2.bottom); StrokeLine(p1,p2); SetHighColor(view_color); p1.Set(rect2.left,rect2.bottom-1); p2.Set(rect2.left+1,rect2.bottom); StrokeLine(p1,p2); StrokeLine(rect2.LeftTop(),rect2.LeftTop()); StrokeLine(rect2.LeftBottom(),rect2.LeftBottom()); StrokeLine(rect2.RightTop(),rect2.RightTop()); StrokeLine(rect2.RightBottom(),rect2.RightBottom()); } } #endif #ifdef __UNIVERSAL_INTERFACE } else // interface==CC_BEOS_INTERFACE { #endif #ifdef __BEOS_INTERFACE BRect rect1(Bounds()),rect2(Bounds()); rect1.bottom--; rect1.right=pb->Frame().left-1; rect2.top++; rect2.left++; rect2.bottom-=2; rect2.right=rect1.right-1; if(IsEnabled()) SetHighColor(255,255,255,255); else SetHighColor(239,239,239,255); StrokeLine(rect1.LeftBottom(),rect1.RightBottom()); StrokeLine(rect1.RightTop(),rect1.RightBottom()); if(IsEnabled()) SetHighColor(184,184,184,0); else SetHighColor(216,216,216,0); StrokeLine(rect1.LeftTop(),rect1.RightTop()); StrokeLine(rect1.LeftTop(),rect1.LeftBottom()); if(dtvc->IsFocus() && wc) { SetHighColor(0,0,229,0); StrokeRect(rect2); } else { SetHighColor(216,216,216,0); StrokeLine(rect2.LeftBottom(),rect2.RightBottom()); StrokeLine(rect2.RightTop(),rect2.RightBottom()); if(IsEnabled()) SetHighColor(96,96,96,0); else SetHighColor(152,152,152,0); StrokeLine(rect2.LeftTop(),rect2.RightTop()); StrokeLine(rect2.LeftTop(),rect2.LeftBottom()); } if(IsEnabled()) SetHighColor(255,255,255,255); else SetHighColor(239,239,239,255); rect2.top++; rect2.left++; rect2.right--; rect2.bottom--; StrokeRect(rect2); #endif #ifdef __UNIVERSAL_INTERFACE } #endif }
static void draw_graph( QPainter &painter, int w, /* width */ int h, /* height */ int margin, double *X, /* x-values */ double *Y, /* y-values */ unsigned int N /* number of X[], Y[] */ ) { if ((w <= 3*margin) || (h <= 2*margin)) return; /* Qt coordinate system */ int x0 = 2*margin; int x1 = w - margin; int y0 = margin; int y1 = h - margin; if (x0 >= x1) return; if (y0 >= y1) return; /* draw boundary rectangle */ QRectF rectangle(x0, y0, x1-x0, y1-y0); painter.drawRect(rectangle); if (!X || !Y || !N) return; double Ymin = 0.0; double Ymax = 1.0; double Xmin = X[0]; double Xmax = X[0]; for(uint32_t i=1; i < N; i++) { double x = X[i]; if (x < Xmin) Xmin = x; if (x > Xmax) Xmax = x; } if ((Xmax > Xmin) && (Ymax > Ymin)) { /* allocate */ QPoint **points = (QPoint **) malloc(N*sizeof(QPoint *)); /* convert to qt coordinate system */ for(uint32_t i=0; i < N; i++) { int x = (int) (x0 + (x1 - x0) * (X[i] - Xmin) / (Xmax - Xmin)); int y = (int) (y1 - (y1 - y0) * (Y[i] - Ymin) / (Ymax - Ymin)); points[i] = new QPoint(x, y); } /* order along horizontal axis */ qsort((void *)points, N, sizeof(QPoint *), qpoint_cmp); /* draw line */ for(uint32_t i=0; i+1 < N; i++) painter.drawLine(*points[i], *points[i+1]); int labelwidth = 3*margin/2; int labelheight = margin; const char *labelfmtX = "%.0f"; const char *labelfmtY = "%.2f"; char label[32]; uint32_t labelsz = sizeof(label) - 1; /* draw horizontal labels */ snprintf(label, labelsz, labelfmtX, Xmin); QString XminStr = label; QRectF rect0(x0-labelwidth/2, y1, labelwidth, labelheight); painter.drawText(rect0, Qt::AlignCenter, XminStr); snprintf(label, labelsz, labelfmtX, Xmax); QString XmaxStr = label; QRectF rect1(x1-labelwidth/2, y1, labelwidth, labelheight); painter.drawText(rect1, Qt::AlignCenter, XmaxStr); /* draw vertical labels */ snprintf(label, labelsz, labelfmtY, Ymin); QString YminStr = label; QRectF rect2(x0-labelwidth, y1-labelheight/2, labelwidth, labelheight); painter.drawText(rect2, Qt::AlignCenter, YminStr); snprintf(label, labelsz, labelfmtY, Ymax); QString YmaxStr = label; QRectF rect3(x0-labelwidth, y0-labelheight/2, labelwidth, labelheight); painter.drawText(rect3, Qt::AlignCenter, YmaxStr); /* clean up */ for(uint32_t i=0; i < N; i++) delete points[i]; free(points); } else if ((Xmin == Xmax) && (Ymin == Ymax)) { /* draw point */ } else if (Xmin == Xmax) { /* draw vertical line */ } else if (Ymin == Ymax) { /* draw horizontal line */ } }
static bool TestIntersects() { RectType rect1(10, 10, 50, 50); RectType rect2(rect1); // Test against a rect that's the same as rect1 EXPECT_FALSE(!rect1.Intersects(rect2)) << "[1] Test against a rect that's the same as rect1"; // Test against a rect that's enclosed by rect1 rect2.Inflate(-1, -1); EXPECT_FALSE(!rect1.Contains(rect2) || !rect1.Intersects(rect2)) << "[2] Test against a rect that's enclosed by rect1"; rect2.Inflate(1, 1); // Make sure inflate and deflate worked correctly EXPECT_TRUE(rect1.IsEqualInterior(rect2)) << "[3] Make sure inflate and deflate worked correctly"; // Test against a rect that overlaps the left edge of rect1 rect2.x--; EXPECT_FALSE(!rect1.Intersects(rect2)) << "[4] Test against a rect that overlaps the left edge of rect1"; rect2.x++; // Test against a rect that's outside of rect1 on the left rect2.x -= rect2.width; EXPECT_FALSE(rect1.Intersects(rect2)) << "[5] Test against a rect that's outside of rect1 on the left"; rect2.x += rect2.width; // Test against a rect that overlaps the top edge of rect1 rect2.y--; EXPECT_FALSE(!rect1.Intersects(rect2)) << "[6] Test against a rect that overlaps the top edge of rect1"; rect2.y++; // Test against a rect that's outside of rect1 on the top rect2.y -= rect2.height; EXPECT_FALSE(rect1.Intersects(rect2)) << "[7] Test against a rect that's outside of rect1 on the top"; rect2.y += rect2.height; // Test against a rect that overlaps the right edge of rect1 rect2.x++; EXPECT_FALSE(!rect1.Intersects(rect2)) << "[8] Test against a rect that overlaps the right edge of rect1"; rect2.x--; // Test against a rect that's outside of rect1 on the right rect2.x += rect2.width; EXPECT_FALSE(rect1.Intersects(rect2)) << "[9] Test against a rect that's outside of rect1 on the right"; rect2.x -= rect2.width; // Test against a rect that overlaps the bottom edge of rect1 rect2.y++; EXPECT_FALSE(!rect1.Intersects(rect2)) << "[10] Test against a rect that overlaps the bottom edge of rect1"; rect2.y--; // Test against a rect that's outside of rect1 on the bottom rect2.y += rect2.height; EXPECT_FALSE(rect1.Intersects(rect2)) << "[11] Test against a rect that's outside of rect1 on the bottom"; rect2.y -= rect2.height; return true; }