Ejemplo n.º 1
0
void Canvas::paintEvent(QPaintEvent *event)
{

    QPainter painter(this);
    QRect dirtyRect = event->rect();
    if(dirtyRect.isEmpty())return;
    //    painter.setOpacity(opacity);
    combineLayers(dirtyRect);

    painter.drawPixmap(dirtyRect, image, dirtyRect);

    if(!isEnabled()){
        QBrush brush;
        brush.setStyle(Qt::BDiagPattern);
        brush.setColor(Qt::lightGray);
        painter.setBrush(brush);
        QRect rect = this->rect();
        rect.setWidth(rect.width());
        rect.setHeight(rect.height());
        painter.drawRect(rect);
    }

    QStyleOption opt;
    opt.init(this);
    style()->drawPrimitive(QStyle::PE_Widget,
                           &opt, &painter, this);

}
Ejemplo n.º 2
0
QPixmap Canvas::currentCanvas()
{
    return combineLayers();
}
Ejemplo n.º 3
0
void ossimHillshadeTool::initProcessingChain()
{
   // Need a mosaic of DEM over the AOI as an image mosaic:
   ossimRefPtr<ossimImageSource> demMosaic = mosaicDemSources();
   m_procChain->add(demMosaic.get());

   // Set up the normal source.
   ossimRefPtr<ossimImageToPlaneNormalFilter> normSource = new ossimImageToPlaneNormalFilter;
   normSource->setTrackScaleFlag(true);
   m_procChain->add( normSource.get() );

   // Set the smoothness factor.
   ossim_float64 gain = 1.0;
   normSource->setSmoothnessFactor(gain);

   // Create the bump shade.
   ossimRefPtr<ossimBumpShadeTileSource> bumpShade = new ossimBumpShadeTileSource;
   m_procChain->add(bumpShade.get());

   // Set the azimuth angle.
   ossim_float64 azimuthAngle = 180;
   ossimString lookup = m_kwl.findKey( ossimKeywordNames::AZIMUTH_ANGLE_KW );
   if ( lookup.size() )
   {
      ossim_float64 f = lookup.toFloat64();
      if ( (f >= 0) && (f <= 360) )
      {
         azimuthAngle = f;
      }
   }
   bumpShade->setAzimuthAngle(azimuthAngle);

   // Set the elevation angle.
   ossim_float64 elevationAngle = 45.0;
   lookup = m_kwl.findKey( ossimKeywordNames::ELEVATION_ANGLE_KW );
   if ( lookup.size() )
   {
      ossim_float64 f = lookup.toFloat64();
      if ( (f >= 0.0) && (f <= 90) )
      {
         elevationAngle = f;
      }
   }
   bumpShade->setElevationAngle(elevationAngle);


   // Color can be added via color image source:
   if (!m_imgLayers.empty())
   {
      // A color source image (or list) is provided. Add them as input to bump shade:
      ossimRefPtr<ossimImageSource> colorSource = combineLayers( m_imgLayers );
      bumpShade->connectMyInputTo(1, colorSource.get());
   }
   else
   {
      // Default colors are grey:
      ossim_uint8 r = 0xff;
      ossim_uint8 g = 0xff;
      ossim_uint8 b = 0xff;
      lookup = m_kwl.findKey( COLOR_RED_KW );
      if ( lookup.size() )
         r = lookup.toUInt8();
      lookup = m_kwl.findKey( COLOR_GREEN_KW );
      if ( lookup.size() )
         g = lookup.toUInt8();
      lookup = m_kwl.findKey( COLOR_BLUE_KW );
      if ( lookup.size() )
         b = lookup.toUInt8();
      bumpShade->setRgbColorSource(r, g, b);
   }
}