Exemplo n.º 1
0
bool PhotoCamera::initializeFromMeshLab(QDomElement &element)
{
    QStringList attTemp;
    //Get Translation
    attTemp = element.attribute("TranslationVector").split(" ");
    Eigen::Vector4f translation;
    for(int i = 0; i < attTemp.count(); i++){
        translation(i) = attTemp[i].toFloat();
    }
    translationMatrix.translation() = translation.head(3);
    //translationMatrix.col(3) = translation;

    //Get Center;
    attTemp = element.attribute("CenterPx").split(" ");
    principalPoint << attTemp.at(0).toFloat(), attTemp.at(1).toFloat();


    //Get RotationMatrix;
    attTemp = element.attribute("RotationMatrix").split(" ");
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            rotationMatrix(i, j) = attTemp[i*4 + j].toFloat();
        }
    }

    //Get Viewport;
    attTemp = element.attribute("ViewportPx").split(" ");
    viewport << attTemp.at(0).toFloat(), attTemp.at(1).toFloat();

    //Lens Distortion;
    attTemp = element.attribute("LensDistortion").split(" ");
    distortion << attTemp.at(0).toFloat(), attTemp.at(1).toFloat();
    //std::cout << distortion.transpose() << std::endl;

    //PixelSize;
    attTemp = element.attribute("PixelSizeMm").split(" ");
    pixelSize << attTemp.at(0).toFloat(), attTemp.at(1).toFloat();
    oneOverDx           = 1/pixelSize(0);
    oneOverDy           = 1/pixelSize(1);
    //std::cout << pixelSize.transpose() << std::endl;

    //Focal
    focalLength = element.attribute("FocalMm").toFloat();

    buildExtrinsic();
    buildIntrinsic();
    buildProjection();

//    cameraCenter = center(intrinsicMatrix.topLeftCorner(3,4)*extrinsicMatrix.matrix());
    cameraCenter = center(intrinsicMatrix.matrix().topLeftCorner(3,4)*extrinsicMatrix.matrix());
    return true;
}
Exemplo n.º 2
0
PhotoCamera::PhotoCamera()
{
    intrinsicMatrix     = Eigen::Matrix4f::Identity();
    extrinsicMatrix     = Eigen::Matrix4f::Identity();
    rotationMatrix      = Eigen::Matrix4f::Identity();
    translationMatrix   = Eigen::Matrix4f::Identity();

    focalLength         = 47.3606;
    pixelSize           << 0.0319598, 0.0319598;
    oneOverDx           = 1/pixelSize(0);
    oneOverDy           = 1/pixelSize(1);

//    buildIntrinsic();
//    buildExtrinsic();
}
Exemplo n.º 3
0
void DepthOfFieldListener::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
    if(pass_id == 2)
	{
		float blurScale =.5f;
		Ogre::Vector4  pixelSize(1.0f / mViewportWidth, 1.0f / mViewportHeight,1.0f / (mViewportWidth * blurScale), 1.0f / (mViewportHeight * blurScale) );

		Ogre::Pass *pass = mat->getBestTechnique()->getPass(0);
        Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
    
	   	if (params->_findNamedConstantDefinition("pixelSize"))
			params->setNamedConstant("pixelSize", pixelSize);

	    // this is the camera you're using
        #ifndef ROAD_EDITOR
		Ogre::Camera *cam = mApp->mSplitMgr->mCameras.front();
		#else
		Ogre::Camera *cam = mApp->mCamera;
		#endif
       		
		if (params->_findNamedConstantDefinition("dofparams"))
		{
			Ogre::Vector4 dofParams(0.0f,mApp->pSet->depthOfFieldFocus,mApp->pSet->depthOfFieldFar,1.0);
			params->setNamedConstant("dofparams", dofParams);
		}
     }
}
Exemplo n.º 4
0
template<UnsignedInt dimensions> std::size_t AbstractImage::dataSize(Math::Vector<dimensions, Int> size) const {
    /** @todo Code this properly when all @fn_gl{PixelStore} parameters are implemented */
    /* Row size, rounded to multiple of 4 bytes */
    const std::size_t rowSize = ((size[0]*pixelSize() + 3)/4)*4;

    /** @todo Can't this be done somewhat nicer? */
    size[0] = 1;
    return rowSize*size.product();
}
Exemplo n.º 5
0
void PhotoCamera::buildProjection()
{
      float fov     = (2 * std::atan((getHeight()/2.0)/-intrinsicMatrix(1,1)));
      float ratio   = getWidth()/(getHeight() * pixelSize(0)/pixelSize(1));
      float f       =  1/ tan(fov/2);
      float near    = 0.1;
      float far     = 100000;
//      cout << "fov: " << fov << endl;
//      cout << "ratio: " << ratio << endl;

      Eigen::Matrix4f perspective = Eigen::Matrix4f::Zero();
      perspective(0,0) = f/ratio;
      perspective(1,1) = f;
      perspective(2,2) = (far + near)/(near - far);
      perspective(3,2) = -1;
      perspective(2,3) = (2 * far * near)/(near - far);

      projectionMatrix = perspective;
}
void KisLegacyTileCompressor::readTile(QIODevice *stream, KisTiledDataManager *dm)
{
    const qint32 tileDataSize = TILE_DATA_SIZE(pixelSize(dm));

    const qint32 bufferSize = maxHeaderLength() + 1;
    quint8 *headerBuffer = new quint8[bufferSize];

    qint32 x, y;
    qint32 width, height;

    stream->readLine((char *)headerBuffer, bufferSize);
    sscanf((char *) headerBuffer, "%d,%d,%d,%d", &x, &y, &width, &height);

    qint32 row = yToRow(dm, y);
    qint32 col = xToCol(dm, x);

    KisTileSP tile = dm->getTile(col, row, true);

    tile->lockForWrite();
    stream->read((char *)tile->data(), tileDataSize);
    tile->unlock();
}
Exemplo n.º 7
0
QPointF Visualizer::worldCoordinate(QPointF deviceCoordinate)
{
  QSizeF size = worldSize();
  double pixel = pixelSize();
  return QPointF(-0.5 * size.width() + deviceCoordinate.x() * pixel, 0.5 * size.height() - deviceCoordinate.y() * pixel);
}
Exemplo n.º 8
0
template<UnsignedInt dimensions> void BufferImage<dimensions>::setData(const typename DimensionTraits<Dimensions, Int>::VectorType& size, ColorFormat format, ColorType type, const void* data, BufferUsage usage) {
    _format = format;
    _type = type;
    _size = size;
    _buffer.setData({data, pixelSize()*size.product()}, usage);
}
Exemplo n.º 9
0
/*
 * fitWidth, fitHeight:
 *  - from setLayout(AlignLeft | AlignTop)
 *    is being deprecated but still needs to be implemented
 *  - nested layouts: handles as other layout items
 */
DomElement *StdGridLayoutImpl2::createDomElement(bool fitWidth, bool fitHeight,
						 WApplication *app)
{
  needAdjust_ = needConfigUpdate_ = needRemeasure_ = false;
  addedItems_.clear();
  removedItems_.clear();

  const unsigned colCount = grid_.columns_.size();
  const unsigned rowCount = grid_.rows_.size();

  int margin[] = { 0, 0, 0, 0};

  int maxWidth = 0, maxHeight = 0;

  if (layout()->parentLayout() == 0) {
#ifndef WT_TARGET_JAVA
    layout()->getContentsMargins(margin + 3, margin, margin + 1, margin + 2);
#else // WT_TARGET_JAVA
    margin[3] = layout()->getContentsMargin(Left);
    margin[0] = layout()->getContentsMargin(Top);
    margin[1] = layout()->getContentsMargin(Right);
    margin[2] = layout()->getContentsMargin(Bottom);
#endif // WT_TARGET_JAVA

    maxWidth = pixelSize(container()->maximumWidth());
    maxHeight = pixelSize(container()->maximumHeight());
  }

  WStringStream js;

  js << app->javaScriptClass()
     << ".layouts2.add(new " WT_CLASS ".StdLayout2("
     << app->javaScriptClass() << ",'"
     << id() << "',";

  if (layout()->parentLayout())
    js << "'" << getImpl(layout()->parentLayout())->id() << "',";
  else
    js << "null,";

  bool progressive = !app->environment().ajax();
  js << (fitWidth ? '1' : '0') << "," << (fitHeight ? '1' : '0') << ","
     << (progressive ? '1' : '0') << ",";

  js << maxWidth << "," << maxHeight
     << ",["
     << grid_.horizontalSpacing_ << "," << margin[3] << "," << margin[1]
     << "],["
     << grid_.verticalSpacing_ << "," << margin[0] << "," << margin[2] << "],";

  streamConfig(js, app);

  DomElement *div = DomElement::createNew(DomElement_DIV);
  div->setId(id());
  div->setProperty(PropertyStylePosition, "relative");

  DomElement *table = 0, *tbody = 0, *tr = 0;
  if (progressive) {
    table = DomElement::createNew(DomElement_TABLE);

    WStringStream style;
    if (maxWidth)
      style << "max-width: " << maxWidth << "px;";
    if (maxHeight)
      style << "max-height: " << maxHeight << "px;";
    style << "width: 100%;";

    table->setProperty(PropertyStyle, style.str());

    int totalColStretch = 0;
    for (unsigned col = 0; col < colCount; ++col)
      totalColStretch += std::max(0, grid_.columns_[col].stretch_);

    for (unsigned col = 0; col < colCount; ++col) {
      DomElement *c = DomElement::createNew(DomElement_COL);
      int stretch = std::max(0, grid_.columns_[col].stretch_);

      if (stretch || totalColStretch == 0) {
	char buf[30];

	double pct = totalColStretch == 0 ? 100.0 / colCount
	  : (100.0 * stretch / totalColStretch);

	WStringStream ss;
	ss << "width:" << Utils::round_css_str(pct, 2, buf) << "%;";
	c->setProperty(PropertyStyle, ss.str());
      }

      table->addChild(c);
    }

    tbody = DomElement::createNew(DomElement_TBODY);
  }

#ifndef WT_TARGET_JAVA
  std::vector<bool> overSpanned(colCount * rowCount, false);
#else
  std::vector<bool> overSpanned;
  overSpanned.insert(0, colCount * rowCount, false);
#endif // WT_TARGET_JAVA

  int prevRowWithItem = -1;

  for (unsigned row = 0; row < rowCount; ++row) {
    if (table)
      tr = DomElement::createNew(DomElement_TR);

    bool rowVisible = false;
    int prevColumnWithItem = -1;

    for (unsigned col = 0; col < colCount; ++col) {
      Impl::Grid::Item& item = grid_.items_[row][col];

      if (!overSpanned[row * colCount + col]) {
	for (int i = 0; i < item.rowSpan_; ++i)
	  for (int j = 0; j < item.colSpan_; ++j)
	    if (i + j > 0)
	      overSpanned[(row + i) * colCount + col + j] = true;

	AlignmentFlag hAlign = item.alignment_ & AlignHorizontalMask;
	AlignmentFlag vAlign = item.alignment_ & AlignVerticalMask;

	DomElement *td = 0;

	if (table) {
	  bool itemVisible = hasItem(row, col);
	  rowVisible = rowVisible || itemVisible;

	  td = DomElement::createNew(DomElement_TD);

	  if (itemVisible) {
	    int padding[] = { 0, 0, 0, 0 };

	    int nextRow = nextRowWithItem(row, col);
	    int prevRow = prevRowWithItem;

	    int nextCol = nextColumnWithItem(row, col);
	    int prevCol = prevColumnWithItem;

	    if (prevRow == -1)
	      padding[0] = margin[0];
	    else
	      padding[0] = (grid_.verticalSpacing_+1) / 2;

	    if (nextRow == (int)rowCount)
	      padding[2] = margin[2];
	    else
	      padding[2] = grid_.verticalSpacing_ / 2;

	    if (prevCol == -1)
	      padding[3] = margin[3];
	    else
	      padding[3] = (grid_.horizontalSpacing_ + 1)/2;

	    if (nextCol == (int)colCount)
	      padding[1] = margin[1];
	    else
	      padding[1] = (grid_.horizontalSpacing_)/2;

	    WStringStream style;

	    if (app->layoutDirection() == RightToLeft)
	      std::swap(padding[1], padding[3]);

	    if (padding[0] == padding[1] && padding[0] == padding[2]
		&& padding[0] == padding[3]) {
	      if (padding[0] != 0)
		style << "padding:" << padding[0] << "px;";
	    } else
	      style << "padding:"
		    << padding[0] << "px " << padding[1] << "px "
		    << padding[2] << "px " << padding[3] << "px;";

	    if (vAlign != 0) switch (vAlign) {
	      case AlignTop:
		style << "vertical-align:top;";
		break;
	      case AlignMiddle:
		style << "vertical-align:middle;";
		break;
	      case AlignBottom:
		style << "vertical-align:bottom;";
	      default:
		break;
	      }

	    td->setProperty(PropertyStyle, style.str());

	    if (item.rowSpan_ != 1)
	      td->setProperty(PropertyRowSpan,
			      boost::lexical_cast<std::string>(item.rowSpan_));
	    if (item.colSpan_ != 1)
	      td->setProperty(PropertyColSpan,
			      boost::lexical_cast<std::string>(item.colSpan_));

	    prevColumnWithItem = col;
	  }
	}

	DomElement *c = 0;

	if (!table) {
	  if (item.item_) {
	    c = createElement(item.item_, app);
	    div->addChild(c);
	  }
	} else
	  if (item.item_)
	    c = getImpl(item.item_)->createDomElement(true, true, app);

	if (table) {
	  if (c) {
	    if (!app->environment().agentIsIElt(9))
	      c->setProperty(PropertyStyleBoxSizing, "border-box");

	    if (hAlign == 0)
	      hAlign = AlignJustify;

	    switch (hAlign) {
	    case AlignCenter: {
	      DomElement *itable = DomElement::createNew(DomElement_TABLE);
	      itable->setProperty(PropertyClass, "Wt-hcenter");
	      if (vAlign == 0)
		itable->setProperty(PropertyStyle, "height:100%;");
	      DomElement *irow = DomElement::createNew(DomElement_TR);
	      DomElement *itd = DomElement::createNew(DomElement_TD);
	      if (vAlign == 0)
		itd->setProperty(PropertyStyle, "height:100%;");

	      bool haveMinWidth
		= !c->getProperty(PropertyStyleMinWidth).empty();

	      itd->addChild(c);

	      if (app->environment().agentIsIElt(9)) {
		// IE7 and IE8 do support min-width but do not enforce it
		// properly when in a table.
		//  see http://stackoverflow.com/questions/2356525
		//            /css-min-width-in-ie6-7-and-8
		if (haveMinWidth) {
		  DomElement *spacer = DomElement::createNew(DomElement_DIV);
		  spacer->setProperty(PropertyStyleWidth,
				      c->getProperty(PropertyStyleMinWidth));
		  spacer->setProperty(PropertyStyleHeight, "1px");
		  itd->addChild(spacer);
		}
	      }

	      irow->addChild(itd);
	      itable->addChild(irow);
	      c = itable;
	      break;
	    }
	    case AlignRight:
	      if (!c->isDefaultInline())
		c->setProperty(PropertyStyleFloat, "right");
	      else
		td->setProperty(PropertyStyleTextAlign, "right");
	      break;
	    case AlignLeft:
	      if (!c->isDefaultInline())
		c->setProperty(PropertyStyleFloat, "left");
	      else
		td->setProperty(PropertyStyleTextAlign, "left");
	      break;
	    default:
	      break;
	    }

	    td->addChild(c);

	    if (app->environment().agentIsIElt(9)) {
	      // IE7 and IE8 do support min-width but do not enforce it properly
	      // when in a table.
	      //  see http://stackoverflow.com/questions/2356525
	      //            /css-min-width-in-ie6-7-and-8
	      if (!c->getProperty(PropertyStyleMinWidth).empty()) {
		DomElement *spacer = DomElement::createNew(DomElement_DIV);
		spacer->setProperty(PropertyStyleWidth,
				    c->getProperty(PropertyStyleMinWidth));
		spacer->setProperty(PropertyStyleHeight, "1px");
		td->addChild(spacer);
	      }
	    }
	  }

	  tr->addChild(td);
	}
      }
    }

    if (tr) {
      if (!rowVisible)
	tr->setProperty(PropertyStyleDisplay, "hidden");
      else
	prevRowWithItem = row;
      tbody->addChild(tr);
    }
  }

  js << "));";

  if (table) {
    table->addChild(tbody);
    div->addChild(table);
  }

  div->callJavaScript(js.str());

  return div;
}
Exemplo n.º 10
0
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
    cairo_t* cr = context->platformContext();
    cairo_save(cr);
    cairo_translate(cr, point.x(), point.y());

    PangoLayout* layout = pango_cairo_create_layout(cr);
    setPangoAttributes(this, run, layout);

    gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length());
    pango_layout_set_text(layout, utf8, -1);

    // Our layouts are single line
    PangoLayoutLine* layoutLine = pango_layout_get_line_readonly(layout, 0);

    GdkRegion* partialRegion = NULL;
    if (to - from != run.length()) {
        // Clip the region of the run to be rendered
        char* start = g_utf8_offset_to_pointer(utf8, from);
        char* end = g_utf8_offset_to_pointer(start, to - from);
        int ranges[] = {start - utf8, end - utf8};
        partialRegion = gdk_pango_layout_line_get_clip_region(layoutLine, 0, 0, ranges, 1);
        gdk_region_shrink(partialRegion, 0, -pixelSize());
    }

    Color fillColor = context->fillColor();
    float red, green, blue, alpha;

    // Text shadow, inspired by FontMac
    IntSize shadowSize;
    int shadowBlur = 0;
    Color shadowColor;
    bool hasShadow = context->textDrawingMode() == cTextFill &&
        context->getShadow(shadowSize, shadowBlur, shadowColor);

    // TODO: Blur support
    if (hasShadow) {
        // Disable graphics context shadows (not yet implemented) and paint them manually
        context->clearShadow();
        Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
        cairo_save(cr);

        shadowFillColor.getRGBA(red, green, blue, alpha);
        cairo_set_source_rgba(cr, red, green, blue, alpha);

        cairo_translate(cr, shadowSize.width(), shadowSize.height());

        if (partialRegion) {
            gdk_cairo_region(cr, partialRegion);
            cairo_clip(cr);
        }

        pango_cairo_show_layout_line(cr, layoutLine);

        cairo_restore(cr);
    }

    fillColor.getRGBA(red, green, blue, alpha);
    cairo_set_source_rgba(cr, red, green, blue, alpha);

    if (partialRegion) {
        gdk_cairo_region(cr, partialRegion);
        cairo_clip(cr);
    }

    pango_cairo_show_layout_line(cr, layoutLine);

    if (context->textDrawingMode() & cTextStroke) {
        Color strokeColor = context->strokeColor();
        strokeColor.getRGBA(red, green, blue, alpha);
        cairo_set_source_rgba(cr, red, green, blue, alpha);
        pango_cairo_layout_line_path(cr, layoutLine);
        cairo_set_line_width(cr, context->strokeThickness());
        cairo_stroke(cr);
    }

    // Re-enable the platform shadow we disabled earlier
    if (hasShadow)
        context->setShadow(shadowSize, shadowBlur, shadowColor);

    // Pango sometimes leaves behind paths we don't want
    cairo_new_path(cr);

    if (partialRegion)
        gdk_region_destroy(partialRegion);

    g_free(utf8);
    g_object_unref(layout);

    cairo_restore(cr);
}
Exemplo n.º 11
0
void BlogListDelegate::paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
{
    BlogListWidget * listWidget = qobject_cast<BlogListWidget *>(this->parent());
    if (listWidget == NULL) return;

    QStyle * style = listWidget->style();
    if (style == NULL) return;

    painter->save();

    QFont itemFont(painter->font());

    style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, listWidget);

    QPixmap pixmap = qvariant_cast<QPixmap>(index.data(IconRole));
	QString title = index.data(TitleRole).toString();
	QString date = index.data(DateRole).toString();
	QString author = index.data(AuthorRole).toString();
	QString intro = index.data(IntroRole).toString();

  //  QRect rect;
	int imageSpace = ImageSpace + 10;

    // TITLE
    painter->setPen(listWidget->titleTextColor());
    QFont titleFont(listWidget->titleTextFontFamily());
    titleFont.setPixelSize(pixelSize(listWidget->titleTextFontSize()));
    painter->setFont(titleFont);
    QRect rect = option.rect.adjusted(imageSpace, TopSpace, 0, 0);
    style->drawItemText(painter, rect, Qt::AlignLeft, option.palette, true, title);
    QFontMetrics titleFontMetrics(titleFont);

    // INTRO
    painter->setPen(listWidget->introTextColor());
    QFont introFont(listWidget->introTextFontFamily());
    introFont.setPixelSize(pixelSize(listWidget->introTextFontSize()));
    painter->setFont(introFont);
    rect = option.rect.adjusted(imageSpace, TopSpace + titleFontMetrics.lineSpacing() + pixelSize(listWidget->titleTextExtraLeading()) , 0, 0);
    style->drawItemText(painter, rect, Qt::AlignLeft, option.palette, true, intro);
    QFontMetrics introFontMetrics(introFont);

    // DATE
    painter->setPen(listWidget->dateTextColor());
    QFont font(listWidget->dateTextFontFamily());
    font.setPixelSize(pixelSize(listWidget->dateTextFontSize()));
    painter->setFont(font);
    rect = option.rect.adjusted(imageSpace, TopSpace + titleFontMetrics.lineSpacing() + introFontMetrics.lineSpacing() + pixelSize(listWidget->introTextExtraLeading()), 0, 0);
    style->drawItemText(painter, rect, Qt::AlignLeft, option.palette, true, date);
    QFontMetrics dateTextFontMetrics(font);

    // AUTHOR
    QRect textRect = style->itemTextRect(dateTextFontMetrics, option.rect, Qt::AlignLeft, true, date);
    rect = option.rect.adjusted(imageSpace + textRect.width() + 7, TopSpace + titleFontMetrics.lineSpacing() + introFontMetrics.lineSpacing() + pixelSize(listWidget->introTextExtraLeading()), 0, 0);
    style->drawItemText(painter, rect, Qt::AlignLeft, option.palette, true, author);

    if (!pixmap.isNull()) {
		//ic.paint(painter, option.rect, Qt::AlignVCenter|Qt::AlignLeft);
        style->drawItemPixmap(painter, option.rect.adjusted(0, TopSpace, 0, -TopSpace), Qt::AlignLeft, pixmap);
	}

    painter->restore();
}
Exemplo n.º 12
0
//*****************************************************************************
// BuckeyeSMPlugin::constructSensorModelFromISD
//*****************************************************************************
TSMWarning *BuckeyeSMPlugin::constructSensorModelFromISD(
                                  const tsm_ISD&   image_support_data,
                                  const std::string& sensor_model_name,
                                  TSMSensorModel*& sensor_model) const throw (TSMError)
{
   TSMWarning * tsmWarn = NULL;
   std::string myname("BuckeyeSMPlugin::constructSensorModelFromISD");
 
   bool isISDSupported = false;
  //canSensorModelBeConstructedFromISD(image_support_data, sensor_model_name, isISDSupported);
   const filenameISD * filenameObject = dynamic_cast<const filenameISD*>(&image_support_data);
   ossimFilename frameMetaGsti;
   ossimRefPtr<ossimImageHandler> ih;
   ossimFilename frameNumber;

   if(filenameObject)
   {
      ossimFilename file(filenameObject->_filename);
     if(file.ext() == "tif")
	  {
	     std::cout << "********* tif\n";		// Temporary -- Tiff development is underway but not operational
	  }
	  ossimFilename dir(file.path());
	  frameNumber = file.fileNoExtension();
	  frameMetaGsti = dir.dirCat("FrameMeta_GSTI.txt");
	  ih = ossimImageHandlerRegistry::instance()->open(file);
	  if(frameMetaGsti.exists()&&ih.valid())
	  {
	     isISDSupported = true;
	  }
   }
	
   BuckeyeSensorModel* result = 0;
   if (isISDSupported) 
   {
      ossimDpt pixelSize(.0068, .0068);
	  // Note:  This system only works for Square pixels.......  
	  ossimDpt principalPoint(-0.1853,1.2428);
	  double focalLength = 211.0211;
	  ossimIrect imageRect = ih->getBoundingRect();
	  
	  double roll  = 0.0;
	  double pitch = 0.0;
	  double yaw   = 0.0;

	  ossimGpt platformPosition;
	  bool frameNumberFound = false;

	  ossimCsvFile csv(" \t");		// we will use tab or spaces as separator
      if(csv.open(frameMetaGsti))
      {
         if(csv.readHeader())
         {
            ossimRefPtr<ossimCsvFile::Record> record;
            while( ((record = csv.nextRecord()).valid()) && !frameNumberFound)
            {
               if( (*record)["Frame#"] == frameNumber)
               {
                  frameNumberFound = true;
                  roll = (*record)["Roll(deg)"].toDouble();
                  pitch = (*record)["Pitch(deg)"].toDouble();
                  yaw = (*record)["Yaw(deg)"].toDouble();
                  platformPosition = ossimGpt((*record)["Lat(deg)"].toDouble(),
				                              (*record)["Lon(deg)"].toDouble(),
                                              (*record)["HAE(m)"].toDouble());
					
			   }
			}
		}
		
		if(frameNumberFound)
		{

		   result = new BuckeyeSensorModel();

		   BuckeyeSensorModel *bkSensorModel = static_cast<BuckeyeSensorModel*>(result);

		   bkSensorModel->buckeye->setRollPitchHeading(roll, pitch, yaw);
		   bkSensorModel->buckeye->setFocalLength(focalLength);
		   bkSensorModel->buckeye->setPlatformPosition(platformPosition);

		   bkSensorModel->buckeye->setPrincipalPoint(principalPoint);
		   bkSensorModel->buckeye->setPixelSize(pixelSize);
		   ossimSmacCallibrationSystem* distortion = new ossimSmacCallibrationSystem(1.06545826E-002, -1.58699040E-005, 1.12448462E-009, -8.67450914E-013, 0,
																					  5.92909E-006, -1.66339E-005, 0, 0);  

		   bkSensorModel->buckeye->setLensDistortion(distortion);
		   bkSensorModel->buckeye->setImageRect(imageRect);			
		   bkSensorModel->buckeye->updateModel();
			
		   bkSensorModel->setSensorPosition(platformPosition);
		   bkSensorModel->setPrincipalPoint(principalPoint);
		   bkSensorModel->setFocalLength(focalLength);
			
		   bkSensorModel->setPixelSize(pixelSize);	
		   bkSensorModel->setImageSize(imageRect.height(), imageRect.width());

		   bkSensorModel->setReferenceDateAndTime("Date TIME");
#if 0
		   testBuckeyeCSMSensor(bkSensorModel);
#endif
			
		}
      }
  }
  if(!result)
  {
	  TSMError tsmError = TSMError(TSMError::ISD_NOT_SUPPORTED, "Unable to create sensor model from ISD.", myname);
	  throw tsmError;
  }
  
  sensor_model = result; 
  return tsmWarn;
}
Exemplo n.º 13
0
/*! \internal
    Returns a QFontEngine for the specified \a script that matches the
    QFontDef \e request member variable.
*/
void QFontPrivate::load( QFont::Script script )
{
    // NOTE: the X11 and Windows implementations of this function are
    // identical... if you change one, change both.

#ifdef QT_CHECK_STATE
    // sanity checks
    if (!QFontCache::instance)
	qWarning("Must construct a QApplication before a QFont");
    Q_ASSERT( script >= 0 && script < QFont::LastPrivateScript );
#endif // QT_CHECK_STATE

    QFontDef req = request;
    req.pixelSize = qRound(pixelSize(req, paintdevice, screen));
    req.pointSize = 0;

    if ( ! engineData ) {
	QFontCache::Key key( req, QFont::NoScript, screen, paintdevice );

	// look for the requested font in the engine data cache
	engineData = QFontCache::instance->findEngineData( key );

	if ( ! engineData ) {
	    // create a new one
	    engineData = new QFontEngineData;
	    QFontCache::instance->insertEngineData( key, engineData );
	} else {
	    engineData->ref();
	}
    }

    // the cached engineData could have already loaded the engine we want
    if ( engineData->engines[script] ) return;

    // load the font
    QFontEngine *engine = 0;
    //    double scale = 1.0; // ### TODO: fix the scale calculations

    // list of families to try
    QStringList family_list;

    if (!req.family.isEmpty()) {
	family_list = QStringList::split( ',', req.family );

	// append the substitute list for each family in family_list
	QStringList subs_list;
	QStringList::ConstIterator it = family_list.begin(), end = family_list.end();
	for ( ; it != end; ++it )
	    subs_list += QFont::substitutes( *it );
	family_list += subs_list;

#ifndef QT_XFT2
	// with Xft2, we want to use fontconfig to determine better fallbacks,
	// otherwise we might run into trouble with default fonts as "serif"

	// append the default fallback font for the specified script
	QString fallback = qt_fallback_font_family( script );
	if ( ! fallback.isEmpty() && ! family_list.contains( fallback ) )
	    family_list << fallback;

	// add the default family
	QString defaultFamily = QApplication::font().family();
	if ( ! family_list.contains( defaultFamily ) )
	    family_list << defaultFamily;

	// add QFont::defaultFamily() to the list, for compatibility with
	// previous versions
	family_list << QApplication::font().defaultFamily();
#endif // QT_XFT2
    }

    // null family means find the first font matching the specified script
    family_list << QString::null;

    QStringList::ConstIterator it = family_list.begin(), end = family_list.end();
    for ( ; ! engine && it != end; ++it ) {
	req.family = *it;

	engine = QFontDatabase::findFont( script, this, req );
	if ( engine ) {
	    if ( engine->type() != QFontEngine::Box )
		break;

	    if ( ! req.family.isEmpty() )
		engine = 0;

	    continue;
	}
    }

    engine->ref();
    engineData->engines[script] = engine;
}