void Spectrogram::updateData()
{
	if (!d_matrix || !d_graph)
		return;

	setData(MatrixData(d_matrix, d_use_matrix_formula));
	setLevelsNumber(levels());

	QwtScaleWidget *colorAxis = d_graph->axisWidget(color_axis);
	if (colorAxis)
		colorAxis->setColorMap(data().range(), colorMap());

	d_graph->setAxisScale(color_axis, data().range().minValue(), data().range().maxValue());
	d_graph->replot();
}
示例#2
0
template<> XmlNode NodeCreator<Color>::createNodeFromObject(const Color& t) {
	XmlNode n("color");
	n.addChild(XmlNode("id", boost::lexical_cast<std::string>(t.getId())));
	XmlNode colorMap("colorMap");
	for(std::map<const boost::uuids::uuid, const SDL_Color>::const_iterator i = t.getColorMap().begin(); i != t.getColorMap().end(); i++) {
		XmlNode entry("entry");
		entry.addChild(XmlNode("themeId", boost::lexical_cast<std::string>(i->first)));
		entry.addChild(XmlNode("r", boost::lexical_cast<std::string>(static_cast<unsigned int>(i->second.r))));
		entry.addChild(XmlNode("g", boost::lexical_cast<std::string>(static_cast<unsigned int>(i->second.g))));
		entry.addChild(XmlNode("b", boost::lexical_cast<std::string>(static_cast<unsigned int>(i->second.b))));
		entry.addChild(XmlNode("a", boost::lexical_cast<std::string>(static_cast<unsigned int>(i->second.unused))));
		colorMap.addChild(entry);
	}

	n.addChild(colorMap);
	return n;
}
示例#3
0
// Internally uses DFS for graph traversal (in fact it's topological sort)
void NodeTree::prepareListImpl()
{
    // Initialize color map with white color
    std::vector<ENodeColor> colorMap(_nodes.size(), ENodeColor::White);

    _executeList.clear();

    // For each invalid nodes (in terms of executable) mark them black
    // so "true" graph traversal can skip them
    for(NodeID nodeID = 0; nodeID < NodeID(_nodes.size()); ++nodeID)
    {
        if(!validateNode(nodeID))
            continue;

        if(colorMap[nodeID] != ENodeColor::White)
            continue;

        if(isNodeExecutable(nodeID))
            continue;

        if(!depthFirstSearch(nodeID, colorMap))
            return;
    }	

    // For each tagged and valid nodes that haven't been visited yet do ..
    for(NodeID nodeID = 0; nodeID < NodeID(_nodes.size()); ++nodeID)
    {
        if(!validateNode(nodeID))
            continue;

        if(colorMap[nodeID] != ENodeColor::White)
            continue;

        if(!_nodes[nodeID].flag(ENodeFlags::Tagged))
            continue;

        if(!depthFirstSearch(nodeID, colorMap, &_executeList))
        {
            _executeList.clear();
            return;
        }
    }

    // Topological sort gives result in inverse order
    std::reverse(std::begin(_executeList), std::end(_executeList));
}
void VRestoreScreen::SaveBackgroundScreenshot()
{
  // GrabBackgroundScreenshot() needs to be called before
  if (m_pScreenshotBuffer == NULL)
    return;

  const int iScreenWidth = Vision::Video.GetXRes();
  const int iScreenHeight = Vision::Video.GetYRes();
  ColorCorrect(m_pScreenshotBuffer, iScreenWidth, iScreenHeight, m_fBrightness, m_fSaturation);

  // use VTEX to scale and save the image
  Image_cl image;
  ImageMap_cl colorMap(iScreenWidth, iScreenHeight, 24, static_cast<UBYTE*>(m_pScreenshotBuffer));
  image.AddColorMap(colorMap);

  // Decide which resolution to use for the saved image.
  int iScaledWidth = 512;
  while (iScaledWidth > iScreenWidth || iScaledWidth > iScreenHeight)
  {
    iScaledWidth /= 2;
    VASSERT(iScaledWidth > 0);
  }

  image.Scale(iScaledWidth, iScaledWidth);

  const char* szFilename = ":app_cache/vision_background.bmp";
  IVFileOutStream* pOut = Vision::File.Create(szFilename);
  const bool bSaved = (image.SaveBMP(pOut) == VERR_NOERROR);
  V_SAFE_DELETE_ARRAY(m_pScreenshotBuffer);

  if (pOut != NULL)
    pOut->Close();

  if (bSaved)
  {
    // Set up loading screen settings.
    Settings settings(szFilename);
    settings.m_eAspectRatioAlignment = ALIGN_NONE;
    SetSettings(settings);
  }
  else
  {
    hkvLog::Dev("VRestoreScreen: Could not save backgrounding screenshot\n");
  }
}
void Spectrogram::showColorScale(int axis, bool on)
{
if (hasColorScale() == on && color_axis == axis)
	return;

QwtPlot *plot = this->plot();
if (!plot)
	return;

QwtScaleWidget *colorAxis = plot->axisWidget(color_axis);
colorAxis->setColorBarEnabled(false);

color_axis = axis;

// We must switch main and the color scale axes and their respective scales
	int xAxis = this->xAxis();
	int yAxis = this->yAxis();
	int oldMainAxis = QwtPlot::xBottom;
	if (axis == QwtPlot::xBottom || axis == QwtPlot::xTop){
		oldMainAxis = xAxis;
		xAxis = 5 - color_axis;
	} else if (axis == QwtPlot::yLeft || axis == QwtPlot::yRight){
		oldMainAxis = yAxis;
		yAxis = 1 - color_axis;
	}

// First we switch axes
setAxis(xAxis, yAxis);

// Next we switch axes scales
QwtScaleDiv *scDiv = plot->axisScaleDiv(oldMainAxis);
if (axis == QwtPlot::xBottom || axis == QwtPlot::xTop)
	plot->setAxisScale(xAxis, scDiv->lBound(), scDiv->hBound());
else if (axis == QwtPlot::yLeft || color_axis == QwtPlot::yRight)
	plot->setAxisScale(yAxis, scDiv->lBound(), scDiv->hBound());

colorAxis = plot->axisWidget(color_axis);
plot->setAxisScale(color_axis, data().range().minValue(), data().range().maxValue());
colorAxis->setColorBarEnabled(on);
colorAxis->setColorMap(data().range(), colorMap());
if (!plot->axisEnabled(color_axis))
	plot->enableAxis(color_axis);
colorAxis->show();
plot->updateLayout();
}
void Spectrogram::updateData(Matrix *m)
{
if (!m)
	return;

QwtPlot *plot = this->plot();
if (!plot)
	return;

setData(MatrixData(m));
setLevelsNumber(levels());

QwtScaleWidget *colorAxis = plot->axisWidget(color_axis);
if (colorAxis)
	colorAxis->setColorMap(data().range(), colorMap());

plot->setAxisScale(color_axis, data().range().minValue(), data().range().maxValue());
plot->replot();
}
示例#7
0
  void EpsWriter::writeColors ( colorTrans colTrans, unsigned int numColors  ) {
  if ( colTrans != UNDEFINED ) {
    aol::RGBColorMap<RealType> colorMap(0.0, 1.0, colTrans);
    for ( unsigned int i = 0; i < numColors; i++ ) {
      fprintf ( output, "/col%d {%f %f %f srgb} bind def\n", i, colorMap.scalarToColor(static_cast<RealType>(i) / static_cast<RealType>(numColors - 1))[0],
                                                    colorMap.scalarToColor(static_cast<RealType>(i) / static_cast<RealType>(numColors - 1))[1],
                                                    colorMap.scalarToColor(static_cast<RealType>(i) / static_cast<RealType>(numColors - 1))[2] );
    }
  } else { // use some standard color palette
    fprintf ( output, "/col0 {0.0 0.0 0.0 srgb} bind def\n" );
    fprintf ( output, "/col1 {0.0 0.0 1.0 srgb} bind def\n" );
    fprintf ( output, "/col2 {0.0 1.0 0.0 srgb} bind def\n" );
    fprintf ( output, "/col3 {0.0 1.0 1.0 srgb} bind def\n" );
    fprintf ( output, "/col4 {1.0 0.0 0.0 srgb} bind def\n" );
    fprintf ( output, "/col5 {1.0 0.0 1.0 srgb} bind def\n" );
    fprintf ( output, "/col6 {1.0 1.0 0.0 srgb} bind def\n" );
    fprintf ( output, "/col7 {1.0 1.0 1.0 srgb} bind def\n" );
  }
}
	void conditionArticulation(boost::shared_array<vertexState> state, mpfr_class& weight, const context& contextObj, std::vector<int>& scratch, boost::detail::depth_first_visit_restricted_impl_helper<filteredGraphType>::stackType& filteredGraphStack)
	{
		const context::inputGraph& graph = contextObj.getGraph();
		filteredGraphType filtered(graph, boost::keep_all(), filterByStateMask(state.get(), UNFIXED_MASK | ON_MASK));
		//get out biconnected components of helper graph (which has different vertex ids, remember)
		std::vector<std::size_t> articulationVertices;
		boost::articulation_points(filtered, std::back_inserter(articulationVertices));
	
		typedef boost::color_traits<boost::default_color_type> Color;
		std::vector<boost::default_color_type> colorMap(boost::num_vertices(contextObj.getGraph()), Color::white());
		findFixedOnVisitor fixedVisitor(state.get());
		const std::vector<mpfr_class> operationalProbabilities = contextObj.getOperationalProbabilities();

		for(std::vector<std::size_t>::iterator i = articulationVertices.begin(); i != articulationVertices.end(); i++)
		{
			if(state[*i].state != FIXED_ON)
			{
				std::fill(colorMap.begin(), colorMap.end(), Color::white());
				colorMap[*i] = Color::black();

				filteredGraphType::out_edge_iterator current, end;
				boost::tie(current, end) = boost::out_edges(*i, filtered);
				int nComponentsWithFixedOnVertices = 0;
				for(; current != end; current++)
				{
					std::size_t otherVertex = current->m_target;
					if(colorMap[otherVertex] != Color::black())
					{
						fixedVisitor.found = false;
						boost::detail::depth_first_visit_restricted_impl(filtered, otherVertex, fixedVisitor, &(colorMap[0]), filteredGraphStack, boost::detail::nontruth2());
						if(fixedVisitor.found) nComponentsWithFixedOnVertices++;
						if(nComponentsWithFixedOnVertices > 1) break;
					}
				}
				if(nComponentsWithFixedOnVertices > 1)
				{
					state[*i].state = FIXED_ON;
					weight *= operationalProbabilities[*i];
				}
			}
		}
	}
示例#9
0
文件: bild1.C 项目: Rollmops/lipsia
Bild::Bild( QWidget *parent, const char *name, VImage src, VImage src1)
  : QWidget( parent, name ), src_m(src), src1_m(src1)


{
  //  if (DEBUGING) qWarning( tr("initialize view %1").arg(typ) );
  
  setPalette( QPalette( QColor( 0,0,0) ) );
  QWidget::setMouseTracking ( TRUE );

  effect_m=VImageNRows(src_m);
  scan_m=VImageNColumns(src_m);

  for (int i=0; i<effect_m; i++) {
    for (int j=0; j<scan_m; j++) {
      if (VPixel(src1_m,0,i,j,VFloat) > maxwert) maxwert=VPixel(src1_m,0,i,j,VFloat);
      else if (VPixel(src1_m,0,i,j,VFloat) < minwert) minwert=VPixel(src1_m,0,i,j,VFloat);
    }
  }  

  colorMap(); 
}
示例#10
0
文件: rubik.cpp 项目: ZoeQIAN/rubik
void Rubik::Render(){
	
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_LIGHTING);
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    GLfloat m[4][4];
  	build_rotmatrix(m, curquat);
  	Vec3f normal;
    //glBegin(GL_QUADS);
		Vec3f rect[4];
	for(int zz=0; zz<3;zz++)
		for(int yy=0; yy<3;yy++)
			for(int xx=0; xx<3; xx++){
				cube c = blocks[xx+yy*3+zz*3*3];
				for(unsigned int j=0; j<c.sf.size(); j++){
				Surface s = c.sf[j];

				float r,g,b;
				colorMap(s.init,r,g,b);
				//glColor3f(r,g,b);

				int x=c.pos[0];
				int y=c.pos[1];
				int z=c.pos[2];
				switch(s.now){
					case UP:
					normal = Vec3f(0,0,1);
					rect[0] = Vec3f((x+1)*edge_length,y*edge_length,3*edge_length);
					rect[1] = Vec3f((x+1)*edge_length,(y+1)*edge_length,3*edge_length);
					rect[2] = Vec3f(x*edge_length,(y+1)*edge_length,3*edge_length);
					rect[3] = Vec3f(x*edge_length,y*edge_length,3*edge_length);
					Paintrect(rect,m,prefix,r,g,b,normal);
					break;
					case DOWN:
					normal = Vec3f(0,0,-1);
					rect[0] = Vec3f(x*edge_length,y*edge_length,0);
					rect[1] = Vec3f(x*edge_length,(y+1)*edge_length,0);
					rect[2] = Vec3f((x+1)*edge_length,(y+1)*edge_length,0);
					rect[3] = Vec3f((x+1)*edge_length,(y)*edge_length,0);
					Paintrect(rect,m,prefix,r,g,b,normal);
					break;
					case LEFT:
					normal = Vec3f(0,-1,0);
					rect[0] = Vec3f((x+1)*edge_length,0,(z+1)*edge_length);
					rect[1] = Vec3f(x*edge_length,0,(z+1)*edge_length);
					rect[2] = Vec3f(x*edge_length,0,z*edge_length);
					rect[3] = Vec3f((x+1)*edge_length,0,z*edge_length);
					Paintrect(rect,m,prefix,r,g,b,normal);
					break;
					case RIGHT:
					normal = Vec3f(0,1,0);
					rect[0]=Vec3f(x*edge_length,3*edge_length,(z+1)*edge_length);
					rect[1]=Vec3f((x+1)*edge_length,3*edge_length,(z+1)*edge_length);
					rect[2]=Vec3f((x+1)*edge_length,3*edge_length,z*edge_length);
					rect[3]=Vec3f(x*edge_length,3*edge_length,z*edge_length);
					Paintrect(rect,m,prefix,r,g,b,normal);
					break;
					case FRONT:
					normal = Vec3f(1,0,0);
					rect[0] = Vec3f(3*edge_length,(y+1)*edge_length,(z+1)*edge_length);
					rect[1] = Vec3f(3*edge_length,y*edge_length,(z+1)*edge_length);
					rect[2] = Vec3f(3*edge_length,y*edge_length,z*edge_length);
					rect[3] = Vec3f(3*edge_length,(y+1)*edge_length,z*edge_length);
					Paintrect(rect,m,prefix,r,g,b,normal);
					break;
					case BACK:
					normal = Vec3f(-1,0,0);
					rect[0] = Vec3f(0,y*edge_length,(z+1)*edge_length);
					rect[1] = Vec3f(0,(y+1)*edge_length,(z+1)*edge_length);
					rect[2] = Vec3f(0,(y+1)*edge_length,z*edge_length);
					rect[3] = Vec3f(0,y*edge_length,z*edge_length);
					Paintrect(rect,m,prefix,r,g,b,normal);
					break;
					default:
					break;
			}

		}
	}

	//glEnd();
	glPopMatrix();
}
示例#11
0
Plot::Plot(QWidget *parent):
    QwtPlot(parent)
{
    d_spectrogram = new QwtPlotSpectrogram();

    QwtLinearColorMap colorMap(Qt::darkCyan, Qt::red);
    colorMap.addColorStop(0.1, Qt::cyan);
    colorMap.addColorStop(0.6, Qt::green);
    colorMap.addColorStop(0.95, Qt::yellow);

    d_spectrogram->setColorMap(colorMap);

    d_spectrogram->setData(SpectrogramData());
    d_spectrogram->attach(this);

    QwtValueList contourLevels;
    for ( double level = 0.5; level < 10.0; level += 1.0 )
        contourLevels += level;
    d_spectrogram->setContourLevels(contourLevels);

    QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight);
    rightAxis->setTitle("Intensity");
    rightAxis->setColorBarEnabled(true);
    rightAxis->setColorMap(d_spectrogram->data().range(),
        d_spectrogram->colorMap());

    setAxisScale(QwtPlot::yRight, 
        d_spectrogram->data().range().minValue(),
        d_spectrogram->data().range().maxValue() );
    enableAxis(QwtPlot::yRight);

    plotLayout()->setAlignCanvasToScales(true);
    replot();

    // LeftButton for the zooming
    // MidButton for the panning
    // RightButton: zoom out by 1
    // Ctrl+RighButton: zoom out to full size

    QwtPlotZoomer* zoomer = new QwtPlotZoomer(canvas());
#if QT_VERSION < 0x040000
    zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
        Qt::RightButton, Qt::ControlButton);
#else
    zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
        Qt::RightButton, Qt::ControlModifier);
#endif
    zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
        Qt::RightButton);

    QwtPlotPanner *panner = new QwtPlotPanner(canvas());
    panner->setAxisEnabled(QwtPlot::yRight, false);
    panner->setMouseButton(Qt::MidButton);

    // Avoid jumping when labels with more/less digits
    // appear/disappear when scrolling vertically

    const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
    QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
    sd->setMinimumExtent( fm.width("100.00") );

    const QColor c(Qt::darkBlue);
    zoomer->setRubberBandPen(c);
    zoomer->setTrackerPen(c);
}
示例#12
0
//======================================================================
// Immediate mode parameter routine (called when PARAM message arrrives)
//======================================================================
void Application::param(const char *paramName, bool inMapLoading)
{
    if (strcmp(paramName, "colormap_file") == 0)
    {
        // get filename
        const char *newVal;
        char *filename = "ColorEdit.dummy";
        if (Covise::get_reply_browser(&newVal))
        {
            char buffer[1024];
            Covise::getname(buffer, newVal);
            if (buffer[0] == '\0' && newVal)
                filename = strcpy(new char[strlen(newVal) + 1], newVal);
            else
                filename = strcpy(new char[strlen(buffer) + 1], buffer);
        }

        //load file
        IntColorMap colorMap(filename);
        char puffer[1024];

        if (colorMap.isValid())
        {
            int size = colorMap.getSize();
            char string[30];
            snprintf(string, sizeof(string), "%i", (8 + size));
#ifdef _STANDARD_C_PLUS_PLUS
            std::ostringstream buffer;
#else
            ostrstream buffer;
#endif
            buffer << "colormap" << endl
                   << "Colormap" << endl
                   << string << endl
                   << "loadColorMap\n";
            colorMap.write(buffer);

#ifdef _STANDARD_C_PLUS_PLUS
            std::string str = buffer.str();
            const char *message = str.c_str();
#else
            const char *message = buffer.str();
#endif

            // send message to all UIF
            Covise::send_ui_message("PARAM_RESTORE", message);
            Covise::send_ui_message("PARAM_SLAVE", message);
        }
        else
        {
            if (!inMapLoading)
            {
                sprintf(puffer, "%s is not a valid colormap file.", filename);
                Covise::sendError(puffer);
            }
        }
    }
    else if (strcmp(paramName, "Min") == 0)
    {
        Covise::get_reply_float_scalar(&min);
    }
    else if (strcmp(paramName, "Max") == 0)
    {
        Covise::get_reply_float_scalar(&max);
    }
    else if (strcmp(paramName, "colormap") == 0)
    {
        colormap_type type;
        Covise::get_reply_colormap(&min, &max, &ncolor, &type);
        Covise::update_scalar_param("Min", min);
        Covise::update_scalar_param("Max", max);

        if (ncolor <= COLORMAP_WIDTH)
        {
            for (int i = 0; i < ncolor; i++)
            {
                Covise::get_reply_colormap(i, &colormap[0][i], &colormap[1][i], &colormap[2][i], &colormap[3][i], &colormap[4][i]);
            }
        }
        else
        {
            char buf[255];
            sprintf(buf, "Colormap > %d is too long for me.", COLORMAP_WIDTH);
            Covise::sendWarning(buf);
        }
    }
}
示例#13
0
/////////////////////////////////////////////////
// 绘制 Julia Set
/////////////////////////////////////////////////
int JDraw(COMPLEX c, double fromx, double fromy, double tox, double toy, double sr, double cr)
{
    int ret = 0;
    int update = 0;
    state* st = g_st - 1;
    clock_t tt = clock();
    g_updatepoint = 0;
    for(int y=0; y<g_h; y++)
    {
        for(int x=0; x<g_w; x++)
        {
            ++st;
            if (st->ed)
            {
                continue;
            }
            COMPLEX& z = st->z;

            if (st->iter == 0)
            {
                double re = fromx + (tox - fromx) * (x / (double)g_w);
                double im = fromy + (toy - fromy) * (y / (double)g_h);
                z.re = cr * re + sr * im;
                z.im = sr * re - cr * im;
            }
            else
            {
                //z = st->z;
            }
            st->iter++;
            {
                z = z * z + c;
                if ( z.re*z.re + z.im*z.im > bilout )
                {
                    st->ed = 1;
                }
            }
            ++ret;
            if ( st->ed )
            {
                color_t c = 0;
                c = colorMap(z, st->iter);
                putpixel(x, y, c);
                g_updatepoint += 1;
            }
            else if (st->iter == 1)
            {
                color_t c = 0;
                //c = colorMap(z, st->iter);
                putpixel_f(x, y, c);
            }
        }
        if (clock() - tt > 10)
        {
            tt = clock();
            if (kbmouhit())
            {
                return -1;
            }
        }
    }
    return ret;
}
示例#14
0
  /**
   * Get the cubes from the config dialog box and figures out
   * which viewportmainwindow the cube is associated with and then
   * creates the ScatterPlotData and the QwtSpectrogram and 
   * attaches it to the plot.  Once the plot is configured the 
   * scatter plot window is shown. 
   * 
   */
  void ScatterPlotWindow::showScatterPlot(){
    QString cube1 = p_cube1ComboBox->currentText();
    QString cube2 = p_cube2ComboBox->currentText();
    if(cube1 == "" || cube2 == ""){
      p_tool->setActionChecked(false);
      return;
    }

    p_plot->setTitle(cube1 + " VS " + cube2);

    //------------------------------------------------------
    // Now we need the viewportmainwindow associated with 
    // each cube.
    //------------------------------------------------------
    CubeViewport *cube1Viewport = NULL;
    CubeViewport *cube2Viewport = NULL;
    std::vector<CubeViewport *> *cubeList = ((ViewportMainWindow *)(p_parent))->workspace()->cubeViewportList();
    for(unsigned int i = 0; i < cubeList->size(); i++) {
      std::string cubeFilename= cubeList->at(i)->cube()->Filename();
      QString str = QFileInfo(cubeFilename.c_str()).fileName();
      if(str.compare(cube1) == 0){
        cube1Viewport = cubeList->at(i);
      }
      if(str.compare(cube2) == 0){
        cube2Viewport = cubeList->at(i);
      }
    }

    // -----------------------------------------------
    // Check to make sure the two cubes have the same 
    // number of lines and samples
    // -----------------------------------------------
    double ssamp1,esamp1,sline1,eline1;
    double ssamp2,esamp2,sline2,eline2;
    cube1Viewport->viewportToCube(0,0,ssamp1,sline1);
    cube1Viewport->viewportToCube(cube1Viewport->viewport()->width()-1,
                                      cube1Viewport->viewport()->height()-1,
                                      esamp1,eline1);

      cube2Viewport->viewportToCube(0,0,ssamp2,sline2);
      cube2Viewport->viewportToCube(cube2Viewport->viewport()->width()-1,
                                      cube2Viewport->viewport()->height()-1,
                                      esamp2,eline2);
   
      if((int)(esamp1 - ssamp1) != (int)(esamp2 - ssamp2) || (int)(eline1 - sline1) != (int)(eline2 - sline2)) {
      QMessageBox::critical(p_configDialog, "Size Issue", "The visible area of the cubes must be the same size!",QMessageBox::Ok);
      p_tool->setActionChecked(false);
      return;
    }

    p_configDialog->setCursor(Qt::WaitCursor);

    //----------------------------------------------
    // Get the band the user selected for each cube
    // to call with the ScatterPlotData constructor
    //---------------------------------------------
    p_band1 = p_cube1BandComboBox->currentIndex()+1;
    p_band2 = p_cube2BandComboBox->currentIndex()+1;
 
    //------------------------------------------------------------
    // Instantiate the QwtPlotSpectrogram and the ScatterPlotData
    // then attach to the plot.
    //----------------------------------------------------------
    p_spectrogram = new QwtPlotSpectrogram();
    int numbins1 = p_numBinsOne->text().toInt();
    int numbins2 = p_numBinsTwo->text().toInt();
    ScatterPlotData *data = new ScatterPlotData(cube1Viewport, p_band1, numbins1, cube2Viewport, p_band2, numbins2);
    p_spectrogram->setData(*data);
    p_spectrogram->attach(p_plot);

    QwtValueList contourLevels;
    QwtDoubleInterval range = data->range();

    // -----------------------------------------------------
    // Setup the contour levels for the contour lines
    // on the spectrogram.
    // ------------------------------------------------------
    for ( double level = 0.5; level < range.maxValue(); level += (range.maxValue() / 6) )
        contourLevels += level;
    p_spectrogram->setContourLevels(contourLevels);

    if(p_colorize->text().compare("Colorize") == 0) {
      QwtLinearColorMap colorMap(Qt::black, Qt::white);
      p_spectrogram->setColorMap(colorMap);
    } else {
      QwtLinearColorMap colorMap(Qt::darkCyan, Qt::red);
      colorMap.addColorStop(0.05, Qt::cyan);
      colorMap.addColorStop(0.3, Qt::green);
      colorMap.addColorStop(0.50, Qt::yellow);
      p_spectrogram->setColorMap(colorMap);
    }

    // -------------------------------------------
    // Setup a color bar on the right axis
    // using the color map created above.
    // -------------------------------------------
    p_rightAxis = p_plot->axisWidget(QwtPlot::yRight);
    p_rightAxis->setTitle("Counts");
    p_rightAxis->setColorBarEnabled(true);
    p_rightAxis->setColorMap(p_spectrogram->data().range(),
        p_spectrogram->colorMap());

    p_plot->setAxisScale(QwtPlot::yRight,
        p_spectrogram->data().range().minValue(),
        p_spectrogram->data().range().maxValue() );
    p_plot->enableAxis(QwtPlot::yRight);

    // ----------------------------------------------------------------
    // Setup the plots min/max and both axes to be the min/max for the
    // data associated with those axes.
    // Also set the axes titles to the cube name and which band on that 
    // cube.
    // -----------------------------------------------------------------
    p_MinOne = data->minOne();
    p_MaxOne = data->maxOne();
    p_MinTwo = data->minTwo();
    p_MaxTwo = data->maxTwo();
    p_plot->setAxisScale(QwtPlot::yLeft, p_MinTwo, p_MaxTwo);
    p_plot->setAxisScale(QwtPlot::xBottom, p_MinOne, p_MaxOne);
    p_plot->setAxisTitle(QwtPlot::xBottom, cube1 + "   Band "+ QString::number(p_band1));
    p_plot->setAxisTitle(QwtPlot::yLeft, cube2 + "   Band " + QString::number(p_band2));
    p_plot->replot();
    p_zoomer->setZoomBase();

    p_scatterPlotWindow->show();
    p_configDialog->setCursor(Qt::ArrowCursor);
    p_tool->setActionChecked(false);
  }
//REIXSXESMCPDetectorView::REIXSXESMCPDetectorView(REIXSXESMCPDetectorPre2013* detector, QWidget *parent) :
REIXSXESMCPDetectorView::REIXSXESMCPDetectorView(REIXSXESMCPDetector* detector, QWidget *parent) :
	QWidget(parent)
{
	detector_ = detector;

	// create UI elements
	imageView_ = new MPlotWidget();
	imagePlot_ = new MPlot();
	imageView_->setPlot(imagePlot_);
	image_ = new MPlotImageBasic();

	clearButton_ = new QPushButton("Clear All Counts");

	imageSelector_ = new QComboBox();
	averagingPeriodControl_ = new AMControlEditor(detector_->averagingPeriodControl());

	persistDurationControl_ = new AMControlEditor(detector_->persistDurationControl());

	countsPerSecondIndicator_ = new QLabel();
	countsPerSecondIndicator_->setFixedWidth(70);
	countsPerSecondIndicator_->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
	countsPerSecondBar_ = new QProgressBar();

	colorMapEditor_ = 0;

	///////////////////////

	// configure UI elements

	image_->setDescription("XES Detector Image");

	imagePlot_->axisScaleLeft()->setAutoScaleEnabled();
	imagePlot_->axisScaleBottom()->setAutoScaleEnabled();
	imagePlot_->axisScaleLeft()->setPadding(1);
	imagePlot_->axisScaleBottom()->setPadding(1);

	imagePlot_->addTool(new MPlotDragZoomerTool);
	imagePlot_->addTool(new MPlotWheelZoomerTool);

	imagePlot_->setMarginBottom(10);
	imagePlot_->setMarginLeft(10);
	imagePlot_->setMarginRight(5);
	imagePlot_->setMarginTop(5);


	imagePlot_->plotArea()->setBrush(QBrush(QColor(Qt::white)));
	imagePlot_->axisRight()->setTicks(4);
	imagePlot_->axisBottom()->setTicks(4);
	imagePlot_->axisLeft()->showGrid(false);
	imagePlot_->axisBottom()->showAxisName(false);
	imagePlot_->axisLeft()->showAxisName(false);

	MPlotColorMap colorMap(MPlotColorMap::Bone);
	colorMap.setContrast(2.1);
	colorMap.setBrightness(0.08);
	colorMap.setGamma(1.0);
	image_->setColorMap(colorMap);
	imagePlot_->addItem(image_);

	imageSelector_->addItem("Realtime Image");
	imageSelector_->addItem("Accumulated Image");
	imageSelector_->addItem("None");

	countsPerSecondBar_->setOrientation(Qt::Vertical);
	countsPerSecondBar_->setRange(0, 600);
	countsPerSecondBar_->setValue(0);
	countsPerSecondBar_->setFormat(QString());

	adjustColorMapButton_ = new QToolButton();
	adjustColorMapButton_->setText("Adjust colors...");

	///////////////////////

	// create layout
	QVBoxLayout* vl = new QVBoxLayout();
	QHBoxLayout* hl1 = new QHBoxLayout();
	QHBoxLayout* hl2 = new QHBoxLayout();
	QHBoxLayout* hl3 = new QHBoxLayout();
	QVBoxLayout* vl1 = new QVBoxLayout();

	hl1->addWidget(imageView_);
	vl1->addWidget(countsPerSecondBar_);
	vl1->addWidget(countsPerSecondIndicator_);
	hl1->addLayout(vl1);

	hl2->addWidget(adjustColorMapButton_);
	hl2->addStretch();
	hl2->addWidget(imageSelector_);
	hl2->addWidget(clearButton_);

	hl3->addWidget(new QLabel("Persist:"));
	hl3->addWidget(persistDurationControl_);
	hl3->addWidget(new QLabel("Averaging Period:"));
	hl3->addWidget(averagingPeriodControl_);

	vl->addLayout(hl1);
	vl->addLayout(hl2);
	vl->addLayout(hl3);

	setLayout(vl);

	//////////////////////

	// hookup signals:
	connect(clearButton_, SIGNAL(clicked()), detector_, SLOT(clear()));
	connect(imageSelector_, SIGNAL(currentIndexChanged(int)), this, SLOT(onImageSelectorChanged(int)));
	connect(detector_, SIGNAL(countsPerSecondChanged(double)), this, SLOT(onCountsPerSecondChanged(double)));

	connect(adjustColorMapButton_, SIGNAL(clicked()), this, SLOT(onAdjustColorMapButtonClicked()));


	//////////////////////////

	// connect the real-time data source to the plot image.
	onCountsPerSecondChanged(0);
	onImageSelectorChanged(0);

}
void BasicScreenShot::Init()
{
	GraphicManager& graphic = GraphicManager::GetInstance();
	auto& d3dStuff = Resource::D3DStuff;
	
	HRESULT hr;

	this->pScreenTexture.resize(this->numberOfTargets);
	this->pColorMapRTV.resize(this->numberOfTargets);

	std::vector<ID3D11Texture2D*> colorMap(this->numberOfTargets);

	D3D11_TEXTURE2D_DESC texDesc;
	ZeroMemory(&texDesc, sizeof(texDesc));
	texDesc.Width = this->width;
	texDesc.Height = this->height;
	texDesc.MipLevels = 0;
	texDesc.ArraySize = 1;
	texDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
	texDesc.SampleDesc.Count = 1;
	texDesc.SampleDesc.Quality = 0;
	texDesc.Usage = D3D11_USAGE_DEFAULT;
	texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
	texDesc.CPUAccessFlags = 0;
	texDesc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;

	
	for(unsigned int i = 0; i < this->numberOfTargets; ++i)
	{
		hr = d3dStuff.pd3dDevice->CreateTexture2D(&texDesc, 0, &colorMap[i]);
		if(FAILED(hr)){ Logger::LogError("Failed at creating the texture 2d for the BasicScreenShot"); }
	}

	for(unsigned int i = 0; i < this->numberOfTargets; ++i)
	{	
		// Null description means to create a view to all mipmap levels
		// using the format the texture was created with.
		ID3D11RenderTargetView*	pTempColorMapRTV;
		hr = d3dStuff.pd3dDevice->CreateRenderTargetView(colorMap[i], 0, &pTempColorMapRTV);
		if(FAILED(hr)){ Logger::LogError("Failed at creating render target view"); }
		this->pColorMapRTV[i] = pTempColorMapRTV;

	}

	for(unsigned int i = 0; i < this->numberOfTargets; ++i)
	{
		ID3D11ShaderResourceView* pTempScreenTexture;
		hr = d3dStuff.pd3dDevice->CreateShaderResourceView(colorMap[i], 0, &pTempScreenTexture);
		if(FAILED(hr)){ Logger::LogError("Failed at creating shader resource view"); }
		this->pScreenTexture[i] = pTempScreenTexture;
	}

	for(unsigned int i = 0; i < this->numberOfTargets; ++i)
	{
		// View saves a reference to the texture so we can release our reference.
		colorMap[i]->Release();
	}

	ID3D11Texture2D* depthMap = 0;
	ZeroMemory(&texDesc, sizeof(texDesc));
	texDesc.Width = this->width;
	texDesc.Height = this->height;
	texDesc.MipLevels = 1;
	texDesc.ArraySize = 1;
	texDesc.Format = DXGI_FORMAT_R32_TYPELESS;
	texDesc.SampleDesc.Count = 1;
	texDesc.SampleDesc.Quality = 0;
	texDesc.Usage = D3D11_USAGE_DEFAULT;
	texDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;

	texDesc.CPUAccessFlags = 0; 
	texDesc.MiscFlags = 0;

	hr = d3dStuff.pd3dDevice->CreateTexture2D(&texDesc, 0, &depthMap);
	if(FAILED(hr)){ Logger::LogError("Failed at creating shader resource view"); }

	D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
	ZeroMemory(&dsvDesc, sizeof(dsvDesc));
	dsvDesc.Format = DXGI_FORMAT_D32_FLOAT;
	dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
	dsvDesc.Texture2D.MipSlice = 0;
	ID3D11DepthStencilView*	pTempDepthMapDSV;
	hr = d3dStuff.pd3dDevice->CreateDepthStencilView(depthMap, &dsvDesc, &pTempDepthMapDSV);
	if(FAILED(hr)){ Logger::LogError("Failed at creating shader resource view"); }
	this->pDepthMapDSV = pTempDepthMapDSV;

	this->Viewport.TopLeftX = 0.0f;
	this->Viewport.TopLeftY = 0.0f;
	this->Viewport.Width = (FLOAT)this->width;
	this->Viewport.Height = (FLOAT)this->height;
	this->Viewport.MinDepth = 0.0f;
	this->Viewport.MaxDepth = 1.0f;
}