Anonymous avatar Anonymous committed c6251c4

intermediate commit for pull form mvdmain

Comments (0)

Files changed (9)

Code/Application/Monteverdi2/main.cxx

 // Monteverdi includes (sorted by alphabetic order)
 #include "mvdApplication.h"
 #include "mvdMainWindow.h"
+#include "Gui/mvdQtApplication.h"
 
 /*****************************************************************************/
 /* FUNCTIONS DECLARATION                                                     */
 int
 main( int argc, char* argv[] )
 {
-  QApplication qtApp( argc, argv );
+  mvd::QtApplication qtApp( argc, argv );
 
   // 0. Splash-screen.
 #if !defined( _DEBUG )

Code/Common/Core/mvdHistogramModel.cxx

   return percent;
 }
 
+void
+HistogramModel
+::GetCumulativeData( CountType band,
+	   double * x, double * y)
+{
+  assert( x!=NULL );
+  assert( y!=NULL );
+ Histogram::Pointer histogram( m_Histograms->GetNthElement( band ) );
+  assert( !histogram.IsNull() );
+
+  // Get number of bins for each dimension.
+  Histogram::SizeType size( histogram->GetSize() );
+
+  // Ensure dimension is 1.
+  assert( Histogram::MeasurementVectorSize==1 );
+
+unsigned int histoSize = size[0];
+  //unsigned int binmin = histogram->GetBinMin( 0, 0 );
+
+  x[ 0 ] = histogram->GetBinMin( 0, 0 );
+  y[ 0 ] = histogram->GetFrequency( 0, 0 );
+
+//std::cerr << histogram->GetTotalFrequency() << "::\n";
+
+
+  for( unsigned int i = 1;  i < histoSize; i++ )
+    {
+  Histogram::FrequencyType f( histogram->GetFrequency( i, 0 ) );
+    x[ i ] = histogram->GetBinMin( 0, i );
+    y[ i ] = f + y [ i - 1 ];
+    
+    }
+
+
+   // x = new double[ size[0] ];
+ //   y = new double[ size[0] ];
+//  double binmin = histogram->GetBinMin( 0, 0 );
+
+//std::cerr << size[0] << ":" <<  x[ 0 ] <<  ";;\n";
+}
 /*******************************************************************************/
 void
 HistogramModel
   xMin = histogram->GetBinMin( 0, 0 );
   xMax = histogram->GetBinMax( 0, size[ 0 ] - 1 );
 
+
   // Traverse samples.
+
   for( unsigned long bin=0; bin<size[ 0 ]; ++bin )
     {
     Histogram::FrequencyType f( histogram->GetFrequency( bin, 0 ) );
   assert( false && "Unknown HISTOGRAM_CURVE_TYPE value" );
 
 #endif
+
+//std::cerr << size[ 0 ] << std::endl;
+//exit(1);
+
     }
 }
 

Code/Common/Core/mvdHistogramModel.h

    */
   inline size_t GetDataCount( CountType band ) const;
 
+  void GetCumulativeData(CountType band, double * x, double * y);
+
   /**
    */
   void GetData( CountType band,

Code/Common/Gui/CMakeLists.txt

   mvdHistogramPlotPicker.cxx
   mvdHistogramWidget.cxx
   mvdI18nApplication.cxx
+  mvdQtApplication.cxx
   mvdI18nMainWindow.cxx
   mvdImageModelRenderer.cxx
   mvdImageViewManipulator.cxx
   mvdGLImageWidget.h
   #mvdGui.h
   mvdI18nApplication.h
+  mvdQtApplication.h
   mvdI18nMainWindow.h
   mvdImageModelRenderer.h
   mvdImageViewManipulator.h

Code/Common/Gui/mvdHistogramController.cxx

 
   if( !RgbwBounds( begin, end, channel ) )
     return;
+  
+
+
 
   const VectorImageModel::Settings& settings = imageModel->GetSettings();
 
     double* x = new double[ size ];
     double* y = new double[ size ];
 
+ size_t cdfsize = size;
+    double *cdfx = new double[ cdfsize ];
+    double *cdfy = new double[ cdfsize ];
+
+//if(chan == 0)
+ model->GetCumulativeData(band,cdfx,cdfy);
+ 
+
+//std::cerr << chan << ":" << band << ":\n";
+
 
     double xMin = std::numeric_limits< double >::quiet_NaN();
     double yMin = std::numeric_limits< double >::quiet_NaN();
 
     model->GetData( band, x, y, xMin, xMax, yMin, yMax );
 
-    size_t cdfsize = 100;
-    std::cerr << cdfsize << ":size\n";
-    double* cdfx = new double[ cdfsize ];
-    double* cdfy = new double[ cdfsize ];
-    cdfx[0] = 0;
-
-    for(int ww  = 1; ww < cdfsize; ww++)
-    {
-      cdfx[ww] = y[ww];
-      cdfy[ww] = cdf[ww-1] + y[ww];
-    }
-
     widget->SetData( chan, x, y,cdfx,cdfy, size, xMin, yMin, xMax, yMax, cdfsize);
 
     widget->SetLowMarker( chan, settings.GetLowIntensity( chan ) );
     delete x;
     x = NULL;
 
+    delete cdfx;
+    cdfx = NULL;
+    delete cdfy;
+    cdfy = NULL;
+
     delete y;
     y = NULL;
     }

Code/Common/Gui/mvdHistogramWidget.cxx

 
   //
   // CURVES.
+/*
 
     m_CdfCurves = new QwtPlotCurve( tr( "CDF" ) );
     m_CdfCurves->setStyle( QwtPlotCurve::Lines );
     m_CdfCurves->setPen( QPen( CURVE_COLORS[ 0 ] ) );
     //m_CdfCurves->setBrush( QBrush( CURVE_COLORS[ 0 ] ) );
 
-
+ m_CdfCurves->setVisible( true );
 m_CdfCurves->attach( m_UI->histogramPlot );
-
+*/
 
   HistogramPlotPicker::PlotCurveVector curves( HistogramWidget::CURVE_COUNT );
 
     delete m_PlotCurves[ i ];
     m_PlotCurves[ i ] = NULL;
 
+/*
+    delete m_CdfCurves;
+    m_CdfCurves = NULL;
+*/
     delete m_LowPlotMarkers[ i ];
     m_LowPlotMarkers[ i ] = NULL;
 
 void
 HistogramWidget
 ::SetData( RgbwChannel channel,
-	   double * const x, double * const y, double *cdf, size_t size,
+	   double * const x, double * const y, double * const cdfx, double * const cdfy, size_t size,
 	   double xMin, double yMin,
 	   double xMax, double yMax, size_t cdfsize )
 {
-  assert( ( x==NULL && y==NULL && size==0 ) ||
-	  ( x!=NULL && y!=NULL && size!=0 ) );
+  assert( ( x==NULL && y==NULL && size==0 && cdfx==NULL && cdfy==NULL ) ||
+	  ( x!=NULL && y!=NULL && size!=0 && cdfx!=NULL && cdfy!=NULL ));
 
   CountType begin = 0;
   CountType end = 0;
 
+
+    std::cerr << cdfsize << ":size\n";
+   
+/*
+    if( cdfx==NULL && cdfy==NULL )
+      m_CdfCurves->setVisible( false );
+else
+ m_CdfCurves->setData( cdfx, cdfy, cdfsize );
+*/
   if( !RgbwBounds( begin, end, channel ) )
     return;
 
     assert( m_PlotCurves[ i ]!=NULL );
 
     m_PlotCurves[ i ]->setData( x, y, size );
-    m_CdfCurves->setData( x, cdf, cdfsize );
+
+
 
     if( x==NULL && y==NULL )
       m_PlotCurves[ i ]->setVisible( false );
 
+
+
     /*
     qDebug()
       << RGBW_CHANNEL_NAMES[ i ]
 	  : i==index ); 
 
     m_PlotCurves[ i ]->setVisible( isVisible );
- m_CdfCurves->setVisible( true );
+
     m_LowPlotMarkers[ i ]->setVisible( isVisible );
     m_HighPlotMarkers[ i ]->setVisible( isVisible );
     }

Code/Common/Gui/mvdHistogramWidget.h

    */
   void SetData( RgbwChannel channel,
 		double * const x,
-		double * const y,double * const cdf,
+		double * const y,
+
+    double * const  cdfx, double * const cdfy,
+
 		size_t size,
 		double xMin, double yMin,
 		double xMax, double yMax, size_t cdfsize );
    */
   QwtPlotCurve* m_PlotCurves[ CURVE_COUNT ];
 
-  QwtPlotCurve* m_CdfCurves;
+//  QwtPlotCurve* m_CdfCurves;
   /**
    */
   QwtPlotMarker* m_LowPlotMarkers[ CURVE_COUNT ];

Code/Common/Gui/mvdQtApplication.cxx

+/*=========================================================================
+
+  Program:   ORFEO Toolbox
+  Language:  C++
+  Date:      $Date$
+  Version:   $Revision$
+
+
+  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
+  See OTBCopyright.txt for details.
+
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+
+=========================================================================*/
+#include "mvdQtApplication.h"
+#include <QObject>
+#include <iostream>
+
+namespace mvd
+{
+
+QtApplication::QtApplication(int& argc, char** argv)
+  : QApplication(argc, argv)
+{
+
+}
+
+bool
+QtApplication::notify(QObject *object, QEvent* event)
+{
+  try
+  {
+    return QApplication::notify(object, event);
+  }
+  catch (std::exception &ex)
+  {
+    /*
+    QString message = QString("<center><font color=\"#FF0000\">");
+    message.append(ex.what());
+    message.append("</font></center>");
+    emit UnhandledException(message);
+    */
+    std::cerr << ex.what() << std::endl;
+  }
+    return false;
+}
+
+} //end of namespace mvd

Code/Common/Gui/mvdQtApplication.h

+/*=========================================================================
+
+  Program:   ORFEO Toolbox
+  Language:  C++
+  Date:      $Date$
+  Version:   $Revision$
+
+
+  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
+  See OTBCopyright.txt for details.
+
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+
+=========================================================================*/
+
+#ifndef __mvdQtApplication_h
+#define __mvdQtApplication_h
+
+#include "ConfigureMonteverdi2.h"
+
+#include <QtGui>
+#include <QString>
+
+namespace mvd
+{
+
+class Monteverdi2_EXPORT QtApplication 
+  : public QApplication
+{
+  Q_OBJECT
+
+public:
+  QtApplication(int& argc, char** argv);
+
+  bool notify(QObject *object, QEvent* event);
+
+signals:
+
+  void UnhandledException(QString message);
+};
+
+} //end of namespace mvd
+
+#endif
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.