MBOOL StereoNodeImpl:: onStart() { FUNC_START; MBOOL ret = MFALSE; MSize rgbSize = getRgbImgSize(); vector<HwPortConfig_t> lHwPortCfg; HwPortConfig_t cfgImg = { mapToPortID(STEREO_IMG), eImgFmt_YV12, getAlgoImgSize(), MRect( MPoint(0, 0), getAlgoImgSize() ) }; HwPortConfig_t cfgRgb = { mapToPortID(STEREO_RGB), eImgFmt_ARGB8888, rgbSize, MRect( MPoint(0, 0), rgbSize ) }; // if( !setupPort(mbCfgImgo, mbCfgFeo, mbCfgRgb ) ) goto lbExit; // if ( mbCfgImgo ) lHwPortCfg.push_back(cfgImg); // if ( mbCfgRgb ) lHwPortCfg.push_back(cfgRgb); // CAM_TRACE_BEGIN("alloc"); if( !allocBuffers(lHwPortCfg) ) { MY_LOGE("alloc buffers failed"); goto lbExit; } CAM_TRACE_END(); // muPostFrameCnt = 0; muEnqFrameCnt = 0; muDeqFrameCnt = 0; // ret = MTRUE; lbExit: FUNC_END; return ret; }
void MScrollView::SetCtrlInfo( HWND hwndCtrl, const MPoint& ptCtrl, const MSize& sizCtrl) { assert(::IsWindow(hwndCtrl)); assert(HasChildStyle(hwndCtrl)); assert(ptCtrl.x >= 0); assert(ptCtrl.y >= 0); MScrollCtrlInfo* info = FindCtrlInfo(hwndCtrl); if (info) info->m_rcCtrl = MRect(ptCtrl, sizCtrl); else AddCtrlInfo(hwndCtrl, ptCtrl, sizCtrl); }
/***************************************************** ** ** BasicVedicChart --- drawSingleGraphicItem ** ******************************************************/ void BasicVedicChart::drawSingleGraphicItem( const MRect &rect, const ChartGraphicItem &g, const FIELD_PART &part ) { VedicChartConfig *vconf = getVChartConfig(); const wxChar retroSymbol = SymbolProvider().getRetroCode( MD_RETROGRADE ); if ( vconf->textColor.IsOk()) { painter->setTextColor( vconf->textColor ); } else if ( chartprops->getVedicChartDisplayConfig().showPlanetColors ) { painter->setTextColor( vconf->getPlanetColor( g.pindex )); } else { setDefaultTextColor( part ); } //setDefaultTextColor(); painter->drawTextFormatted( rect, g.name, Align::Center ); if ( g.retro ) painter->drawTextFormatted( MRect( rect.x + text_width, rect.y+text_height/3, rect.width, rect.height ), retroSymbol, Align::Center); }
/***************************************************** ** ** BasicVedicChart --- paintOuterRectangle ** ******************************************************/ void BasicVedicChart::paintOuterRectangle() { VedicChartConfig *vconf = getVChartConfig(); if ( ! vconf->outerRectangle.show ) return; painter->setPen( vconf->outerRectangle.pen.IsOk() ? vconf->outerRectangle.pen : defaultPen ); if ( vconf->outerRectangle.brush.IsOk() ) painter->setBrush( vconf->outerRectangle.brush ); else painter->setTransparentBrush(); MRect coord( xcenter - xr, ycenter - yr, 2 * xr, 2 * yr ); painter->drawRectangle( coord, .01 * Min( xmax, ymax ) * vconf->outerRectangle.cornerRadius ); if ( vconf->outerRectangle.doubleOuterLine ) { // distance of second frame: derive from rmax -> prevent scaling errors in pdf output const double delta = rmax / 100.0; painter->drawRectangle( MRect( coord.x - delta, coord.y - delta, coord.width + 2 * delta, coord.height + 2 * delta )); } painter->setPen( defaultPen ); }
/******************************************************************************* * Config CamIO Pipe /floria ********************************************************************************/ int Ts_UT:: main_ts_IOPipe_ZSD(int count) { // int count = 1000; //enque, deque loop iterations printf("[iopipetest] E\n"); //for Enqueue, raw buf MUINT32 u4RawBufSize = (u4SensorWidth * u4SensorHeight * 2 + L1_CACHE_BYTES-1) & ~(L1_CACHE_BYTES-1); //for buffer per frame int BufIdx = BUF_NUM, nCt = BUF_NUM; #ifdef USE_IMAGEBUF_HEAP MUINT32 bufStridesInBytes[3] = {1600, 0, 0}; MINT32 bufBoundaryInBytes[3] = {0, 0, 0}; #endif #if 0 ringbuffer* mpRingImgo = new ringbuffer( 2,//PASS1_FULLRAW PORT_IMGO, 0//fakeResized ? PASS1_RESIZEDRAW : 0 ); #endif MY_LOGD("+"); /*------------------------------ * (1) Create Instance *-----------------------------*/ /* eScenarioID_VSS, eScenarioFmt_RAW */ MUINT mSensorIdx = 0;//0:MAIN const char Name = '1'; MUINT mIspEnquePeriod = 1; prepareSensor();//test IHalSensor printf("[iopipetest] INormalPipe::createInstance\n"); mpCamIO = (INormalPipe*)INormalPipe::createInstance(mSensorIdx, &Name, mIspEnquePeriod); #if 0//camera 3.0, should create INormalPipe_FrmB class instance mpCamIO = (IHalCamIO*)INormalPipe_FrmB::createInstance(mSensorIdx, &Name, mIspEnquePeriod); #endif /*------------------------------ test 3A build pass ------------------------------*/ #if 0 MINT32 handle; MBOOL fgRet = mpCamIO->sendCommand(NSImageio_FrmB::NSIspio_FrmB::EPIPECmd_GET_MODULE_HANDLE, NSImageio_FrmB::NSIspio_FrmB::EModule_AF, (MINT32)&handle, (MINT32)(&("AFMgr::setFlkWinConfig()"))); MINT32 wintmp; IOPIPE_SET_MODUL_REG(handle, CAM_AF_WINX01, wintmp); #endif /*------------------------------ * (2) init *-----------------------------*/ printf("[iopipetest] mpCamIO->init\n"); if(!mpCamIO->init()) { printf("[iopipetest] mpCamIO->init failed!!\n"); } /*------------------------------ * (3). Config pipe + RAW10 *-----------------------------*/ MSize mDstSize; mDstSize.w = u4SensorWidth; mDstSize.h = u4SensorHeight; //prepare sensor config vector<IHalSensor::ConfigParam> vSensorCfg; IHalSensor::ConfigParam sensorCfg = { mSensorIdx, /* index */ mDstSize, /* crop no reference in NormalPipe */ u4Scenario, /* scenarioId */ 0, /* isBypassScenario */ 1, /* isContinuous */ 0, /* iHDROn */ 0, /* framerate */ 0, /* two pixel on */ 0, /* debugmode */ }; vSensorCfg.push_back(sensorCfg); printf("[iopipetest] sensor %dx%d, sce %d, bypass %d, con %d, hdr %d, fps %d, twopxl %d\n", sensorCfg.crop.w, sensorCfg.crop.h, sensorCfg.scenarioId, sensorCfg.isBypassScenario, sensorCfg.isContinuous, sensorCfg.HDRMode, sensorCfg.framerate, sensorCfg.twopixelOn); // vector<portInfo> vPortInfo; // portInfo OutPort( PORT_IMGO, eImgFmt_BAYER10, mDstSize, //dst size 0, //pPortCfg->mCrop, //crop u4SensorWidth, //pPortCfg->mStrideInByte[0], 0, //pPortCfg->mStrideInByte[1], 0, //pPortCfg->mStrideInByte[2], 0, // pureraw MTRUE //packed ); vPortInfo.push_back(OutPort); printf("[iopipetest] config portID(0x%x), fmt(%u), size(%dx%d), crop(%u,%u,%u,%u)\n", OutPort.mPortID, OutPort.mFmt, OutPort.mDstSize.w, OutPort.mDstSize.h, OutPort.mCropRect.p.x, OutPort.mCropRect.p.y, OutPort.mCropRect.s.w, OutPort.mCropRect.s.h); printf("[iopipetest] stride(%u,%u,%u), pureRaw(%u), pack(%d)\n", OutPort.mStride[0], OutPort.mStride[1], OutPort.mStride[2], OutPort.mPureRaw, OutPort.mPureRawPak); // QInitParam halCamIOinitParam( 0, u4Bitdepth, vSensorCfg, vPortInfo); printf("[iopipetest] mpCamIO->configPipe\n"); if(!mpCamIO->configPipe(halCamIOinitParam, eScenarioID_VSS)) { printf("[iopipetest] mpCamIO->configPipe failed!!\n"); goto TEST_EXIT; } /*------------------------------ * (4). Enqueue * 4.1, raw buf *-----------------------------*/ #ifdef _USE_THREAD_QUE_ if(vRawMem.size() > 0) { freeRawMem(); TS_Thread_UnInit(); } nCt--; #else // int nReplace; printf("*****************************************\n"); printf("Buffer per frame(1:y; else:n)\n"); scanf("%d", &nReplace); printf("*****************************************\n"); if(nReplace != 1) { nCt--; } #endif /* * * * * * * * * * * * * buffer per frame * nReplace = 1 * size = BUF_NUM + 1 *(replace buffer) * * * * * * * * * * * * * sequential buffer * nReplace != 1 * size = BUF_NUM *(no replace buffer) * * * * * * * * * * * */ printf("[iopipetest] allocMem: RawBuff\n"); for (int i = 0; i <= nCt; i++) //BUF_NUM=3 { IMEM_BUF_INFO rBuf; rBuf.size = u4RawBufSize; allocMem(rBuf); #ifdef USE_IMAGEBUF_HEAP PortBufInfo_v1 portBufInfo = PortBufInfo_v1( rBuf.memID,rBuf.virtAddr,0,rBuf.bufSecu, rBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam = IImageBufferAllocator::ImgParam((eImgFmt_BAYER10), MSize(1280, 720), bufStridesInBytes, bufBoundaryInBytes, 1); sp<ImageBufferHeap> pHeap = ImageBufferHeap::create( LOG_TAG, imgParam,portBufInfo,MTRUE); IImageBuffer* tempBuffer = pHeap->createImageBuffer(); tempBuffer->incStrong(tempBuffer); tempBuffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); // BufInfo rBufInfo; rBufInfo.mPortID = PORT_IMGO; rBufInfo.mBuffer = tempBuffer; rBufInfo.FrameBased.mMagicNum_tuning = 0; rBufInfo.FrameBased.mDstSize = mDstSize; rBufInfo.FrameBased.mCropRect = MRect(MPoint(0, 0), mDstSize);//no crop rRawBuf.mvOut.push_back(rBufInfo); #endif vRawMem.push_back(rBuf); printf("[iopipetest] vRawMem(%d)PA(0x%x)VA(0x%x)\n", i, vRawMem.at(i).phyAddr,vRawMem.at(i).virtAddr); } //for deque for (int i = 0; i <= 0; i++) { IMEM_BUF_INFO rBuf; rBuf.size = u4RawBufSize; allocMem(rBuf); #ifdef USE_IMAGEBUF_HEAP PortBufInfo_v1 portBufInfo = PortBufInfo_v1( rBuf.memID,rBuf.virtAddr,0,rBuf.bufSecu, rBuf.bufCohe); IImageBufferAllocator::ImgParam imgParam = IImageBufferAllocator::ImgParam((eImgFmt_BAYER10), MSize(1280, 720), bufStridesInBytes, bufBoundaryInBytes, 1); sp<ImageBufferHeap> pHeap = ImageBufferHeap::create( LOG_TAG, imgParam,portBufInfo,MTRUE); IImageBuffer* tempBuffer = pHeap->createImageBuffer(); tempBuffer->incStrong(tempBuffer); tempBuffer->lockBuf(LOG_TAG,eBUFFER_USAGE_HW_CAMERA_READWRITE | eBUFFER_USAGE_SW_READ_OFTEN); // BufInfo rBufInfo; rBufInfo.mPortID = PORT_IMGO; rBufInfo.mBuffer = tempBuffer; rDequeBuf.mvOut.push_back(rBufInfo); #endif vDequeMem.push_back(rBuf); printf("[iopipetest] vDequeMem(%d)PA(0x%x)VA(0x%x)\n", i, vDequeMem.at(i).phyAddr, vDequeMem.at(i).virtAddr); } /* enque 3 buffers */ for (int i = 0; i < BUF_NUM; i++) { #if 1 QBufInfo rInBuf; rInBuf.mvOut.clear(); #ifdef USE_IMAGEBUF_HEAP BufInfo rBufInfo(PORT_IMGO, rRawBuf.mvOut.at(i).mBuffer, rRawBuf.mvOut.at(i).mSize, rRawBuf.mvOut.at(i).mVa, rRawBuf.mvOut.at(i).mPa); #else BufInfo rBufInfo(PORT_IMGO, NULL, vRawMem.at(i).size, vRawMem.at(i).virtAddr, vRawMem.at(i).phyAddr); #endif rInBuf.mvOut.push_back(rBufInfo); rInBuf.mvOut.at(0).FrameBased.mMagicNum_tuning = 0; rInBuf.mvOut.at(0).FrameBased.mDstSize = mDstSize; rInBuf.mvOut.at(0).FrameBased.mCropRect = MRect(MPoint(0, 0), mDstSize);//no crop #ifdef USE_IMAGEBUF_HEAP printf("[iopipetest] enque.PA(0x%x)VA(0x%x)buf(0x%x)\n", rInBuf.mvOut.at(0).mBuffer->getBufPA(0), rInBuf.mvOut.at(0).mBuffer->getBufVA(0), rInBuf.mvOut.at(0).mBuffer); #else printf("[iopipetest] enque.PA(0x%x)VA(0x%x)\n", rInBuf.mvOut.at(0).mPa, rInBuf.mvOut.at(0).mVa); #endif printf("[iopipetest] enque(%d)\n", i); if(!mpCamIO->enque(rInBuf)) { printf("[iopipetest] enque failed!!\n"); goto TEST_EXIT; } #else /* * * * * * * * * * * * * * * * * * * * * * * * * * * test: * if enque a buffer,and it's port is not IMGO, * mpCamIO->enque(rRawBuf)will return MFALSE * * * * * * * * * * * * * * * * * * * * * * * * * */ QBufInfo rInBuf; rInBuf.mvOut.clear(); #ifdef USE_IMAGEBUF_HEAP BufInfo rBufInfo2(PORT_IMGO, rRawBuf.mvOut.at(i).mBuffer, rRawBuf.mvOut.at(i).mSize, rRawBuf.mvOut.at(i).mVa, rRawBuf.mvOut.at(i).mPa); #else BufInfo rBufInfo2(PORT_IMG2O, NULL, vRawMem.at(i).size, vRawMem.at(i).virtAddr, vRawMem.at(i).phyAddr); #endif rInBuf.mvOut.push_back(rBufInfo2); printf("[iopipetest] enque(%d)\n", i); if(!mpCamIO->enque(rInBuf)){//try to enque IMGO port printf("[iopipetest] enque(%d) again\n", i); rInBuf.mvOut.clear(); BufInfo rBufInfo(PORT_IMGO, NULL, vRawMem.at(i).size, vRawMem.at(i).virtAddr, vRawMem.at(i).phyAddr); rInBuf.mvOut.push_back(rBufInfo); if(!mpCamIO->enque(rInBuf)) { printf("[iopipetest] enque failed!!\n"); goto TEST_EXIT; } } #endif } /*------------------------------ * (5). start *-----------------------------*/ printf("[iopipetest] mpCamIO->start\n"); if(!mpCamIO->start()) { printf("[iopipetest] mpCamIO->start failed!!\n"); goto TEST_EXIT; } #if 0//for debug // test: wait VSYNC printf("[iopipetest] mpCamIO->irq(VSYNC)\n"); if(!mpCamIO->wait(mSensorIdx, EPipeSignal_SOF)) { printf("[iopipetest] wait VSYNC failed!!\n"); goto TEST_EXIT; } // test: wait pass1 done printf("[iopipetest] mpCamIO->irq(p1done)\n"); if(!mpCamIO->wait(mSensorIdx, EPipeSignal_EOF)) { printf("[iopipetest] wait p1done failed!!\n"); goto TEST_EXIT; } #endif /*------------------------------ * (6). deque/enque loop * --> dequeue * --> enqueue *-----------------------------*/ #ifdef _USE_THREAD_QUE_ TS_Thread_Init(count); #else do { printf("-------------------------------------------\n"); QBufInfo halCamIOOutQBuf; QBufInfo rEnBuf; // halCamIOOutQBuf.mvOut.clear(); #ifdef USE_IMAGEBUF_HEAP BufInfo rDeBufInfo(PORT_IMGO, rDequeBuf.mvOut.at(0).mBuffer, rDequeBuf.mvOut.at(0).mSize, rDequeBuf.mvOut.at(0).mVa, rDequeBuf.mvOut.at(0).mPa); #else BufInfo rDeBufInfo(PORT_IMGO, NULL, vDequeMem.at(0).size, vDequeMem.at(0).virtAddr, vDequeMem.at(0).phyAddr); #endif halCamIOOutQBuf.mvOut.push_back(rDeBufInfo); #ifdef USE_IMAGEBUF_HEAP //do nothing #else printf("[iopipetest] dequeBuf.PA(0x%x)VA(0x%x)size(%d)\n", halCamIOOutQBuf.mvOut.at(0).mPa, halCamIOOutQBuf.mvOut.at(0).mVa, halCamIOOutQBuf.mvOut.size()); #endif // printf("[iopipetest] dequeBuf count(%d)\n", count); if(!mpCamIO->deque(halCamIOOutQBuf)) { printf("[iopipetest] deque failed!!\n"); goto TEST_EXIT; } #ifdef USE_IMAGEBUF_HEAP printf("[iopipetest] dequeBuf.PA(0x%x)VA(0x%x)buf(0x%x)\n", halCamIOOutQBuf.mvOut.at(0).mBuffer->getBufPA(0), halCamIOOutQBuf.mvOut.at(0).mBuffer->getBufVA(0), halCamIOOutQBuf.mvOut.at(0).mBuffer); #else printf("[iopipetest] dequeBuf.PA(0x%x)VA(0x%x)\n", halCamIOOutQBuf.mvOut.at(0).mPa, halCamIOOutQBuf.mvOut.at(0).mVa); #endif /* * * * * * * * * * * * * get ResultMetadata * * * * * * * * * * * */ ResultMetadata result = halCamIOOutQBuf.mvOut.at(0).mMetaData; /* * * * * * * * * * * * * check dummy frame * * * * * * * * * * * */ if(halCamIOOutQBuf.mvOut.at(0).mMetaData.m_bDummyFrame == MTRUE) { printf("[iopipetest] this is a dummy frame\n"); } /* * * * * * * * * * * * * sequential buffer *(no replace buffer) * * * * * * * * * * * */ if(nReplace != 1) { rEnBuf.mvOut.clear(); BufInfo rBufInfo(PORT_IMGO, #ifdef USE_IMAGEBUF_HEAP halCamIOOutQBuf.mvOut.at(0).mBuffer, #else NULL, #endif halCamIOOutQBuf.mvOut.at(0).mSize, halCamIOOutQBuf.mvOut.at(0).mVa, halCamIOOutQBuf.mvOut.at(0).mPa); rEnBuf.mvOut.push_back(rBufInfo); } /* * * * * * * * * * * * * buffer per frame *(replace buffer) * * * * * * * * * * * */ else { rEnBuf.mvOut.clear(); #ifdef USE_IMAGEBUF_HEAP BufInfo rBufInfo(PORT_IMGO, rRawBuf.mvOut.at(BufIdx).mBuffer, rRawBuf.mvOut.at(BufIdx).mSize, rRawBuf.mvOut.at(BufIdx).mVa, rRawBuf.mvOut.at(BufIdx).mPa); #else BufInfo rBufInfo(PORT_IMGO, NULL, vRawMem.at(BufIdx).size, vRawMem.at(BufIdx).virtAddr, vRawMem.at(BufIdx).phyAddr); #endif rEnBuf.mvOut.push_back(rBufInfo); } #ifdef USE_IMAGEBUF_HEAP printf("[iopipetest] enqueBuf.PA(0x%x)VA(0x%x),BufId(%d)\n", rEnBuf.mvOut.at(0).mBuffer->getBufPA(0), rEnBuf.mvOut.at(0).mBuffer->getBufVA(0), BufIdx); #else printf("[iopipetest] enqueBuf.PA(0x%x)VA(0x%x),BufId(%d)\n", rEnBuf.mvOut.at(0).mPa, rEnBuf.mvOut.at(0).mVa, BufIdx); #endif /* * * * * * * * * * * * * setting before enque * * * * * * * * * * * */ rEnBuf.mvOut.at(0).FrameBased.mMagicNum_tuning = 0; rEnBuf.mvOut.at(0).FrameBased.mDstSize = mDstSize; rEnBuf.mvOut.at(0).FrameBased.mCropRect = MRect(MPoint(0, 0), mDstSize);//no crop // printf("[iopipetest] enque count(%d)\n", count); if(!mpCamIO->enque(rEnBuf)) { printf("[iopipetest] enque failed!!\n"); goto TEST_EXIT; } // if(++BufIdx > BUF_NUM) BufIdx = 0; // } while(--count > 0); #endif /*------------------------------ * (7). Stop *-----------------------------*/ printf("[iopipetest] mpCamIO->stop\n"); mpCamIO->stop(); TEST_EXIT: /*------------------------------ * (8). uninit *-----------------------------*/ printf("[iopipetest] mpCamIO->uninit\n"); if( !mpCamIO->uninit() ) { MY_LOGE("uninit failed"); } /*------------------------------ * (9). destory instance *-----------------------------*/ printf("[iopipetest] mpCamIO->destroyInstance\n"); mpCamIO->destroyInstance(&Name); mpCamIO = NULL; printf("[iopipetest] X\n"); return 0; }
MVOID* Ts_UT:: endeque_Thread(MVOID * arg) { printf("[endeque_Thread] E\n"); int count = (int)arg; //enque, deque loop iterations MSize mDstSize; mDstSize.w = pTestUT->u4SensorWidth; mDstSize.h = pTestUT->u4SensorHeight; // detach thread => cannot be join ::pthread_detach(::pthread_self()); do { printf("-----------------------------------\n"); printf("[endeque_Thread] dequeBuf count(%d)\n", count); QBufInfo halCamIOOutQBuf; QBufInfo rEnBuf; /* * Deque */ halCamIOOutQBuf.mvOut.clear(); #ifdef USE_IMAGEBUF_HEAP BufInfo rDeBufInfo(PORT_IMGO, pTestUT->rDequeBuf.mvOut.at(0).mBuffer, pTestUT->rDequeBuf.mvOut.at(0).mSize, pTestUT->rDequeBuf.mvOut.at(0).mVa, pTestUT->rDequeBuf.mvOut.at(0).mPa); #else BufInfo rDeBufInfo(PORT_IMGO, NULL, pTestUT->vDequeMem.at(0).size, pTestUT->vDequeMem.at(0).virtAddr, pTestUT->vDequeMem.at(0).phyAddr); #endif halCamIOOutQBuf.mvOut.push_back(rDeBufInfo); // if(!pTestUT->mpCamIO->deque(halCamIOOutQBuf)) { printf("[endeque_Thread] deque failed!!\n"); return NULL; } /* * Enque */ rEnBuf.mvOut.clear(); BufInfo rBufInfo(halCamIOOutQBuf.mvOut.at(0).mPortID, #ifdef USE_IMAGEBUF_HEAP halCamIOOutQBuf.mvOut.at(0).mBuffer, #else NULL, #endif halCamIOOutQBuf.mvOut.at(0).mSize, halCamIOOutQBuf.mvOut.at(0).mVa, halCamIOOutQBuf.mvOut.at(0).mPa); rEnBuf.mvOut.push_back(rBufInfo); /* * * * * * * * * * * * * setting before enque * * * * * * * * * * * */ rEnBuf.mvOut.at(0).FrameBased.mMagicNum_tuning = 0; rEnBuf.mvOut.at(0).FrameBased.mDstSize = mDstSize; rEnBuf.mvOut.at(0).FrameBased.mCropRect = MRect(MPoint(0, 0), mDstSize);//no crop // printf("[endeque_Thread] enqueBuf count(%d)\n", count); if(MFALSE == pTestUT->mpCamIO->enque(rEnBuf)) { printf("[endeque_Thread] enqueBuf failed\n"); return NULL; } } while(--count > 0); printf("[endeque_Thread] X\n"); printf("-----------------------------------\n"); pthread_exit(0); return NULL; }
/***************************************************** ** ** Painter --- drawSingleMStringLine ** ******************************************************/ void Painter::drawSingleMStringLine( const MRect &r, MString &f, const int& align ) { assert( f.formattedLines.size() == 0 ); wxString s; MPoint p; Lang lang( writercfg ); wxFont oldFont = getCurrentFont(); const int drawalign = Align::Left + Align::VCenter; SheetFormatter formatter( writercfg ); if ( ! f.isEmpty() && ( f.size.real() == 0 || f.size.imag() == 0 )) { printf( "WARN: size not set\n" ); f.size = getTextExtent( f ); } //printf( "PAINT -- --- - - - - x %f y %f w %f h %f SIZE x %f y %f\n", r.x, r.y, r.width, r.height, size.real(), size.imag() ); //printf( " ----- %s\n", str2char( formatter.fragment2PlainText( f ))); double x0 = r.x; double y0 = r.y; if ( align & Align::HCenter ) { x0 += .5 * ( r.width - f.size.real()); } else if ( align & Align::Right ) { x0 = x0 + r.width - f.size.real(); } // offset for subscriptum and superscriptum const double yoffset = .5 * f.size.imag(); double yy = y0; // + .5 * ( r.height - size.imag()); for( list<MToken>::const_iterator iter = f.tokens.begin(); iter != f.tokens.end(); iter++ ) { switch ( iter->fontFormat ) { case TTFF_SUBSCRPTUM: yy = y0 + yoffset; break; case TTFF_SUPERSCRPTUM: yy = y0 - yoffset; break; case TTFF_NORMAL: default: yy = y0; break; } setFont( oldFont ); wxChar symbol = 0; SymbolProvider sp( writercfg ); switch ( iter->entity ) { case TTSE_PLANET: if ( writercfg->planetSymbols ) symbol = sp.getPlanetCode( (ObjectId)iter->entityId ); if ( ! symbol || symbol == SYMBOL_CODE_ERROR ) s = formatter.getObjectNamePlain( (ObjectId)iter->entityId, iter->textFormat, iter->vedic ); break; case TTSE_SIGN: if ( writercfg->signSymbols ) symbol = sp.getSignCode( (Rasi)iter->entityId ); if ( ! symbol ) s = lang.getSignName( (Rasi)iter->entityId, iter->textFormat ); //, writercfg->vedicSignNames ); break; case TTSE_ASPECT: symbol = SymbolProvider().getAspectCode( (ASPECT_TYPE)iter->entityId ); if ( ! symbol ) s = AspectExpert::getAspectShortDescription( (int)iter->entityId ); break; case TTSE_DIRECTION: symbol = sp.getRetroCode( (MOVING_DIRECTION)iter->entityId ); if ( ! symbol ) s = wxT( "R" ); break; default: symbol = 0; s = iter->text; break; } if ( symbol && symbol != SYMBOL_CODE_ERROR ) { const int pointSize = oldFont.GetPointSize(); setFont( *FontProvider::get()->getFontBySize( FONT_GRAPHIC_SYMBOLS, pointSize )); drawTextFormatted( MRect( x0, yy, r.width, r.height ), symbol, drawalign ); p = getTextExtent( symbol ); } else { drawTextFormatted( MRect( x0, yy, r.width, r.height ), s, drawalign ); p = getTextExtent( s ); } x0 += p.real(); } }