void QgsEllipseSymbolLayerV2::renderPoint( QPointF point, QgsSymbolV2RenderContext& context ) { bool ok; if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH ) ) { context.setOriginalValueVariable( mOutlineWidth ); double width = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, context, mOutlineWidth ).toDouble(); width = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), width, mOutlineWidthUnit, mOutlineWidthMapUnitScale ); mPen.setWidthF( width ); } if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_STYLE ) ) { context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodePenStyle( mOutlineStyle ) ); QString styleString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_STYLE, context, QVariant(), &ok ).toString(); if ( ok ) { Qt::PenStyle style = QgsSymbolLayerV2Utils::decodePenStyle( styleString ); mPen.setStyle( style ); } } if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_JOIN_STYLE ) ) { context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodePenJoinStyle( mPenJoinStyle ) ); QString style = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_JOIN_STYLE, context, QVariant(), &ok ).toString(); if ( ok ) { mPen.setJoinStyle( QgsSymbolLayerV2Utils::decodePenJoinStyle( style ) ); } } if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR ) ) { context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mColor ) ); QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR, context, QVariant(), &ok ).toString(); if ( ok ) mBrush.setColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) ); } if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR ) ) { context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mOutlineColor ) ); QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR, context, QVariant(), &ok ).toString(); if ( ok ) mPen.setColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) ); } double scaledWidth = mSymbolWidth; double scaledHeight = mSymbolHeight; if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH ) || hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT ) || hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME ) ) { QString symbolName = mSymbolName; if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME ) ) { context.setOriginalValueVariable( mSymbolName ); symbolName = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME, context, mSymbolName ).toString(); } preparePath( symbolName, context, &scaledWidth, &scaledHeight, context.feature() ); } //offset and rotation bool hasDataDefinedRotation = false; QPointF offset; double angle = 0; calculateOffsetAndRotation( context, scaledWidth, scaledHeight, hasDataDefinedRotation, offset, angle ); QPainter* p = context.renderContext().painter(); if ( !p ) { return; } QMatrix transform; transform.translate( point.x() + offset.x(), point.y() + offset.y() ); if ( !qgsDoubleNear( angle, 0.0 ) ) { transform.rotate( angle ); } p->setPen( mPen ); p->setBrush( mBrush ); p->drawPath( transform.map( mPainterPath ) ); }
const std::string& CDirectoryHistory::GetSelectedItem(const std::string& strDirectory) const { HistoryMap::const_iterator iter = m_vecHistory.find(preparePath(strDirectory)); if (iter != m_vecHistory.end()) return iter->second.m_strItem; return StringUtils::Empty; }
void stereoCalibThread::saveImage(const char * imageDir, IplImage* left, int num) { char pathL[256]; preparePath(imageDir, pathL,pathR,num); fprintf(stdout,"Saving images number %d \n",num); cvSaveImage(pathL,left); }
void K3bCddbLocalQuery::doQuery() { emit infoMessage( i18n("Searching entry in %1").arg( m_cddbDir ) ); kapp->processEvents(); //BAD! QString path = preparePath( m_cddbDir ); kdDebug() << "(K3bCddbLocalQuery) searching in dir " << path << " for " << QString::number( toc().discId(), 16 ).rightJustify( 8, '0' ) << endl; for( QStringList::const_iterator it = categories().begin(); it != categories().end(); ++it ) { QString file = path + *it + "/" + QString::number( toc().discId(), 16 ).rightJustify( 8, '0' ); if( QFile::exists( file ) ) { // found file QFile f( file ); if( !f.open( IO_ReadOnly ) ) { kdDebug() << "(K3bCddbLocalQuery) Could not open file" << endl; } else { QTextStream t( &f ); K3bCddbResultEntry entry; parseEntry( t, entry ); K3bCddbResultHeader header; header.discid = QString::number( toc().discId(), 16 ).rightJustify( 8, '0' ); header.category = *it; header.title = entry.cdTitle; header.artist = entry.cdArtist; m_inexactMatches.append(header); } } else { kdDebug() << "(K3bCddbLocalQuery) Could not find local entry in category " << *it << endl; } } if( m_inexactMatches.count() > 0 ) { setError( SUCCESS ); if( m_inexactMatches.count() == 1 ) { queryMatch( m_inexactMatches.first() ); } else { emit inexactMatches( this ); } } else { setError( NO_ENTRY_FOUND ); emit queryFinished( this ); } }
void CDirectoryHistory::SetSelectedItem(const std::string& strSelectedItem, const std::string& strDirectory) { if (strSelectedItem.empty()) return; std::string strDir = preparePath(strDirectory); std::string strItem = preparePath(strSelectedItem, false); HistoryMap::iterator iter = m_vecHistory.find(strDir); if (iter != m_vecHistory.end()) { iter->second.m_strItem = strItem; return; } CHistoryItem item; item.m_strItem = strItem; item.m_strDirectory = strDir; m_vecHistory[strDir] = item; }
void QgsEllipseSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context ) { if ( !context.feature() || !hasDataDefinedProperty() ) { preparePath( mSymbolName, context ); } mPen.setColor( mOutlineColor ); mPen.setWidthF( mOutlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit ) ); mBrush.setColor( mFillColor ); prepareExpressions( context.layer(), context.renderContext().rendererScale() ); }
// Initialize the haret application. void setupHaret() { preparePath(); // Open log file "haretlog.txt" if "earlyharetlog.txt" is found. char fn[100]; fnprepare("earlyharetlog.txt", fn, sizeof(fn)); FILE *logfd=fopen(fn, "r"); if (logfd) { // Requesting early logs.. fclose(logfd); openLogFile("haretlog.txt"); } outTls = TlsAlloc(); TlsSetValue(outTls, 0); Output("\n===== HaRET %s =====", VERSION); init_ehandling(); // Prep for per-thread output function. prepThread(); Output("Finished initializing output"); if(InitKMDriver()){ Output("Initializing kernel mode driver succeeded"); }else{ Output(C_ERROR "Initializing kernel mode driver FAILED"); } // Bind to DLLs dynamically. setup_LateLoading(); // Detect some system settings setupMachineType(); // Init memory maps. setupMemory(); // Setup variable/command lists. setupCommands(); // Initialize the machine found earlier. Output("Initializing for machine '%s'", Mach->name); Mach->init(); // Send banner info to log (if logging on). printWelcome(); }
void QgsEllipseSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context ) { QgsMarkerSymbolLayerV2::startRender( context ); // get anchor point expressions if ( !context.feature() || !hasDataDefinedProperties() ) { preparePath( mSymbolName, context ); } mPen.setColor( mOutlineColor ); mPen.setStyle( mOutlineStyle ); mPen.setWidthF( QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), mOutlineWidth, mOutlineWidthUnit, mOutlineWidthMapUnitScale ) ); mBrush.setColor( mFillColor ); prepareExpressions( context ); }
void QgsEllipseSymbolLayer::startRender( QgsSymbolRenderContext &context ) { QgsMarkerSymbolLayer::startRender( context ); // get anchor point expressions if ( !context.feature() || !dataDefinedProperties().hasActiveProperties() ) { preparePath( mSymbolName, context ); } mPen.setColor( mStrokeColor ); mPen.setStyle( mStrokeStyle ); mPen.setJoinStyle( mPenJoinStyle ); mPen.setWidthF( context.renderContext().convertToPainterUnits( mStrokeWidth, mStrokeWidthUnit, mStrokeWidthMapUnitScale ) ); mBrush.setColor( mColor ); }
void K3bCddbLocalQuery::doMatchQuery() { QString path = preparePath( m_cddbDir ) + header().category + "/" + header().discid; QFile f( path ); if( !f.open( IO_ReadOnly ) ) { kdDebug() << "(K3bCddbLocalQuery) Could not open file" << endl; setError( READ_ERROR ); } else { QTextStream t( &f ); parseEntry( t, result() ); result().discid = header().discid; result().category = header().category; setError( SUCCESS ); } emit queryFinished( this ); }
bool AIScriptGenericWalkerA::prepareWalker() { if (Game_Flag_Query(kFlagGenericWalkerWaiting) || Global_Variable_Query(35) < 0 || !preparePath()) { return false; } int model = 0; do { if (isInside) { model = Random_Query(3, 5); } else { model = Random_Query(0, 5); } } while (model == Global_Variable_Query(kVariableGenericWalkerBModel) || model == Global_Variable_Query(kVariableGenericWalkerCModel)); Global_Variable_Set(kVariableGenericWalkerAModel, model); Game_Flag_Set(kFlagGenericWalkerWaiting); AI_Countdown_Timer_Reset(kActorGenwalkerA, 2); AI_Countdown_Timer_Start(kActorGenwalkerA, 2, Random_Query(4, 12)); Actor_Set_Goal_Number(kActorGenwalkerA, 1); return true; }
bool AIScriptGenericWalkerC::prepareWalker() { if (Game_Flag_Query(kFlagGenericWalkerWaiting) || Global_Variable_Query(35) < 2 || !preparePath()) { return false; } int model = 0; do { if (isInside) { model = Random_Query(3, 5); } else { model = Random_Query(0, 5); } // Here is probably bug in original code, because it not using kVariableGenericWalkerBModel but kVariableGenericWalkerCModel } while (model == Global_Variable_Query(kVariableGenericWalkerAModel) || model == Global_Variable_Query(kVariableGenericWalkerBModel)); Global_Variable_Set(kVariableGenericWalkerCModel, model); Game_Flag_Set(kFlagGenericWalkerWaiting); AI_Countdown_Timer_Reset(kActorGenwalkerC, 2); AI_Countdown_Timer_Start(kActorGenwalkerC, 2, Random_Query(4, 12)); Actor_Set_Goal_Number(kActorGenwalkerC, 1); return true; }
void QgsEllipseSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ) { bool ok; if ( hasDataDefinedProperty( "outline_width" ) ) { double width = evaluateDataDefinedProperty( "outline_width", context.feature(), mOutlineWidth ).toDouble(); width *= QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit, mOutlineWidthMapUnitScale ); mPen.setWidthF( width ); } if ( hasDataDefinedProperty( "outline_style" ) ) { QString styleString = evaluateDataDefinedProperty( "outline_style", context.feature(), QVariant(), &ok ).toString(); if ( ok ) { Qt::PenStyle style = QgsSymbolLayerV2Utils::decodePenStyle( styleString ); mPen.setStyle( style ); } } if ( hasDataDefinedProperty( "fill_color" ) ) { QString colorString = evaluateDataDefinedProperty( "fill_color", context.feature(), QVariant(), &ok ).toString(); if ( ok ) mBrush.setColor( QColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) ) ); } if ( hasDataDefinedProperty( "outline_color" ) ) { QString colorString = evaluateDataDefinedProperty( "outline_color", context.feature(), QVariant(), &ok ).toString(); if ( ok ) mPen.setColor( QColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) ) ); } double scaledWidth = mSymbolWidth; double scaledHeight = mSymbolHeight; if ( hasDataDefinedProperty( "width" ) || hasDataDefinedProperty( "height" ) || hasDataDefinedProperty( "symbol_name" ) ) { QString symbolName = mSymbolName; if ( hasDataDefinedProperty( "symbol_name" ) ) { symbolName = evaluateDataDefinedProperty( "symbol_name", context.feature(), mSymbolName ).toString(); } preparePath( symbolName, context, &scaledWidth, &scaledHeight, context.feature() ); } //offset double offsetX = 0; double offsetY = 0; markerOffset( context, scaledWidth, scaledHeight, mSymbolWidthUnit, mSymbolHeightUnit, offsetX, offsetY, mSymbolWidthMapUnitScale, mSymbolHeightMapUnitScale ); QPointF off( offsetX, offsetY ); QPainter* p = context.renderContext().painter(); if ( !p ) { return; } //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle) double rotation = 0.0; if ( hasDataDefinedProperty( "rotation" ) ) { rotation = evaluateDataDefinedProperty( "rotation", context.feature(), mAngle ).toDouble(); } else if ( !qgsDoubleNear( mAngle, 0.0 ) ) { rotation = mAngle; } if ( rotation ) off = _rotatedOffset( off, rotation ); QMatrix transform; transform.translate( point.x() + off.x(), point.y() + off.y() ); if ( !qgsDoubleNear( rotation, 0.0 ) ) { transform.rotate( rotation ); } p->setPen( mPen ); p->setBrush( mBrush ); p->drawPath( transform.map( mPainterPath ) ); }
void stereoCalibThread::monoCalibRun() { while(imagePortInLeft.getInputCount()==0 && imagePortInRight.getInputCount()==0) { fprintf(stdout, "Connect one camera.. \n"); Time::delay(1.0); if(isStopping()) return; } bool left= imagePortInLeft.getInputCount()>0?true:false; string cameraName; if(left) cameraName="LEFT"; else cameraName="RIGHT"; fprintf(stdout, "CALIBRATING %s CAMERA \n",cameraName.c_str()); int count=1; Size boardSize, imageSize; boardSize.width=this->boardWidth; boardSize.height=this->boardHeight; while (!isStopping()) { if(left) imageL = imagePortInLeft.read(false); else imageL = imagePortInRight.read(false); if(imageL!=NULL){ bool foundL=false; mutex->wait(); if(startCalibration>0) { string pathImg=imageDir; preparePath(pathImg.c_str(), pathL,pathR,count); string iml(pathL); imgL= (IplImage*) imageL->getIplImage(); Mat Left(imgL); std::vector<Point2f> pointbufL; if(boardType == "CIRCLES_GRID") { foundL = findCirclesGridDefault(Left, boardSize, pointbufL, CALIB_CB_SYMMETRIC_GRID | CALIB_CB_CLUSTERING); } else if(boardType == "ASYMMETRIC_CIRCLES_GRID") { foundL = findCirclesGridDefault(Left, boardSize, pointbufL, CALIB_CB_ASYMMETRIC_GRID | CALIB_CB_CLUSTERING); } else { foundL = findChessboardCorners(Left, boardSize, pointbufL, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE); } if(foundL) { cvCvtColor(imgL,imgL,CV_RGB2BGR); saveImage(pathImg.c_str(),imgL,count); imageListL.push_back(iml); Mat cL(pointbufL); drawChessboardCorners(Left, boardSize, cL, foundL); count++; } if(count>numOfPairs) { fprintf(stdout," Running %s Camera Calibration... \n", cameraName.c_str()); monoCalibration(imageListL,this->boardWidth,this->boardHeight,this->Kleft,this->DistL); fprintf(stdout," Saving Calibration Results... \n"); if(left) updateIntrinsics(imgL->width,imgL->height,Kleft.at<double>(0,0),Kleft.at<double>(1,1),Kleft.at<double>(0,2),Kleft.at<double>(1,2),DistL.at<double>(0,0),DistL.at<double>(0,1),DistL.at<double>(0,2),DistL.at<double>(0,3),"CAMERA_CALIBRATION_LEFT"); else updateIntrinsics(imgL->width,imgL->height,Kleft.at<double>(0,0),Kleft.at<double>(1,1),Kleft.at<double>(0,2),Kleft.at<double>(1,2),DistL.at<double>(0,0),DistL.at<double>(0,1),DistL.at<double>(0,2),DistL.at<double>(0,3),"CAMERA_CALIBRATION_RIGHT"); fprintf(stdout, "Calibration Results Saved in %s \n", camCalibFile.c_str()); startCalibration=0; count=1; imageListL.clear(); } } mutex->post(); ImageOf<PixelRgb>& outimL=outPortLeft.prepare(); outimL=*imageL; outPortLeft.write(); ImageOf<PixelRgb>& outimR=outPortRight.prepare(); outimR=*imageL; outPortRight.write(); if(foundL && startCalibration==1) Time::delay(2.0); cout.flush(); } } }
void stereoCalibThread::stereoCalibRun() { imageL=new ImageOf<PixelRgb>; imageR=new ImageOf<PixelRgb>; Stamp TSLeft; Stamp TSRight; bool initL=false; bool initR=false; int count=1; Size boardSize, imageSize; boardSize.width=this->boardWidth; boardSize.height=this->boardHeight; while (!isStopping()) { ImageOf<PixelRgb> *tmpL = imagePortInLeft.read(false); ImageOf<PixelRgb> *tmpR = imagePortInRight.read(false); if(tmpL!=NULL) { *imageL=*tmpL; imagePortInLeft.getEnvelope(TSLeft); initL=true; } if(tmpR!=NULL) { *imageR=*tmpR; imagePortInRight.getEnvelope(TSRight); initR=true; } if(initL && initR && checkTS(TSLeft.getTime(),TSRight.getTime())){ bool foundL=false; bool foundR=false; mutex->wait(); if(startCalibration>0) { string pathImg=imageDir; preparePath(pathImg.c_str(), pathL,pathR,count); string iml(pathL); string imr(pathR); imgL= (IplImage*) imageL->getIplImage(); imgR= (IplImage*) imageR->getIplImage(); Mat Left(imgL); Mat Right(imgR); std::vector<Point2f> pointbufL; std::vector<Point2f> pointbufR; if(boardType == "CIRCLES_GRID") { foundL = findCirclesGridDefault(Left, boardSize, pointbufL, CALIB_CB_SYMMETRIC_GRID | CALIB_CB_CLUSTERING); foundR = findCirclesGridDefault(Right, boardSize, pointbufR, CALIB_CB_SYMMETRIC_GRID | CALIB_CB_CLUSTERING); } else if(boardType == "ASYMMETRIC_CIRCLES_GRID") { foundL = findCirclesGridDefault(Left, boardSize, pointbufL, CALIB_CB_ASYMMETRIC_GRID | CALIB_CB_CLUSTERING); foundR = findCirclesGridDefault(Right, boardSize, pointbufR, CALIB_CB_ASYMMETRIC_GRID | CALIB_CB_CLUSTERING); } else { foundL = findChessboardCorners( Left, boardSize, pointbufL, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE); foundR = findChessboardCorners( Right, boardSize, pointbufR, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE); } if(foundL && foundR) { cvCvtColor(imgL,imgL,CV_RGB2BGR); cvCvtColor(imgR,imgR, CV_RGB2BGR); saveStereoImage(pathImg.c_str(),imgL,imgR,count); imageListR.push_back(imr); imageListL.push_back(iml); imageListLR.push_back(iml); imageListLR.push_back(imr); Mat cL(pointbufL); Mat cR(pointbufR); drawChessboardCorners(Left, boardSize, cL, foundL); drawChessboardCorners(Right, boardSize, cR, foundR); count++; } if(count>numOfPairs) { fprintf(stdout," Running Left Camera Calibration... \n"); monoCalibration(imageListL,this->boardWidth,this->boardHeight,this->Kleft,this->DistL); fprintf(stdout," Running Right Camera Calibration... \n"); monoCalibration(imageListR,this->boardWidth,this->boardHeight,this->Kright,this->DistR); stereoCalibration(imageListLR, this->boardWidth,this->boardHeight,this->squareSize); fprintf(stdout," Saving Calibration Results... \n"); updateIntrinsics(imgL->width,imgL->height,Kright.at<double>(0,0),Kright.at<double>(1,1),Kright.at<double>(0,2),Kright.at<double>(1,2),DistR.at<double>(0,0),DistR.at<double>(0,1),DistR.at<double>(0,2),DistR.at<double>(0,3),"CAMERA_CALIBRATION_RIGHT"); updateIntrinsics(imgL->width,imgL->height,Kleft.at<double>(0,0),Kleft.at<double>(1,1),Kleft.at<double>(0,2),Kleft.at<double>(1,2),DistL.at<double>(0,0),DistL.at<double>(0,1),DistL.at<double>(0,2),DistL.at<double>(0,3),"CAMERA_CALIBRATION_LEFT"); Mat Rot=Mat::eye(3,3,CV_64FC1); Mat Tr=Mat::zeros(3,1,CV_64FC1); updateExtrinsics(this->R,this->T,"STEREO_DISPARITY"); fprintf(stdout, "Calibration Results Saved in %s \n", camCalibFile.c_str()); startCalibration=0; count=1; imageListR.clear(); imageListL.clear(); imageListLR.clear(); } } mutex->post(); ImageOf<PixelRgb>& outimL=outPortLeft.prepare(); outimL=*imageL; outPortLeft.write(); ImageOf<PixelRgb>& outimR=outPortRight.prepare(); outimR=*imageR; outPortRight.write(); if(foundL && foundR && startCalibration==1) Time::delay(2.0); initL=initR=false; cout.flush(); } } delete imageL; delete imageR; }
void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context ) { QColor brushColor = mColor; QColor penColor = mBorderColor; brushColor.setAlphaF( mColor.alphaF() * context.alpha() ); penColor.setAlphaF( mBorderColor.alphaF() * context.alpha() ); mBrush = QBrush( brushColor ); mPen = QPen( penColor ); mPen.setWidthF( mOutlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit ) ); QColor selBrushColor = context.renderContext().selectionColor(); QColor selPenColor = selBrushColor == mColor ? selBrushColor : mBorderColor; if ( context.alpha() < 1 ) { selBrushColor.setAlphaF( context.alpha() ); selPenColor.setAlphaF( context.alpha() ); } mSelBrush = QBrush( selBrushColor ); mSelPen = QPen( selPenColor ); mSelPen.setWidthF( mOutlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit ) ); bool hasDataDefinedRotation = context.renderHints() & QgsSymbolV2::DataDefinedRotation || dataDefinedProperty( "angle" ); bool hasDataDefinedSize = context.renderHints() & QgsSymbolV2::DataDefinedSizeScale || dataDefinedProperty( "size" ); // use caching only when: // - size, rotation, shape, color, border color is not data-defined // - drawing to screen (not printer) mUsingCache = !hasDataDefinedRotation && !hasDataDefinedSize && !context.renderContext().forceVectorOutput() && !dataDefinedProperty( "name" ) && !dataDefinedProperty( "color" ) && !dataDefinedProperty( "color_border" ) && !dataDefinedProperty( "outline_width" ) && !dataDefinedProperty( "size" ); // use either QPolygonF or QPainterPath for drawing // TODO: find out whether drawing directly doesn't bring overhead - if not, use it for all shapes if ( !prepareShape() ) // drawing as a polygon { if ( preparePath() ) // drawing as a painter path { // some markers can't be drawn as a polygon (circle, cross) // For these set the selected border color to the selected color if ( mName != "circle" ) mSelPen.setColor( selBrushColor ); } else { QgsDebugMsg( "unknown symbol" ); return; } } QMatrix transform; // scale the shape (if the size is not going to be modified) if ( !hasDataDefinedSize ) { double scaledSize = mSize * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mSizeUnit ); if ( mUsingCache ) scaledSize *= context.renderContext().rasterScaleFactor(); double half = scaledSize / 2.0; transform.scale( half, half ); } // rotate if the rotation is not going to be changed during the rendering if ( !hasDataDefinedRotation && mAngle != 0 ) { transform.rotate( mAngle ); } if ( !mPolygon.isEmpty() ) mPolygon = transform.map( mPolygon ); else mPath = transform.map( mPath ); if ( mUsingCache ) { if ( !prepareCache( context ) ) { mUsingCache = false; } } else { mCache = QImage(); mSelCache = QImage(); } prepareExpressions( context.layer(), context.renderContext().rendererScale() ); mAngleExpression = expression( "angle" ); mNameExpression = expression( "name" ); QgsMarkerSymbolLayerV2::startRender( context ); }
bool EpisodeConverterWorker::runJob() { m_jobRunning = true; m_isFine = false; QString BackupDirectory = QString("pge_maintainer_backup-%1-%2-%3_%4-%5-%6") .arg(QDate().currentDate().year()) .arg(QDate().currentDate().month()) .arg(QDate().currentDate().day()) .arg(QTime().currentTime().hour()) .arg(QTime().currentTime().minute()) .arg(QTime().currentTime().second()); m_currentValue = 0; try { for(int i=0; i<m_episodeBox.d.size(); i++) { EpisodeBox_level& lvl = m_episodeBox.d[i]; QString relDirPath; QString oldPath = lvl.fPath; if(preparePath(m_episode, relDirPath, lvl.fPath, BackupDirectory, m_doBackup)) continue; switch(m_targetFormat) { case 0://PGE-X qDebug() << "Make LVLX"; lvl.ftype = EpisodeBox_level::F_LVLX; renameExtension(lvl.fPath, ".lvlx"); if(!FileFormats::SaveLevelFile(lvl.d, lvl.fPath, FileFormats::LVL_PGEX)) throw(FileFormats::errorString); break; case 1://SMBX 1...64 qDebug() << "Make LVL SMBX" << lvl.ftypeVer; lvl.ftype = EpisodeBox_level::F_LVL; lvl.ftypeVer = m_targetFormatVer; renameExtension(lvl.fPath, ".lvl"); if(!FileFormats::SaveLevelFile(lvl.d, lvl.fPath, FileFormats::LVL_SMBX64, m_targetFormatVer)) throw(FileFormats::errorString); break; case 2://SMBX-38A qDebug() << "Make LVL SMBX-38a"; lvl.ftype = EpisodeBox_level::F_LVL38A; renameExtension(lvl.fPath, ".lvl"); if(!FileFormats::SaveLevelFile(lvl.d, lvl.fPath, FileFormats::LVL_SMBX38A)) throw(FileFormats::errorString); break; } if(oldPath != lvl.fPath) { m_episodeBox.renameLevel(oldPath, lvl.fPath); QFile::remove(oldPath); } qDebug() << "Successfully!"; m_currentValue++; } for(int i=0; i<m_episodeBox.dw.size(); i++) { EpisodeBox_world& wld = m_episodeBox.dw[i]; qDebug() << "Open world map" << wld.fPath; QString relDirPath; if(preparePath(m_episode, relDirPath, wld.fPath, BackupDirectory, m_doBackup)) continue; qDebug() << "Will be processed"; if(m_doBackup) { qDebug() << "Make backup"; QFileInfo oldFile(wld.fPath); m_episode.mkpath(BackupDirectory + "/" + relDirPath); QFile::copy(wld.fPath, BackupDirectory+"/" + relDirPath + "/" + oldFile.fileName() ); } QString oldPath = wld.fPath; switch(m_targetFormat) { case 0://PGE-X qDebug() << "Make WLDX"; wld.ftype = EpisodeBox_world::F_WLDX; renameExtension(wld.fPath, ".wldx"); if(!FileFormats::SaveWorldFile(wld.d, wld.fPath, FileFormats::WLD_PGEX)) throw(FileFormats::errorString); break; case 1://SMBX 1...64 qDebug() << "Make WLD SMBX "<<wld.ftypeVer; wld.ftype = EpisodeBox_world::F_WLD; wld.ftypeVer = m_targetFormatVer; renameExtension(wld.fPath, ".wld"); if(!FileFormats::SaveWorldFile(wld.d, wld.fPath, FileFormats::WLD_SMBX64, m_targetFormatVer)) throw(FileFormats::errorString); break; case 2://SMBX-38A qDebug() << "Make WLD SMBX-38a"; wld.ftype = EpisodeBox_world::F_WLD38A; renameExtension(wld.fPath, ".wld"); if(!FileFormats::SaveWorldFile(wld.d, wld.fPath, FileFormats::WLD_SMBX38A)) throw(FileFormats::errorString); break; } if(oldPath != wld.fPath) { qDebug() << "Delete old file"; //m_episodeBox.renameLevel(oldPath, wld.fPath); QFile::remove(oldPath); } qDebug() << "Successfully!"; m_currentValue++; } m_isFine=true; } catch(QString err) { m_errorString = "Error ocouped while conversion process: " + err; emit workFinished(false); m_isFine = false; } m_jobRunning = false; qDebug() << "Work done, exiting"; emit workFinished(true); return m_isFine; }
//! Get the texture by searching for it in all paths that makes sense for the given textureName. irr::video::ITexture* CMeshTextureLoader::getTexture(const irr::io::path& textureName) { if ( textureName.empty() || !FileSystem || !VideoDriver) return NULL; // Pre-process texture filename. irr::io::path simplifiedTexName(textureName); simplifiedTexName.replace(_IRR_TEXT('\\'),_IRR_TEXT('/')); // user defined texture path if ( !TexturePath.empty() ) { if ( checkTextureName(TexturePath + simplifiedTexName) ) return VideoDriver->getTexture(TextureName); if ( checkTextureName(TexturePath + FileSystem->getFileBasename(simplifiedTexName)) ) return VideoDriver->getTexture(TextureName); } // just the name itself if ( checkTextureName(simplifiedTexName) ) return VideoDriver->getTexture(TextureName); // look in files relative to the folder of the meshfile if ( MeshFile ) { if ( MeshPath.empty() ) { MeshPath = FileSystem->getFileDir(MeshFile->getFileName()); preparePath(MeshPath); } if ( !MeshPath.empty() ) { if ( checkTextureName(MeshPath + simplifiedTexName) ) return VideoDriver->getTexture(TextureName); if ( checkTextureName(MeshPath + FileSystem->getFileBasename(simplifiedTexName)) ) return VideoDriver->getTexture(TextureName); } } // look in files relative to the folder of the materialfile if ( MaterialFile ) { if ( MaterialPath.empty() ) { MaterialPath = FileSystem->getFileDir(MaterialFile->getFileName()); preparePath(MaterialPath); } if ( !MaterialPath.empty() ) { if ( checkTextureName(MaterialPath + simplifiedTexName) ) return VideoDriver->getTexture(TextureName); if ( checkTextureName(MaterialPath + FileSystem->getFileBasename(simplifiedTexName)) ) return VideoDriver->getTexture(TextureName); } } // check current working directory if ( checkTextureName(FileSystem->getFileBasename(simplifiedTexName)) ) return VideoDriver->getTexture(TextureName); TextureName = _IRR_TEXT(""); return NULL; }
//! Set a custom texture path. void CMeshTextureLoader::setTexturePath(const irr::io::path& path) { TexturePath = path; preparePath(TexturePath); }
void QgsEllipseSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ) { bool ok; if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH ) ) { context.setOriginalValueVariable( mOutlineWidth ); double width = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, context, mOutlineWidth ).toDouble(); width = QgsSymbolLayerV2Utils::convertToPainterUnits( context.renderContext(), width, mOutlineWidthUnit, mOutlineWidthMapUnitScale ); mPen.setWidthF( width ); } if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_STYLE ) ) { context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodePenStyle( mPen.style() ) ); QString styleString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_STYLE, context, QVariant(), &ok ).toString(); if ( ok ) { Qt::PenStyle style = QgsSymbolLayerV2Utils::decodePenStyle( styleString ); mPen.setStyle( style ); } } if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR ) ) { context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mBrush.color() ) ); QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR, context, QVariant(), &ok ).toString(); if ( ok ) mBrush.setColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) ); } if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR ) ) { context.setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mPen.color() ) ); QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR, context, QVariant(), &ok ).toString(); if ( ok ) mPen.setColor( QgsSymbolLayerV2Utils::decodeColor( colorString ) ); } double scaledWidth = mSymbolWidth; double scaledHeight = mSymbolHeight; if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH ) || hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT ) || hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME ) ) { QString symbolName = mSymbolName; if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME ) ) { context.setOriginalValueVariable( mSymbolName ); symbolName = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME, context, mSymbolName ).toString(); } preparePath( symbolName, context, &scaledWidth, &scaledHeight, context.feature() ); } //offset double offsetX = 0; double offsetY = 0; markerOffset( context, scaledWidth, scaledHeight, mSymbolWidthUnit, mSymbolHeightUnit, offsetX, offsetY, mSymbolWidthMapUnitScale, mSymbolHeightMapUnitScale ); QPointF off( offsetX, offsetY ); QPainter* p = context.renderContext().painter(); if ( !p ) { return; } //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle) double rotation = 0.0; if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION ) ) { context.setOriginalValueVariable( mAngle ); rotation = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION, context, mAngle ).toDouble() + mLineAngle; } else if ( !qgsDoubleNear( mAngle + mLineAngle, 0.0 ) ) { rotation = mAngle + mLineAngle; } if ( rotation ) off = _rotatedOffset( off, rotation ); QMatrix transform; transform.translate( point.x() + off.x(), point.y() + off.y() ); if ( !qgsDoubleNear( rotation, 0.0 ) ) { transform.rotate( rotation ); } p->setPen( mPen ); p->setBrush( mBrush ); p->drawPath( transform.map( mPainterPath ) ); }
void QgsSimpleMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ) { QPainter *p = context.renderContext().painter(); if ( !p ) { return; } //offset double offsetX = 0; double offsetY = 0; markerOffset( context, offsetX, offsetY ); QPointF off( offsetX, offsetY ); //angle double angle = mAngle; if ( mAngleExpression ) { angle = mAngleExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble(); } if ( angle ) off = _rotatedOffset( off, angle ); //data defined shape? if ( mNameExpression ) { QString name = mNameExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString(); if ( !prepareShape( name ) ) // drawing as a polygon { preparePath( name ); // drawing as a painter path } } if ( mUsingCache ) { // we will use cached image QImage &img = context.selected() ? mSelCache : mCache; double s = img.width() / context.renderContext().rasterScaleFactor(); p->drawImage( QRectF( point.x() - s / 2.0 + off.x(), point.y() - s / 2.0 + off.y(), s, s ), img ); } else { QMatrix transform; // move to the desired position transform.translate( point.x() + off.x(), point.y() + off.y() ); QgsExpression *sizeExpression = expression( "size" ); bool hasDataDefinedSize = context.renderHints() & QgsSymbolV2::DataDefinedSizeScale || sizeExpression; // resize if necessary if ( hasDataDefinedSize ) { double scaledSize = mSize; if ( sizeExpression ) { scaledSize = sizeExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble(); } scaledSize *= QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mSizeUnit ); switch ( mScaleMethod ) { case QgsSymbolV2::ScaleArea: scaledSize = sqrt( scaledSize ); break; case QgsSymbolV2::ScaleDiameter: break; } double half = scaledSize / 2.0; transform.scale( half, half ); } bool hasDataDefinedRotation = context.renderHints() & QgsSymbolV2::DataDefinedRotation || mAngleExpression; if ( angle != 0 && hasDataDefinedRotation ) transform.rotate( angle ); QgsExpression* colorExpression = expression( "color" ); QgsExpression* colorBorderExpression = expression( "color_border" ); QgsExpression* outlineWidthExpression = expression( "outline_width" ); if ( colorExpression ) { mBrush.setColor( QgsSymbolLayerV2Utils::decodeColor( colorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) ); } if ( colorBorderExpression ) { mPen.setColor( QgsSymbolLayerV2Utils::decodeColor( colorBorderExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) ); mSelPen.setColor( QgsSymbolLayerV2Utils::decodeColor( colorBorderExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) ); } if ( outlineWidthExpression ) { double outlineWidth = outlineWidthExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble(); mPen.setWidthF( outlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit ) ); mSelPen.setWidthF( outlineWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit ) ); } p->setBrush( context.selected() ? mSelBrush : mBrush ); p->setPen( context.selected() ? mSelPen : mPen ); if ( !mPolygon.isEmpty() ) p->drawPolygon( transform.map( mPolygon ) ); else p->drawPath( transform.map( mPath ) ); } }
void QgsEllipseSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ) { QgsExpression* outlineWidthExpression = expression( "outline_width" ); QgsExpression* fillColorExpression = expression( "fill_color" ); QgsExpression* outlineColorExpression = expression( "outline_color" ); QgsExpression* widthExpression = expression( "width" ); QgsExpression* heightExpression = expression( "height" ); QgsExpression* symbolNameExpression = expression( "symbol_name" ); QgsExpression* rotationExpression = expression( "rotation" ); if ( outlineWidthExpression ) { double width = outlineWidthExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble(); width *= QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOutlineWidthUnit ); mPen.setWidthF( width ); } if ( fillColorExpression ) { QString colorString = fillColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString(); mBrush.setColor( QColor( colorString ) ); } if ( outlineColorExpression ) { QString colorString = outlineColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString(); mPen.setColor( QColor( colorString ) ); } if ( widthExpression || heightExpression || symbolNameExpression ) { QString symbolName = mSymbolName; if ( symbolNameExpression ) { symbolName = symbolNameExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString(); } preparePath( symbolName, context, context.feature() ); } //offset double offsetX = 0; double offsetY = 0; markerOffset( context, mSymbolWidth, mSymbolHeight, mSymbolWidthUnit, mSymbolHeightUnit, offsetX, offsetY ); QPointF off( offsetX, offsetY ); QPainter* p = context.renderContext().painter(); if ( !p ) { return; } //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle) double rotation = 0.0; if ( rotationExpression ) { rotation = rotationExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble(); } else if ( !qgsDoubleNear( mAngle, 0.0 ) ) { rotation = mAngle; } if ( rotation ) off = _rotatedOffset( off, rotation ); QMatrix transform; transform.translate( point.x() + off.x(), point.y() + off.y() ); if ( !qgsDoubleNear( rotation, 0.0 ) ) { transform.rotate( rotation ); } p->setPen( mPen ); p->setBrush( mBrush ); p->drawPath( transform.map( mPainterPath ) ); }
int main(int argc, char **argv) { CApp theApp; preparePath(argv[0]); return theApp.OnExecute(argc, argv); }
void QgsEllipseSymbolLayer::renderPoint( QPointF point, QgsSymbolRenderContext &context ) { double scaledWidth = mSymbolWidth; double scaledHeight = mSymbolHeight; if ( mDataDefinedProperties.hasActiveProperties() ) { bool ok; context.setOriginalValueVariable( mStrokeWidth ); QVariant exprVal = mDataDefinedProperties.value( QgsSymbolLayer::PropertyStrokeWidth, context.renderContext().expressionContext() ); if ( exprVal.isValid() ) { double width = exprVal.toDouble( &ok ); if ( ok ) { width = context.renderContext().convertToPainterUnits( width, mStrokeWidthUnit, mStrokeWidthMapUnitScale ); mPen.setWidthF( width ); } } context.setOriginalValueVariable( QgsSymbolLayerUtils::encodePenStyle( mStrokeStyle ) ); exprVal = mDataDefinedProperties.value( QgsSymbolLayer::PropertyStrokeStyle, context.renderContext().expressionContext() ); if ( exprVal.isValid() ) { mPen.setStyle( QgsSymbolLayerUtils::decodePenStyle( exprVal.toString() ) ); } context.setOriginalValueVariable( QgsSymbolLayerUtils::encodePenJoinStyle( mPenJoinStyle ) ); exprVal = mDataDefinedProperties.value( QgsSymbolLayer::PropertyJoinStyle, context.renderContext().expressionContext() ); if ( exprVal.isValid() ) { mPen.setJoinStyle( QgsSymbolLayerUtils::decodePenJoinStyle( exprVal.toString() ) ); } context.setOriginalValueVariable( QgsSymbolLayerUtils::encodeColor( mColor ) ); mBrush.setColor( mDataDefinedProperties.valueAsColor( QgsSymbolLayer::PropertyFillColor, context.renderContext().expressionContext(), mColor ) ); context.setOriginalValueVariable( QgsSymbolLayerUtils::encodeColor( mStrokeColor ) ); mPen.setColor( mDataDefinedProperties.valueAsColor( QgsSymbolLayer::PropertyStrokeColor, context.renderContext().expressionContext(), mStrokeColor ) ); if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyWidth ) || mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyHeight ) || mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyName ) ) { QString symbolName = mSymbolName; context.setOriginalValueVariable( mSymbolName ); exprVal = mDataDefinedProperties.value( QgsSymbolLayer::PropertyName, context.renderContext().expressionContext() ); if ( exprVal.isValid() ) { symbolName = exprVal.toString(); } preparePath( symbolName, context, &scaledWidth, &scaledHeight, context.feature() ); } } //offset and rotation bool hasDataDefinedRotation = false; QPointF offset; double angle = 0; calculateOffsetAndRotation( context, scaledWidth, scaledHeight, hasDataDefinedRotation, offset, angle ); QPainter *p = context.renderContext().painter(); if ( !p ) { return; } QMatrix transform; transform.translate( point.x() + offset.x(), point.y() + offset.y() ); if ( !qgsDoubleNear( angle, 0.0 ) ) { transform.rotate( angle ); } p->setPen( mPen ); p->setBrush( mBrush ); p->drawPath( transform.map( mPainterPath ) ); }
void CDirectoryHistory::RemoveSelectedItem(const std::string& strDirectory) { HistoryMap::iterator iter = m_vecHistory.find(preparePath(strDirectory)); if (iter != m_vecHistory.end()) m_vecHistory.erase(iter); }