void
SoItkIsotropicFourthOrderLevelSetImageFilter::evaluate()
{
	if( mOutput )
	{
		mOutput->unref();
		mOutput = 0;
		SO_ENGINE_OUTPUT( Output, SoItkSFDataImage, setValue( 0 ) );
	}

	if( !Input0.getValue() )
		return ;
	
	if( !checkInput() )
	{
		SoDebugError::post( __FILE__, "Invalid Input Types" );
		return ;
	}

	try
	{
		switch( Input0.getValue()->getType() )
		{
			case SoItkDataImage::FLOAT:
			{
				switch( Input0.getValue()->getNumDimension() )
				{
					case 2:
					{
						typedef itk::Image< float, 2 > InputImageType;
						typedef itk::Image< float, 2 > OutputImageType;
						typedef itk::IsotropicFourthOrderLevelSetImageFilter< InputImageType, OutputImageType > FilterType;
						
						FilterType::Pointer filter = FilterType::New();
						
						// Set the filter's inputs
						SO_ITK_SET_FIELD_VALUE( filter, MaxFilterIteration );
						
						// Inherited from SoItkSparseFieldFourthOrderLevelSetImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, CurvatureBandWidth );
						SO_ITK_SET_FIELD_VALUE( filter, NumberOfLayers );
						SO_ITK_SET_FIELD_VALUE( filter, NormalProcessUnsharpWeight );
						SO_ITK_SET_FIELD_VALUE( filter, NormalProcessConductance );
						SO_ITK_SET_FIELD_VALUE( filter, NormalProcessUnsharpFlag );
						SO_ITK_SET_FIELD_VALUE( filter, RMSChangeNormalProcessTrigger );
						SO_ITK_SET_FIELD_VALUE( filter, MaxNormalIteration );
						SO_ITK_SET_FIELD_VALUE( filter, MaxRefitIteration );
						SO_ITK_SET_FIELD_VALUE( filter, NormalProcessType );
						
						// Inherited from SoItkSparseFieldLevelSetImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, NumberOfLayers );
						SO_ITK_SET_FIELD_VALUE( filter, IsoSurfaceValue );
						SO_ITK_SET_FIELD_VALUE( filter, InterpolateSurfaceLocation );
						
						// Inherited from SoItkFiniteDifferenceImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, UseImageSpacing );
						SO_ITK_SET_FIELD_VALUE( filter, NumberOfIterations );
						SO_ITK_SET_FIELD_VALUE( filter, RMSChange );
						SO_ITK_SET_FIELD_VALUE( filter, ManualReinitialization );
						SO_ITK_SET_FIELD_VALUE( filter, MaximumRMSError );
						
						// Inherited from SoItkInPlaceImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, InPlace );
						
						// Inherited from SoItkImageToImageFilter
						typedef itk::Image< float, 2 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 0, InputImageType );
						
						
						
						// Start processing the ouputs
						filter->Update();
						
						// Retrieve the filter's outputs
						filter->GetOutput()->Register();
						mOutput = new SoItkDataImage( SoItkDataImage::FLOAT, 2,
							Input0.getValue()->getModelMatrix() );
						mOutput->ref();
						mOutput->setPointer( filter->GetOutput() );
					}
					break ;
					case 3:
					{
						typedef itk::Image< float, 3 > InputImageType;
						typedef itk::Image< float, 3 > OutputImageType;
						typedef itk::IsotropicFourthOrderLevelSetImageFilter< InputImageType, OutputImageType > FilterType;
						
						FilterType::Pointer filter = FilterType::New();
						
						// Set the filter's inputs
						SO_ITK_SET_FIELD_VALUE( filter, MaxFilterIteration );
						
						// Inherited from SoItkSparseFieldFourthOrderLevelSetImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, CurvatureBandWidth );
						SO_ITK_SET_FIELD_VALUE( filter, NumberOfLayers );
						SO_ITK_SET_FIELD_VALUE( filter, NormalProcessUnsharpWeight );
						SO_ITK_SET_FIELD_VALUE( filter, NormalProcessConductance );
						SO_ITK_SET_FIELD_VALUE( filter, NormalProcessUnsharpFlag );
						SO_ITK_SET_FIELD_VALUE( filter, RMSChangeNormalProcessTrigger );
						SO_ITK_SET_FIELD_VALUE( filter, MaxNormalIteration );
						SO_ITK_SET_FIELD_VALUE( filter, MaxRefitIteration );
						SO_ITK_SET_FIELD_VALUE( filter, NormalProcessType );
						
						// Inherited from SoItkSparseFieldLevelSetImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, NumberOfLayers );
						SO_ITK_SET_FIELD_VALUE( filter, IsoSurfaceValue );
						SO_ITK_SET_FIELD_VALUE( filter, InterpolateSurfaceLocation );
						
						// Inherited from SoItkFiniteDifferenceImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, UseImageSpacing );
						SO_ITK_SET_FIELD_VALUE( filter, NumberOfIterations );
						SO_ITK_SET_FIELD_VALUE( filter, RMSChange );
						SO_ITK_SET_FIELD_VALUE( filter, ManualReinitialization );
						SO_ITK_SET_FIELD_VALUE( filter, MaximumRMSError );
						
						// Inherited from SoItkInPlaceImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, InPlace );
						
						// Inherited from SoItkImageToImageFilter
						typedef itk::Image< float, 3 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 0, InputImageType );
						
						
						
						// Start processing the ouputs
						filter->Update();
						
						// Retrieve the filter's outputs
						filter->GetOutput()->Register();
						mOutput = new SoItkDataImage( SoItkDataImage::FLOAT, 3,
							Input0.getValue()->getModelMatrix() );
						mOutput->ref();
						mOutput->setPointer( filter->GetOutput() );
					}
					break ;
				}
			}
			break ;
		}
	}
	catch( itk::ExceptionObject& e )
	{
		SoDebugError::post( e.GetFile(), "line %d: %s", e.GetLine(), e.GetDescription() );
		return ;
	}
	catch(...)
	{
		SoDebugError::post( __FILE__, "Unknown Exception" );
		return ;
	}

	SO_ENGINE_OUTPUT( Output, SoItkSFDataImage, setValue( mOutput ) );
}
Exemplo n.º 2
0
void ConfigurationDialog::on_databaseLocation_textChanged( const QString& text )
{
    checkInput();
}
void
SoItkInterpolateImageFilter::evaluate()
{
	if( mOutput )
	{
		mOutput->unref();
		mOutput = 0;
		SO_ENGINE_OUTPUT( Output, SoItkSFDataImage, setValue( 0 ) );
	}

	if( !Input0.getValue() )
		return ;
	
	if( !Input1.getValue() )
		return ;
	
	if( !checkInput() )
	{
		SoDebugError::post( __FILE__, "Invalid Input Types" );
		return ;
	}

	try
	{
		switch( Input1.getValue()->getNumDimension() )
		{
			case 2:
			{
				switch( Input1.getValue()->getType() )
				{
					case SoItkDataImage::FLOAT:
					{
						typedef itk::Image< float, 2 > InputImageType;
						typedef itk::Image< float, 2 > OutputImageType;
						typedef itk::InterpolateImageFilter< InputImageType, OutputImageType > FilterType;
						
						FilterType::Pointer filter = FilterType::New();
						
						// Set the filter's inputs
						SO_ITK_SET_FIELD_VALUE( filter, Distance );
						typedef itk::Image< float, 2 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 1, InputImageType );
						
						// Inherited from SoItkImageToImageFilter
						typedef itk::Image< float, 2 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 0, InputImageType );
						
						
						
						// Start processing the ouputs
						filter->Update();
						
						// Retrieve the filter's outputs
						filter->GetOutput()->Register();
						mOutput = new SoItkDataImage( SoItkDataImage::FLOAT, 2,
							Input0.getValue()->getModelMatrix() );
						mOutput->ref();
						mOutput->setPointer( filter->GetOutput() );
					}
					break ;
					case SoItkDataImage::UNSIGNED_SHORT:
					{
						typedef itk::Image< unsigned short, 2 > InputImageType;
						typedef itk::Image< unsigned short, 2 > OutputImageType;
						typedef itk::InterpolateImageFilter< InputImageType, OutputImageType > FilterType;
						
						FilterType::Pointer filter = FilterType::New();
						
						// Set the filter's inputs
						SO_ITK_SET_FIELD_VALUE( filter, Distance );
						typedef itk::Image< unsigned short, 2 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 1, InputImageType );
						
						// Inherited from SoItkImageToImageFilter
						typedef itk::Image< unsigned short, 2 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 0, InputImageType );
						
						
						
						// Start processing the ouputs
						filter->Update();
						
						// Retrieve the filter's outputs
						filter->GetOutput()->Register();
						mOutput = new SoItkDataImage( SoItkDataImage::UNSIGNED_SHORT, 2,
							Input0.getValue()->getModelMatrix() );
						mOutput->ref();
						mOutput->setPointer( filter->GetOutput() );
					}
					break ;
				}
			}
			break ;
			case 3:
			{
				switch( Input1.getValue()->getType() )
				{
					case SoItkDataImage::FLOAT:
					{
						typedef itk::Image< float, 3 > InputImageType;
						typedef itk::Image< float, 3 > OutputImageType;
						typedef itk::InterpolateImageFilter< InputImageType, OutputImageType > FilterType;
						
						FilterType::Pointer filter = FilterType::New();
						
						// Set the filter's inputs
						SO_ITK_SET_FIELD_VALUE( filter, Distance );
						typedef itk::Image< float, 3 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 1, InputImageType );
						
						// Inherited from SoItkImageToImageFilter
						typedef itk::Image< float, 3 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 0, InputImageType );
						
						
						
						// Start processing the ouputs
						filter->Update();
						
						// Retrieve the filter's outputs
						filter->GetOutput()->Register();
						mOutput = new SoItkDataImage( SoItkDataImage::FLOAT, 3,
							Input0.getValue()->getModelMatrix() );
						mOutput->ref();
						mOutput->setPointer( filter->GetOutput() );
					}
					break ;
					case SoItkDataImage::UNSIGNED_SHORT:
					{
						typedef itk::Image< unsigned short, 3 > InputImageType;
						typedef itk::Image< unsigned short, 3 > OutputImageType;
						typedef itk::InterpolateImageFilter< InputImageType, OutputImageType > FilterType;
						
						FilterType::Pointer filter = FilterType::New();
						
						// Set the filter's inputs
						SO_ITK_SET_FIELD_VALUE( filter, Distance );
						typedef itk::Image< unsigned short, 3 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 1, InputImageType );
						
						// Inherited from SoItkImageToImageFilter
						typedef itk::Image< unsigned short, 3 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 0, InputImageType );
						
						
						
						// Start processing the ouputs
						filter->Update();
						
						// Retrieve the filter's outputs
						filter->GetOutput()->Register();
						mOutput = new SoItkDataImage( SoItkDataImage::UNSIGNED_SHORT, 3,
							Input0.getValue()->getModelMatrix() );
						mOutput->ref();
						mOutput->setPointer( filter->GetOutput() );
					}
					break ;
				}
			}
			break ;
		}
	}
	catch( itk::ExceptionObject& e )
	{
		SoDebugError::post( e.GetFile(), "line %d: %s", e.GetLine(), e.GetDescription() );
		return ;
	}
	catch(...)
	{
		SoDebugError::post( __FILE__, "Unknown Exception" );
		return ;
	}

	SO_ENGINE_OUTPUT( Output, SoItkSFDataImage, setValue( mOutput ) );
}
Exemplo n.º 4
0
WHTMLReport::WHTMLReport(const CSMesUndoRedoFramework *c,QWidget* parent,  Qt::WFlags fl) : QDialog(parent, fl)
{
  document_types[CSMes::DOCUMENT_HTML]=tr("HTML");
  //document_types[CSMes::DOCUMENT_OPEN_OFFICE]=tr("OpenOffice");
  document_types[CSMes::DOCUMENT_XML]=tr("XML");
  csmes_p=c;
  setupUi(this);
  connect(buttons_p, SIGNAL(accepted()), this, SLOT(process()));
  connect(buttons_p, SIGNAL(rejected()), this, SLOT(reject()));
  QPushButton* apply_p = buttons_p->button(QDialogButtonBox::Apply);
  connect(apply_p, SIGNAL(clicked()), this, SLOT(apply()));
#if QT_COMPLETOR
  QStringList lru=Options::get_opt_strlst(QString(),"HTML_REPORT_FILE_NAME_HISTORY");
  file_completor_p = new QCompleter(file_p);
  file_completor_model_p=new QStringListModel(lru,file_completor_p);
  file_completor_p->setModel(file_completor_model_p);
  file_completor_p->setModelSorting(QCompleter::UnsortedModel);
  file_completor_p->setCompletionMode(QCompleter::PopupCompletion);
  file_p->setCompleter( file_completor_p );

  lru=Options::get_opt_strlst(QString(),"HTML_REPORT_TITLE_HISTORY");
  title_completor_p = new QCompleter(title_p);
  title_completor_model_p=new QStringListModel(lru,title_completor_p);
  title_completor_p->setModel(title_completor_model_p);
  title_completor_p->setModelSorting(QCompleter::UnsortedModel);
  title_completor_p->setCompletionMode(QCompleter::PopupCompletion);
  title_p->setCompleter( title_completor_p );

  lru=Options::get_opt_strlst(QString(),"HTML_REPORT_LAYOUT_CSS_HISTORY");
  css_file_completor_p = new QCompleter(css_file_p);
  css_file_completor_model_p=new QStringListModel(lru,css_file_completor_p);
  css_file_completor_p->setModel(css_file_completor_model_p);
  css_file_completor_p->setModelSorting(QCompleter::UnsortedModel);
  css_file_completor_p->setCompletionMode(QCompleter::PopupCompletion);
  css_file_p->setCompleter( css_file_completor_p );

  lru=Options::get_opt_strlst(QString(),"HTML_REPORT_LAYOUT_ICON_HISTORY");
  icon_completor_p = new QCompleter(icon_p);
  icon_completor_model_p=new QStringListModel(lru,icon_completor_p);
  icon_completor_p->setModel(icon_completor_model_p);
  icon_completor_p->setModelSorting(QCompleter::UnsortedModel);
  icon_completor_p->setCompletionMode(QCompleter::PopupCompletion);
  icon_p->setCompleter( icon_completor_p );
#endif

  file_type_p->clear();
  for (QMap<CSMes::DocumentType_t,QString>::const_iterator it=document_types.begin();it!=document_types.end();++it)
  {
    QString item=*it;
    file_type_p->addItem(item);
  }
  file_p->setText(Options::get_opt_str(QString(),"HTML_REPORT_FILE_NAME",file_p->text()));
  file_type_p->setCurrentIndex(Options::get_opt_long(QString(),"HTML_REPORT_FILE_TYPE"));
  css_file_p->setText(Options::get_opt_str(QString(),"HTML_REPORT_LAYOUT_CSS",css_file_p->text()));
  icon_p->setText(Options::get_opt_str(QString(),"HTML_REPORT_LAYOUT_ICON",icon_p->text()));
  title_p->setText(Options::get_opt_str(QString(),"HTML_REPORT_TITLE",title_p->text()));

  bargraph_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_BARGRAPH",bargraph_p->isChecked()));
  statistic_global_coverage_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_STATISTIC_SUMMARY",statistic_global_coverage_p->isChecked()));
  statistic_method_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_STATISTIC_METHOD",statistic_method_p->isChecked()));
  statistic_sources_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_STATISTIC_SOURCE",statistic_sources_p->isChecked()));
  statistic_executions_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_STATISTIC_EXECUTION",statistic_executions_p->isChecked()));
  code_fragments_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_CODE_FRAGMENTS",code_fragments_p->isChecked()));

  int coverage_level=Options::get_opt_int(QString(),"COVERAGE_LEVEL",1);
  global_coverage_level_p->setValue(coverage_level);
  global_coverage_output_all_level_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_SUMMARY_OUTPUT_ALL_LEVEL",global_coverage_output_all_level_p->isChecked()));
  global_coverage_output_selected_level_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_SUMMARY_OUTPUT_SELECTED_LEVEL",global_coverage_output_selected_level_p->isChecked()));
  global_coverage_output_selected_level_and_level_1_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_SUMMARY_OUTPUT_SELECTED_LEVEL_AND_LEVEL_ONE",global_coverage_output_selected_level_and_level_1_p->isChecked()));

  methods_level_p->setValue(coverage_level);
  methods_output_all_level_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_METHODS_OUTPUT_ALL_LEVEL",methods_output_all_level_p->isChecked()));
  methods_output_selected_level_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_METHODS_OUTPUT_SELECTED_LEVEL",methods_output_selected_level_p->isChecked()));
  methods_output_selected_level_and_level_1_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_METHODS_OUTPUT_SELECTED_LEVEL_AND_LEVEL_ONE",methods_output_selected_level_and_level_1_p->isChecked()));

  sources_level_p->setValue(coverage_level);
  sources_output_all_level_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_SOURCES_OUTPUT_ALL_LEVEL",sources_output_all_level_p->isChecked()));
  sources_output_selected_level_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_SOURCES_OUTPUT_SELECTED_LEVEL",sources_output_selected_level_p->isChecked()));
  sources_output_selected_level_and_level_1_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_SOURCES_OUTPUT_SELECTED_LEVEL_AND_LEVEL_ONE",sources_output_selected_level_and_level_1_p->isChecked()));

  executions_level_p->setValue(Options::get_opt_int(QString(),"HTML_REPORT_EXECUTIONS_COVERAGE_LEVEL",1));
  executions_output_all_level_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_EXECUTIONS_OUTPUT_ALL_LEVEL",executions_output_all_level_p->isChecked()));
  executions_output_selected_level_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_EXECUTIONS_OUTPUT_SELECTED_LEVEL",executions_output_selected_level_p->isChecked()));
  executions_output_selected_level_and_level_1_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_EXECUTIONS_OUTPUT_SELECTED_LEVEL_AND_LEVEL_ONE",executions_output_selected_level_and_level_1_p->isChecked()));

  toc_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_LAYOUT_TOC",toc_p->isChecked()));
  code_fragments_manually_validated_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_CODE_FRAGMENTS_MANUALLY_VALIDATED",code_fragments_manually_validated_p->isChecked()));
  code_fragments_unexecuted_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_CODE_FRAGMENTS_UNEXECUTED",code_fragments_unexecuted_p->isChecked()));
  code_fragments_executed_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_CODE_FRAGMENTS_EXECUTED",code_fragments_executed_p->isChecked()));

  executions_sorting_coverage_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_EXECUTIONS_SORTING_COVERAGE",executions_sorting_coverage_p->isChecked()));
  executions_sorting_name_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_EXECUTIONS_SORTING_NAME",executions_sorting_name_p->isChecked()));
  executions_filter_active_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_EXECUTIONS_FILTER_ACTIVE",executions_filter_active_p->isChecked()));
  executions_filter_min_p->setValue(Options::get_opt_double(QString(),"HTML_REPORT_EXECUTIONS_FILTER_MIN",executions_filter_min_p->value()));
  executions_filter_max_p->setValue(Options::get_opt_double(QString(),"HTML_REPORT_EXECUTIONS_FILTER_MAX",executions_filter_max_p->value()));

  sources_sorting_coverage_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_SOURCES_SORTING_COVERAGE",sources_sorting_coverage_p->isChecked()));
  sources_sorting_name_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_SOURCES_SORTING_NAME",sources_sorting_name_p->isChecked()));
  sources_filter_active_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_SOURCES_FILTER_ACTIVE",sources_filter_active_p->isChecked()));
  sources_filter_min_p->setValue(Options::get_opt_double(QString(),"HTML_REPORT_SOURCES_FILTER_MIN",sources_filter_min_p->value()));
  sources_filter_max_p->setValue(Options::get_opt_double(QString(),"HTML_REPORT_SOURCES_FILTER_MAX",sources_filter_max_p->value()));


  methods_sorting_coverage_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_METHODS_SORTING_COVERAGE",methods_sorting_coverage_p->isChecked()));
  methods_sorting_name_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_METHODS_SORTING_NAME",methods_sorting_name_p->isChecked()));
  methods_filter_active_p->setChecked(Options::get_opt_bool(QString(),"HTML_REPORT_METHODS_FILTER_ACTIVE",methods_filter_active_p->isChecked()));
  methods_filter_min_p->setValue(Options::get_opt_double(QString(),"HTML_REPORT_METHODS_FILTER_MIN",methods_filter_min_p->value()));
  methods_filter_max_p->setValue(Options::get_opt_double(QString(),"HTML_REPORT_METHODS_FILTER_MAX",methods_filter_max_p->value()));

  sources_watermark_medium_level_p->setValue(Options::get_opt_double(QString(),"MODULE_MEDIUM_COLOR_LEVEL",sources_watermark_medium_level_p->value()));
  sources_watermark_low_level_p->setValue(Options::get_opt_double(QString(),"MODULE_LOW_COLOR_LEVEL",sources_watermark_low_level_p->value()));
  methods_watermark_medium_level_p->setValue(Options::get_opt_double(QString(),"FUNCTION_MEDIUM_COLOR_LEVEL",methods_watermark_medium_level_p->value()));
  methods_watermark_low_level_p->setValue(Options::get_opt_double(QString(),"FUNCTION_LOW_COLOR_LEVEL",methods_watermark_low_level_p->value()));
  executed_by_limit_p->setValue(Options::get_opt_double(QString(),"EXECUTED_BY_LIMIT",executed_by_limit_p->value()));
  executions_watermark_medium_level_p->setValue(Options::get_opt_double(QString(),"HTML_REPORT_EXECUTIONS_MEDIUM_LEVEL"));
  executions_watermark_low_level_p->setValue(Options::get_opt_double(QString(),"HTML_REPORT_EXECUTIONS_LOW_LEVEL"));
  global_coverage_watermark_medium_level_p->setValue(Options::get_opt_double(QString(),"HTML_REPORT_SUMMARY_MEDIUM_LEVEL"));
  global_coverage_watermark_low_level_p->setValue(Options::get_opt_double(QString(),"HTML_REPORT_SUMMARY_LOW_LEVEL"));

  global_coverage_max_intermediate_levels_p->setValue(Options::get_opt_long(QString(),"HTML_REPORT_SUMMARY_MAX_LEVELS"));
  methods_max_intermediate_levels_p->setValue(Options::get_opt_long(QString(),"HTML_REPORT_METHODS_MAX_LEVELS"));
  executions_max_intermediate_levels_p->setValue(Options::get_opt_long(QString(),"HTML_REPORT_EXECUTIONS_MAX_LEVELS"));
  sources_max_intermediate_levels_p->setValue(Options::get_opt_long(QString(),"HTML_REPORT_SOURCES_MAX_LEVELS"));

  checkInput();

  connect(code_fragments_p,SIGNAL(toggled(bool)),this,SLOT(checkInput()));
  connect(statistic_executions_p,SIGNAL(toggled(bool)),this,SLOT(checkInput()));
  connect(methods_filter_active_p,SIGNAL(toggled(bool)),this,SLOT(checkInput()));
  connect(executions_filter_active_p,SIGNAL(toggled(bool)),this,SLOT(checkInput()));
  connect(sources_filter_active_p,SIGNAL(toggled(bool)),this,SLOT(checkInput()));
  connect(statistic_method_p,SIGNAL(toggled(bool)),this,SLOT(checkInput()));
  connect(statistic_sources_p,SIGNAL(toggled(bool)),this,SLOT(checkInput()));
  connect(statistic_global_coverage_p,SIGNAL(toggled(bool)),this,SLOT(checkInput()));
  connect(global_coverage_level_p,SIGNAL(valueChanged(int)),this,SLOT(checkInput()));
  connect(methods_level_p,SIGNAL(valueChanged(int)),this,SLOT(checkInput()));
  connect(sources_level_p,SIGNAL(valueChanged(int)),this,SLOT(checkInput()));
  connect(executions_level_p,SIGNAL(valueChanged(int)),this,SLOT(checkInput()));
  connect(executions_filter_min_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(executions_filter_max_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(sources_filter_min_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(sources_filter_max_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(methods_filter_min_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(methods_filter_max_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(sources_watermark_medium_level_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(sources_watermark_low_level_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(methods_watermark_medium_level_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(methods_watermark_low_level_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(executed_by_limit_p ,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(executions_watermark_medium_level_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(executions_watermark_low_level_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(global_coverage_watermark_medium_level_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(global_coverage_watermark_low_level_p,SIGNAL(valueChanged(double)),this,SLOT(checkInput()));
  connect(methods_output_all_level_p,SIGNAL(toggled(bool)),this,SLOT(checkInput()));
  connect(global_coverage_output_all_level_p,SIGNAL(toggled(bool)),this,SLOT(checkInput()));
  connect(sources_output_all_level_p,SIGNAL(toggled(bool)),this,SLOT(checkInput()));
  connect(executions_output_all_level_p,SIGNAL(toggled(bool)),this,SLOT(checkInput()));
}
Exemplo n.º 5
0
void WHTMLReport::on_file_type_p_activated(int)
{
   file_p->setText(QString());
   checkInput();
}
Exemplo n.º 6
0
void CalibrationScanAnalysis::analyze() {

#ifdef DEBUG_ON
  TFile* debugFile = new TFile("debug.root","RECREATE");
#endif
  
  // load data from files
  std::cout << "Loading data from files..." << std::endl;
  for(FileList::const_iterator it=files_.begin();it!=files_.end();++it) {
    getSummaries(it);
  }
  std::cout << endl;
  sortByGeometry();
  loadPresentValues();

  // sanity check
  if(!checkInput()) return;

  // check if both ISHA and VFS have to be tuned
  std::cout << "Preparing analysis..." << std::endl;
  int minISHA = 1000;
  int maxISHA = 0;
  int minVFS  = 1000;
  int maxVFS  = 0;
  for(FileList::const_iterator file=files_.begin();file!=files_.end();++file){
    int isha = file->first.first;
    int vfs  = file->first.second;
    minISHA = minISHA<isha ? minISHA : isha;
    maxISHA = maxISHA>isha ? maxISHA : isha;
    minVFS  = minVFS <vfs  ? minVFS  : vfs ;
    maxVFS  = maxVFS >vfs  ? maxVFS  : vfs ;
  }
  tuneISHA_ &= (minISHA!=maxISHA);
  tuneVFS_  &= (minVFS !=maxVFS );
  if(!tuneISHA_) std::cout << "ISHA tune disabled" << std::endl;
  if(!tuneVFS_ ) std::cout << "VFS  tune disabled" << std::endl;
  // two cases are possible:
  // ISHA tune: look at the rise time
  // VFS  tune: look at the tail

  // number of APVs
  unsigned int nAPVs = (*(summaries_.begin()->second.begin()))->GetNbinsX();

  // loop over the inputs to find individual values of ISHA ans VFS
  std::list<unsigned int> ishaValues;
  std::list<unsigned int> vfsValues;
  for(SummaryV::const_iterator summary = summaries_.begin(); summary!=summaries_.end(); ++summary) {
     ishaValues.push_back(summary->first.first);
     vfsValues.push_back(summary->first.second);
  }
  ishaValues.sort();
  vfsValues.sort();
  ishaValues.unique();
  vfsValues.unique();

  // loop over apvs (bins)
  std::cout << "Running analysis..." << std::endl;
  for(unsigned int apv=1;apv<=nAPVs;++apv) {
     TGraph* g1 = new TGraph();
     TGraph* g2 = new TGraph();
     int ii=0;
     cout << "\r" << setw(5) << setfill('0') << apv << flush; 

     // loop over the VFS values
     for(std::list<unsigned int>::const_iterator vfs = vfsValues.begin(); vfs!=vfsValues.end(); ++vfs,++ii) {
       float tail = 0.;
       unsigned int npts = 0;
       for(SummaryV::const_iterator summary = summaries_.begin(); summary!=summaries_.end(); ++summary){
         if((unsigned int)summary->first.second==(*vfs)) {
           // determine which histogram are the rise time and the tail
           const std::vector<TH1*>& observables = summary->second;
           int tail_index = 0;
           int rise_index = 0;
           for( std::vector<TH1*>::const_iterator histo = observables.begin();histo<observables.end();++histo) {
              std::string name = (*histo)->GetName();
              if(name.find("CalibrationTail")!=std::string::npos) tail_index = histo-observables.begin();
              if(name.find("CalibrationRiseTime")!=std::string::npos) rise_index = histo-observables.begin();
           }
	   //for vfs, we take the mean tail over the ISHA values at that point
	   tail += observables[tail_index]->GetBinContent(apv);
	   ++npts;
	 }
       }
       // fill the graph
       g2->SetPoint(ii,(*vfs), tail/npts);
     }
#ifdef DEBUG_ON
     std::string name2 = Form("graph%s%s",summaries_.begin()->second[0]->GetXaxis()->GetBinLabel(apv),"CalibrationTail");
     std::replace( name2.begin(), name2.end(), '.', '_' );
     g2->Write(name2.c_str());
#endif
     // analyse the graphs
     float best_vfs  = tuneVFS_  ? getX(g2,50) : 
                                   presentValues_[summaries_.begin()->second[0]->GetXaxis()->GetBinLabel(apv)].second;
     // now that VFS is optimized, take the ISHA values for the closest VFS point
     // for ISHA, we consider the rise time for VFS values close to the optimal

     // find the closest point in the VFS scan
     float dist = 1000.;
     std::list<unsigned int>::const_iterator vfsPoint = vfsValues.begin();
     for(std::list<unsigned int>::const_iterator vfs = vfsValues.begin(); vfs!=vfsValues.end(); ++vfs) {
       if(dist>fabs((*vfs)-best_vfs)) {
         dist = fabs((*vfs)-best_vfs);
	 vfsPoint = vfs;
       }
     }
     // loop over the ISHA values
     ii=0;
     for(std::list<unsigned int>::const_iterator isha = ishaValues.begin(); isha!=ishaValues.end(); ++isha,++ii) {
       for(SummaryV::const_iterator summary = summaries_.begin(); summary!=summaries_.end(); ++summary){
         if(((unsigned int)summary->first.second==(*vfsPoint))&&((unsigned int)summary->first.first==(*isha))) {
           // determine which histogram are the rise time and the tail
           const std::vector<TH1*>& observables = summary->second;
           int tail_index = 0;
           int rise_index = 0;
           for( std::vector<TH1*>::const_iterator histo = observables.begin();histo<observables.end();++histo) {
              std::string name = (*histo)->GetName();
              if(name.find("CalibrationTail")!=std::string::npos) tail_index = histo-observables.begin();
              if(name.find("CalibrationRiseTime")!=std::string::npos) rise_index = histo-observables.begin();
           }
	   // fill the graph
	   g1->SetPoint(ii,summary->first.first,observables[rise_index]->GetBinContent(apv));
#ifdef DEBUG_ON
           std::string name1 = Form("graph%s%s",summaries_.begin()->second[0]->GetXaxis()->GetBinLabel(apv),"CalibrationRiseTime");
           std::replace( name1.begin(), name1.end(), '.', '_' );
           g1->Write(name1.c_str());
#endif
	 }
       }
     }
     // analyse the graphs
     float best_isha = tuneISHA_ ? getX(g1,53.5 ) :
                                   presentValues_[summaries_.begin()->second[0]->GetXaxis()->GetBinLabel(apv)].first;

     // save the result
     result_[summaries_.begin()->second[0]->GetXaxis()->GetBinLabel(apv)] = std::make_pair((int)round(best_isha),(int)round(best_vfs));

     // cleaning
     delete g1;
     delete g2;
  }
  std::cout << std::endl;

#ifdef DEBUG_ON
  debugFile->Write();
  debugFile->Close();
  delete debugFile;
#endif

}
Exemplo n.º 7
0
Arquivo: cangc2.c Projeto: rocrail/GCA
void main(void) {
    unsigned char swTrig = 0;
    byte l3 = 1;

    lDelay();

    Wait4NN = FALSE;
    isLearning = FALSE;
    led1timer = 0;
    doSOD = 0;
    ioIdx = 0;
    doEV = 0;
    evIdx = 0;

    NV1 = eeRead(EE_NV);

    initIO();
    resetOutputs();

    NN_temp = eeRead(EE_NN) * 256;
    NN_temp += eeRead(EE_NN + 1);
    if (NN_temp == 0 || NN_temp == 0xFFFF)
        NN_temp = DEFAULT_NN;

    CANID = eeRead(EE_CANID);
    if (CANID == 0 || CANID == 0xFF)
        CANID = NN_temp & 0xFF;
    initCAN();

    delay();
    restoreOutputStates();
    delay();


    SOD = eeRead(EE_SOD) * 256;
    SOD += eeRead(EE_SOD + 1);
    if (SOD == 0 || SOD == 0xFFFF)
        SOD = DEFAULT_SOD;


    // Loop forever (nothing lasts forever...)
    while (1) {
        CANMsg cmsg;
        unsigned char txed = 0;
        LED3 = PORT_ON;
        l3 ^= 1;
        // Check for Rx packet and setup pointer to it
        while (canbusRecv(&cmsg)) {
            // Decode the new command
            LED1 = 1;
            led1timer = 20;
            txed = parseCmd(&cmsg);
        }
        LED3 = PORT_OFF;

        doTimedOff(ioIdx);

        if (checkInput(ioIdx, doSOD)) {
            ioIdx++;
            if (ioIdx >= 16) {
                ioIdx = 0;
                doSOD = 0;
            }
        }

        if (l3) {
            if (doPortEvent(evIdx)) {
                evIdx++;
                if (evIdx >= 16) {
                    evIdx = 0;
                    doEV = 0;
                }
            }
        }

        if (checkFlimSwitch() && !swTrig) {
            swTrig = 1;
        } else if (!checkFlimSwitch() && swTrig) {
            swTrig = 0;
            if (Wait4NN) {
                Wait4NN = 0;
                LED2 = 0;
            } else {
                CANMsg canmsg;
                LED2 = 1;
                canmsg.b[d0] = OPC_RQNN;
                canmsg.b[d1] = NN_temp / 256;
                canmsg.b[d2] = NN_temp % 256;
                canmsg.b[dlc] = 3;
                canbusSend(&canmsg);
                Wait4NN = 1;
            }
        }
    }
}
Exemplo n.º 8
0
void WExecutionTextDump::on_executed_format_p_textChanged( const QString & )
{
  checkInput();
}
void MainMenuScreen::update() {
    m_camera.update();
    checkInput();
}
Exemplo n.º 10
0
void
IOContext_SDL::cycle()
{
    checkInput();
    IOContext::cycle();
}
Exemplo n.º 11
0
void WExecutionTextDump::on_file_p_textChanged( const QString & )
{
  checkInput();
}
void
SoItkResampleImageFilter::evaluate()
{
	if( mOutput )
	{
		mOutput->unref();
		mOutput = 0;
		SO_ENGINE_OUTPUT( Output, SoItkSFDataImage, setValue( 0 ) );
	}

	if( !Input0.getValue() )
		return ;
	
	if( !checkInput() )
	{
		SoDebugError::post( __FILE__, "Invalid Input Types" );
		return ;
	}

	try
	{
		switch( Input0.getValue()->getType() )
		{
			case SoItkDataImage::FLOAT:
			{
				switch( Input0.getValue()->getNumDimension() )
				{
					case 2:
					{
						typedef itk::Image< float, 2 > InputImageType;
						typedef itk::Image< float, 2 > OutputImageType;
						typedef itk::ResampleImageFilter< InputImageType, OutputImageType > FilterType;
						
						FilterType::Pointer filter = FilterType::New();
						
						// Set the filter's inputs
						typedef double CoordinateRepresentationType;
						typedef itk::Transform< CoordinateRepresentationType, 2, 2 > TransformType;
						SO_ITK_SET_FIELD_DATA( filter, Transform, TransformType );
						SO_ITK_SET_FIELD_VALUE( filter, UseReferenceImage );
						SO_ITK_SET_FIELD_MATRIX( filter, OutputDirection, double, 2, 2 );
						SO_ITK_SET_FIELD_INDEX( filter, OutputStartIndex, 2 );
						SO_ITK_SET_FIELD_VALUE( filter, OutputSpacing );
						SO_ITK_SET_FIELD_POINT( filter, OutputOrigin, double, 2 );
						SO_ITK_SET_FIELD_SIZE( filter, Size, 2 );
						SO_ITK_SET_FIELD_VALUE( filter, DefaultPixelValue );
						
						// Inherited from SoItkImageToImageFilter
						typedef itk::Image< float, 2 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 0, InputImageType );
						
						
						
						// Start processing the ouputs
						filter->Update();
						
						// Retrieve the filter's outputs
						filter->GetOutput()->Register();
						mOutput = new SoItkDataImage( SoItkDataImage::FLOAT, 2,
							Input0.getValue()->getModelMatrix() );
						mOutput->ref();
						mOutput->setPointer( filter->GetOutput() );
					}
					break ;
					case 3:
					{
						typedef itk::Image< float, 3 > InputImageType;
						typedef itk::Image< float, 3 > OutputImageType;
						typedef itk::ResampleImageFilter< InputImageType, OutputImageType > FilterType;
						
						FilterType::Pointer filter = FilterType::New();
						
						// Set the filter's inputs
						typedef double CoordinateRepresentationType;
						typedef itk::Transform< CoordinateRepresentationType, 3, 3 > TransformType;
						SO_ITK_SET_FIELD_DATA( filter, Transform, TransformType );
						SO_ITK_SET_FIELD_VALUE( filter, UseReferenceImage );
						SO_ITK_SET_FIELD_MATRIX( filter, OutputDirection, double, 3, 3 );
						SO_ITK_SET_FIELD_INDEX( filter, OutputStartIndex, 3 );
						SO_ITK_SET_FIELD_VALUE( filter, OutputSpacing );
						SO_ITK_SET_FIELD_POINT( filter, OutputOrigin, double, 3 );
						SO_ITK_SET_FIELD_SIZE( filter, Size, 3 );
						SO_ITK_SET_FIELD_VALUE( filter, DefaultPixelValue );
						
						// Inherited from SoItkImageToImageFilter
						typedef itk::Image< float, 3 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 0, InputImageType );
						
						
						
						// Start processing the ouputs
						filter->Update();
						
						// Retrieve the filter's outputs
						filter->GetOutput()->Register();
						mOutput = new SoItkDataImage( SoItkDataImage::FLOAT, 3,
							Input0.getValue()->getModelMatrix() );
						mOutput->ref();
						mOutput->setPointer( filter->GetOutput() );
					}
					break ;
				}
			}
			break ;
			case SoItkDataImage::UNSIGNED_SHORT:
			{
				switch( Input0.getValue()->getNumDimension() )
				{
					case 2:
					{
						typedef itk::Image< unsigned short, 2 > InputImageType;
						typedef itk::Image< unsigned short, 2 > OutputImageType;
						typedef itk::ResampleImageFilter< InputImageType, OutputImageType > FilterType;
						
						FilterType::Pointer filter = FilterType::New();
						
						// Set the filter's inputs
						typedef double CoordinateRepresentationType;
						typedef itk::Transform< CoordinateRepresentationType, 2, 2 > TransformType;
						SO_ITK_SET_FIELD_DATA( filter, Transform, TransformType );
						SO_ITK_SET_FIELD_VALUE( filter, UseReferenceImage );
						SO_ITK_SET_FIELD_MATRIX( filter, OutputDirection, double, 2, 2 );
						SO_ITK_SET_FIELD_INDEX( filter, OutputStartIndex, 2 );
						SO_ITK_SET_FIELD_VALUE( filter, OutputSpacing );
						SO_ITK_SET_FIELD_POINT( filter, OutputOrigin, double, 2 );
						SO_ITK_SET_FIELD_SIZE( filter, Size, 2 );
						SO_ITK_SET_FIELD_VALUE( filter, DefaultPixelValue );
						
						// Inherited from SoItkImageToImageFilter
						typedef itk::Image< unsigned short, 2 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 0, InputImageType );
						
						
						
						// Start processing the ouputs
						filter->Update();
						
						// Retrieve the filter's outputs
						filter->GetOutput()->Register();
						mOutput = new SoItkDataImage( SoItkDataImage::UNSIGNED_SHORT, 2,
							Input0.getValue()->getModelMatrix() );
						mOutput->ref();
						mOutput->setPointer( filter->GetOutput() );
					}
					break ;
					case 3:
					{
						typedef itk::Image< unsigned short, 3 > InputImageType;
						typedef itk::Image< unsigned short, 3 > OutputImageType;
						typedef itk::ResampleImageFilter< InputImageType, OutputImageType > FilterType;
						
						FilterType::Pointer filter = FilterType::New();
						
						// Set the filter's inputs
						typedef double CoordinateRepresentationType;
						typedef itk::Transform< CoordinateRepresentationType, 3, 3 > TransformType;
						SO_ITK_SET_FIELD_DATA( filter, Transform, TransformType );
						SO_ITK_SET_FIELD_VALUE( filter, UseReferenceImage );
						SO_ITK_SET_FIELD_MATRIX( filter, OutputDirection, double, 3, 3 );
						SO_ITK_SET_FIELD_INDEX( filter, OutputStartIndex, 3 );
						SO_ITK_SET_FIELD_VALUE( filter, OutputSpacing );
						SO_ITK_SET_FIELD_POINT( filter, OutputOrigin, double, 3 );
						SO_ITK_SET_FIELD_SIZE( filter, Size, 3 );
						SO_ITK_SET_FIELD_VALUE( filter, DefaultPixelValue );
						
						// Inherited from SoItkImageToImageFilter
						typedef itk::Image< unsigned short, 3 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 0, InputImageType );
						
						
						
						// Start processing the ouputs
						filter->Update();
						
						// Retrieve the filter's outputs
						filter->GetOutput()->Register();
						mOutput = new SoItkDataImage( SoItkDataImage::UNSIGNED_SHORT, 3,
							Input0.getValue()->getModelMatrix() );
						mOutput->ref();
						mOutput->setPointer( filter->GetOutput() );
					}
					break ;
				}
			}
			break ;
		}
	}
	catch( itk::ExceptionObject& e )
	{
		SoDebugError::post( e.GetFile(), "line %d: %s", e.GetLine(), e.GetDescription() );
		return ;
	}
	catch(...)
	{
		SoDebugError::post( __FILE__, "Unknown Exception" );
		return ;
	}

	SO_ENGINE_OUTPUT( Output, SoItkSFDataImage, setValue( mOutput ) );
}
Exemplo n.º 13
0
int main(int argc, char **argv) {
	checkInput(argc, *(argv+1));	
	return 0;
	
}
int AvatarWalking::update(float p_dt, InputInfo p_inputInfo)
{
	Avatar* av = ((Avatar*)m_gameObject);

	checkInput(p_inputInfo);
	
	if (m_navigationData->m_desired != m_navigationData->m_direction)
	{
		if (check180())
		{
			Tile* destination = m_navigationData->m_map->getTile(
				m_navigationData->m_currentTile->getTilePosition() +
				Directions[m_navigationData->m_desired]);
			Tile* temp = m_navigationData->m_currentTile;
			m_navigationData->m_currentTile = m_navigationData->m_nextTile;
			m_navigationData->m_nextTile = m_navigationData->m_queuedTile = temp;
			if (destination && destination->isFree())
				m_navigationData->m_queuedTile = destination;
			m_navigationData->m_direction = m_navigationData->m_desired;
			m_navigationData->dt = 1 - m_navigationData->dt;
		}
		else
		{
			Tile* destination = m_navigationData->m_map->getTile(
				m_navigationData->m_nextTile->getTilePosition() +
				Directions[m_navigationData->m_desired]);
			if (destination && destination->isFree())
			{
				m_navigationData->m_queuedTile = destination;
				m_navigationData->m_direction = m_navigationData->m_desired;
			}
		}
	}
	float deltaMovement = p_dt*6;
	m_navigationData->dt += deltaMovement;

	if (m_gameStats && m_gameStats->isSpeeded())
		m_navigationData->dt += p_dt * 3;

	if (m_navigationData->m_currentTile && (m_navigationData->m_direction != Direction::NONE) )
	{
		while (m_navigationData->dt > 1)
		{
			m_navigationData->dt -= 1;
			m_navigationData->m_currentTile = m_navigationData->m_nextTile;
			m_navigationData->m_nextTile = m_navigationData->m_queuedTile;

			m_navigationData->m_queuedTile = m_navigationData->m_map->getTile(
				m_navigationData->m_nextTile->getTilePosition() +
				Directions[av->getDirection()]);
			if (!m_navigationData->m_queuedTile ||
				!m_navigationData->m_queuedTile->isFree())
				m_navigationData->m_queuedTile = m_navigationData->m_nextTile;

			m_navigationData->m_currentTile->removePill();
		}
	}
	else
		m_navigationData->dt = 0;

	determineAnimation();

	return GAME_OK;
}
Exemplo n.º 15
0
/*
 * this is called from the Go button
 */
void
CommandDlg::slotLauchCommand()
{
  //QString str;
  QString args;

  if (childProcess.isRunning()) {
    return;
  }

  args = commandArgs->text();
  //CB args = commandArgs->currentText();//CB
  if (strlen(args) == 0) {
    // nothing to do (this should not be possible)
  } else {

    // Check the input
    if (!checkInput(&args)) {
      //warning("input not valid");
      commandArgs->selectAll();
      KApplication::beep();
      return;
    }

    // Install the "Stop" button, and hide "Go!"
    commandGoBtn->setEnabled(FALSE);
    commandStopBtn->setEnabled(TRUE);

    // Install waitCursor
    installWaitCursor();

    // separate commands with CR/LF
    if (commandTextArea->numLines() > 1) {
      int line;
      line = QMAX(commandTextArea->numLines()-2, 0);
      if (strlen(commandTextArea->textLine(line)) > 0) {
	commandTextArea->append("");
      }
    }

    //  Process creation
    if (!buildCommandLine(args)) {
      QString errorString;
      debug("buildCommandLine = FALSE");
      // Same message in MtrDlg.cpp
      errorString.sprintf(i18n("\nYou have a problem in your\n" 
			    "%s/%src\nconfiguration file.\n"
			    "In the [%s] group,\nI can't "
			    "find a valid \"path=\" entry.\n\n"
			    "Please use Edit->Preferences... menu\n"
			    "to configure it again.\n"), 
			  (const char *)kapp->localconfigdir(), 
			  (const char *)kapp->appName(), 
			  (const char *)removeAmpersand(this->name()));
      KMsgBox::message(this, i18n("Error in pathname"), 
		       errorString, KMsgBox::STOP);
      slotProcessDead(NULL);
      return;
    }

    connect(&childProcess, SIGNAL(processExited(KProcess *)), 
	    SLOT(slotProcessDead(KProcess *)));

    connect(&childProcess, SIGNAL(receivedStdout(KProcess *, char *, int)), 
	    this, SLOT(slotCmdStdout(KProcess *, char *, int)));
    connect(&childProcess, SIGNAL(receivedStderr(KProcess *, char *, int)), 
	    this, SLOT(slotCmdStdout(KProcess *, char *, int)));

    // Test pour mtr: pb stdin?
//    if (!childProcess.start(KProcess::NotifyOnExit, KProcess::AllOutput)) {
    if (!childProcess.start(KProcess::NotifyOnExit, KProcess::All)) {
      // Process not started
      debug("Process not started");
      slotProcessDead(NULL);
      return;
    }
  }
}
Exemplo n.º 16
0
void DialogKvp::apply(){

	if (checkInput(lineEditLastNameP,tr("Введите пожалуйста\nфамилию поручителя"),1)&&
		checkInput(lineEditFirstNameP,tr("Введите пожалуйста\nимя поручителя"),1)&&
		checkInput(lineEditMidNameP,tr("Введите пожалуйста\nотчество поручителя"),1)&&

		checkInput(spinBoxPaspSerP,tr("Введите пожалуйста\nсерию паспорта поручителя"),1)&&
		checkInput(spinBoxPaspNumP,tr("Введите пожалуйста\nномер паспорта поручителя"),1)&&
		checkInput(lineEditPaspPlaceP,tr("Введите пожалуйста\nкем выдан паспорт сотруднику"),1)&&

		checkInput(spinBoxPostP,tr("Введите пожалуйста\nиндекс поручителя"),1)&&
		checkInput(lineEditCityP,tr("Введите пожалуйста\nгород поручителя"),1)&&
		checkInput(lineEditStreetP,tr("Введите пожалуйста\nулицу поручителя"),1)&&
		checkInput(spinBoxHouseP,tr("Введите пожалуйста\nдом поручителя"),1)&&

		checkInput(lineEditDolgmP,tr("Введите пожалуйста\nдолжность поручителя"),1)&&
		checkInput(lineEditRabotaP,tr("Введите пожалуйста\n место работы поручителя"),1)&&
		checkInput(lineEditDogNumP,tr("Введите пожалуйста\n номер договора"),1)&&

		checkInput(lineEditBank,tr("Введите пожалуйста\nнаименование банка"),2)&&
		checkInput(lineEditDogNumS,tr("Введите пожалуйста\nномер договора"),2)&&
		checkInput(lineEditProtokolNum,tr("Введите пожалуйста\nномер протокола"),2)&&
		checkInput(lineEditSchetNum,tr("Введите пожалуйста\nномер счета"),2)&&
		checkInput(lineEditNazS,tr("Введите пожалуйста\nназначение суммы"),2)&&
		checkInput(spinBoxSummaS,tr("Введите пожалуйста\nсумму числом"),2)&&
		checkInput(lineEditSummaS,tr("Введите пожалуйста\nсумму текстом"),2)&&
		checkInput(spinBoxSrokS,tr("Введите пожалуйста\nсрок числом"),2)&&
		checkInput(lineEditSrokS,tr("Введите пожалуйста\nсрок текстом"),2)

		){
			accept();

		}
}
Exemplo n.º 17
0
void PlayState::update()
{
	// Shake the background up and down when bomb is used
	if(bombAnimation)
	{
		bombAnimationCount++;
		bombShakeCounter++;
		// Up
		if(bombShakeCounter < 5)
		{
			starsBG_Pos.y -= 2;
		}
		// Down + Down
		else if(bombShakeCounter < 15)
		{
			starsBG_Pos.y += 2;
		}
		// Up
		else if(bombShakeCounter < 20)
		{
			starsBG_Pos.y -= 2;
		}
		// Reset
		else
		{
			bombShakeCounter = 0;
			--starsBG_Pos.y;
		}

		if(bombAnimationCount == BOMB_ANIMATION_LENGTH)
		{
			bombAnimationCount = 0;
			bombAnimation = false;
		}
	}

	// Move BG
	++bgMoveCounter;

	if(bgMoveCounter > 2)
	{
		++starsBG_Pos.x;
		bgMoveCounter = 0;
	}

	REG_BG0VOFS = starsBG_Pos.y;
	REG_BG0HOFS = starsBG_Pos.x;

	updateText();

	// Update the stage
	currentStage->update();

	// Checks for button pushes and updates accordingly
	checkInput();

	updatePlayer();
	
	// Udates the PowerUp and checks for collisions
	updatePowerUp();

	// Updates all of the enemies and has them fire.
	updateEnemies();

	// Updates all of the bullets and checks for collisions
	updateBullets();
}
Exemplo n.º 18
0
void EditIndexDialog::updateColumnLists()
{
    // Fill the table column list
    sqlb::FieldInfoList tableFields = pdb.getObjectByName(index.table()).dynamicCast<sqlb::Table>()->fieldInformation();
    ui->tableTableColumns->setRowCount(tableFields.size());
    int tableRows = 0;
    for(int i=0;i<tableFields.size();++i)
    {
        // When we're doing the initial loading and this field already is in the index to edit, then don't add it to the
        // list of table columns. It will be added to the list of index columns in the next step. When this is not the initial
        // loading, the index column list is empty, so this check will always be true.
        if(index.findColumn(tableFields.at(i).name) == -1)
        {
            // Put the name of the field in the first column
            QTableWidgetItem* name = new QTableWidgetItem(tableFields.at(i).name);
            name->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
            ui->tableTableColumns->setItem(tableRows, 0, name);

            // Put the data type in the second column
            QTableWidgetItem* type = new QTableWidgetItem(tableFields.at(i).type);
            type->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
            ui->tableTableColumns->setItem(tableRows, 1, type);

            tableRows++;
        }
    }

    // Set row count to actual count. This is needed for the intial loading, when some rows might have been omitted because they were used in the index
    ui->tableTableColumns->setRowCount(tableRows);

    // Fill the index column list. This is done separately from the table column to include expression columns (these are not found in the original
    // table) and to preserve the order of the index columns
    auto indexFields = index.columns();
    ui->tableIndexColumns->blockSignals(true);
    ui->tableIndexColumns->setRowCount(indexFields.size());
    for(int i=0;i<indexFields.size();++i)
    {
        // Put the name of the field in the first column
        QTableWidgetItem* name = new QTableWidgetItem(indexFields.at(i)->name());
        Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
        if(indexFields.at(i)->expression())
            flags |= Qt::ItemIsEditable;
        name->setFlags(flags);
        ui->tableIndexColumns->setItem(i, 0, name);

        // And put a combobox to select the order in which to index the field in the last column
        QComboBox* order = new QComboBox(this);
        order->addItem("");
        order->addItem("ASC");
        order->addItem("DESC");
        order->setCurrentText(indexFields.at(i)->order().toUpper());
        ui->tableIndexColumns->setCellWidget(i, 1, order);
        connect(order, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentTextChanged),
                [=](QString new_order)
        {
            int colnum = index.findColumn(indexFields.at(i)->name());
            if(colnum != -1)
            {
                index.column(colnum)->setOrder(new_order);
                updateSqlText();
            }
        });
    }
    ui->tableIndexColumns->blockSignals(false);

    checkInput();
}
Exemplo n.º 19
0
int KyraEngine_MR::o3_daggerWarning(EMCState *script) {
	debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3_daggerWarning(%p) ()", (const void *)script);
	int selection = 1;

	_screen->hideMouse();
	_screen->copyRegionToBuffer(1, 0, 0, 320, 200, _screenBuffer);
	int curPageBackUp = _screen->_curPage;
	_screen->_curPage = 2;

	_screen->drawFilledBox(0, 0, 0x13F, 0xC7, 0xB4, 0xB3, 0xB6);
	_screen->drawFilledBox(0xF, 0xAA, 0x68, 0xBA, 0xB4, 0xB3, 0xB6);
	_screen->drawFilledBox(0x73, 0xAA, 0xCC, 0xBA, 0xB4, 0xB3, 0xB6);
	_screen->drawFilledBox(0xD6, 0xAA, 0x12F, 0xBA, 0xB4, 0xB3, 0xB6);

	int y = 15;
	for (int i = 100; i <= 107; ++i) {
		const char *str = (const char *)getTableEntry(_cCodeFile, i);
		int x = _text->getCenterStringX(str, 0, 0x13F);
		_text->printText(str, x, y, 0xFF, 0xF0, 0x00);
		y += 10;
	}
	y += 15;
	for (int i = 110; i <= 113; ++i) {
		const char *str = (const char *)getTableEntry(_cCodeFile, i);
		int x = _text->getCenterStringX(str, 0, 0x13F);
		_text->printText(str, x, y, 0xFF, 0xF0, 0x00);
		y += 10;
	}

	const char *str = 0;
	int x = 0;

	str = (const char *)getTableEntry(_cCodeFile, 120);
	x = _text->getCenterStringX(str, 0xF, 0x68);
	_text->printText(str, x, 174, 0xFF, 0xF0, 0x00);

	str = (const char *)getTableEntry(_cCodeFile, 121);
	x = _text->getCenterStringX(str, 0x73, 0xCC);
	_text->printText(str, x, 174, 0xFF, 0xF0, 0x00);

	str = (const char *)getTableEntry(_cCodeFile, 122);
	x = _text->getCenterStringX(str, 0xD6, 0x12F);
	_text->printText(str, x, 174, 0xFF, 0xF0, 0x00);

	_screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0);
	_screen->updateScreen();

	_screen->_curPage = curPageBackUp;
	_screen->showMouse();

	while (!shouldQuit()) {
		int keys = checkInput(0);
		removeInputTop();

		if (keys == 198 || keys == 199) {
			if (_mouseX >= 15 && _mouseX <= 104 && _mouseY >= 170 && _mouseY <= 186) {
				selection = 1;
				break;
			} else if (_mouseX >= 115 && _mouseX <= 204 && _mouseY >= 170 && _mouseY <= 186) {
				selection = 2;
				break;
			} else if (_mouseX >= 214 && _mouseX <= 303 && _mouseY >= 170 && _mouseY <= 186) {
				selection = 3;
				break;
			}
		}

		delay(10);
	}

	restorePage3();
	_screen->copyBlockToPage(1, 0, 0, 320, 200, _screenBuffer);
	return selection;
}
Exemplo n.º 20
0
int fakeidentd_main(int argc, char **argv)
{
	memset(conns, 0, sizeof(conns));
	memset(&G, 0, sizeof(G));
	FD_ZERO(&G.readfds);
	FD_SET(0, &G.readfds);

	/* handle -b <ip> parameter */
	bb_getopt_ulflags(argc, argv, "b:", &bind_ip_address);
	/* handle optional REPLY STRING */
	if (optind < argc)
		G.identuser = argv[optind];
	else
		G.identuser = nobodystr;

	/* daemonize and have the parent return */
	if (godaemon() == 0)
		return 0;

	/* main loop where we process all events and never exit */
	while (1) {
	fd_set rfds = G.readfds;
	struct timeval tv = { 15, 0 };
	int i;
	int tim = time(NULL);

	select(G.conncnt + FCS, &rfds, NULL, NULL, G.conncnt? &tv: NULL);

	for (i = G.conncnt - 1; i >= 0; i--) {
		int s = i + FCS;

		if (FD_ISSET(s, &rfds)) {
			char *buf = conns[i].buf;
			unsigned int len = conns[i].len;
			unsigned int l;

			if ((l = read(s, buf + len, sizeof(conns[0].buf) - len)) > 0) {
				if (checkInput(buf, len, l)) {
					reply(s, buf);
					goto deleteconn;
				} else if (len + l >= sizeof(conns[0].buf)) {
					replyError(s, "X-INVALID-REQUEST");
					goto deleteconn;
				} else {
					conns[i].len += l;
				}
			} else {
				goto deleteconn;
			}

			conns[i].lasttime = tim;
			continue;

deleteconn:
			deleteConn(s);
		} else {
			/* implement as time_after() in linux kernel sources ... */
			if (conns[i].lasttime + MAXIDLETIME <= tim) {
				replyError(s, "X-TIMEOUT");
				deleteConn(s);
			}
		}
	}

	if (FD_ISSET(0, &rfds)) {
		int s = accept(0, NULL, 0);

		if (s < 0) {
			if (errno != EINTR) /* EINTR */
				syslog(LOG_ERR, "accept: %s", strerror(errno));
		} else {
			if (G.conncnt == MAXCONNS)
				i = closeOldest();
			else
				i = G.conncnt++;

			movefd(s, i + FCS); /* move if not already there */
			FD_SET(i + FCS, &G.readfds);

			conns[i].len = 0;
			conns[i].lasttime = time(NULL);
		}
	}
	} /* end of while(1) */

	return 0;
}
Exemplo n.º 21
0
void __fastcall TDicSupplierForm::btnOK0Click(TObject *Sender)
{
        if ( !checkInput() )
        {
                ShowMessage("输入信息不全");
                return;
        }

  int nState;
  CString szSQL;
  szSQL="";
  switch(m_enWorkState)
  {
    case EN_ADDNEW:
      szSQL.Format("insert into supplier(spid, name, address, tel, fax, \
                        chargeman, tel_lk, settlement_type, remarks_busi_license, \
                        reputation, bank, bank_account, huming) \
                        values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", \
                        edtSpId->Text, edtName->Text, edtAddress->Text, edtTel->Text, edtFax->Text, \
                        edtChargeMan->Text, edtTelLinkMan->Text, cbbSettlementType->Text, cbbLicense->Text, \
                        cbbReputation->Text, edtBank->Text, edtBankAccount->Text, getByEdt(edtHuMing).c_str());
      break;
    case EN_EDIT:
      szSQL.Format("update supplier set name='%s',  address='%s',  tel='%s',  fax='%s',  \
                        chargeman='%s',  tel_lk='%s', settlement_type='%s',  remarks_busi_license='%s',  \
                        reputation='%s',  bank='%s',  bank_account='%s', huming='%s' where spid='%s'",  \
                        edtName->Text, edtAddress->Text, edtTel->Text, edtFax->Text, \
                        edtChargeMan->Text, edtTelLinkMan->Text, cbbSettlementType->Text, cbbLicense->Text, \
                        cbbReputation->Text, edtBank->Text, edtBankAccount->Text, getByEdt(edtHuMing).c_str(), edtSpId->Text);
//      edtDebug->Text = AnsiString(szSQL);
      break;
    default:
      ShowMessage("Work State not AddNew or Edit");
      return;
  }
//  edtDebug->Text = AnsiString(szSQL);
  if(!dm1->OpenDatabase())  return;

  try
  {
    if(m_enWorkState==EN_ADDNEW)
    {
      char strAddSQL[256];
      sprintf(strAddSQL,"select * from supplier where spid='%s'", edtSpId->Text);
      RunSQL(strAddSQL,true);
      if(dm1->Query1->RecordCount>0)
      {
        ShowMessage("数据库中已有该编号的记录!");
        edtSpId->SetFocus();
        return;
      }
    }
    RunSQL(szSQL);
  }
  catch(...)
  {
    ShowMessage("数据库操作错误!");
    return;
  }

  TListItem *pItem;
  if(m_enWorkState==EN_ADDNEW)
  {
    pItem=ListView1->Items->Add();
    Editor2RowAdd(pItem);
    ListView1->Selected=pItem;
  }
  else if(m_enWorkState==EN_EDIT)
  {
    pItem=ListView1->Selected;
    Editor2RowUpdate(pItem);
  }

  nState=m_enWorkState;
  m_enWorkState=EN_IDLE;
  ResetCtrl();
  msgState->Caption="工作状态:查询";
  switch(nState)
  { //设置确定後的光标位置
    case EN_ADDNEW: btnAddNew->SetFocus();  break;
    case EN_EDIT:   btnEdit->SetFocus();    break;
    default:  break;
  }
}
Exemplo n.º 22
0
int main(int argc, char * argv[])
{
  uid_t nobody, nogrp;
  
  memset(conns, 0, sizeof conns);
  memset(&G, 0, sizeof G);
  FD_ZERO(&G.readfds);
  FD_SET(0, &G.readfds);
  
  if (argv[1])
  {
      if (argv[1][0] == '-')
      {
	  if (argv[1][1] == 'V')
	  {
	      printversion('.');
	      return 0;
	  }
	  else
	  {
	      fdprintf(2, "%s: invalid option -- %c\n", argv[0], argv[1][1]);
	      fdprintf(2, "Usage: %s [-V] " IU_IN_USAGESTR "\n", argv[0]);
	      return 1;
	  }
      }
      else
      {
	  SET_IU(argv[1], argc - 1);
      }
  }
  else
  {
      SET_IU(nobodystr, 1);
  }
  
  
#ifndef DEBUG
  close(1); /* not debugging, openlog() hopefully uses fd 1. */
#else
  close(3); /* debugging, TRACE uses fd 1, openlog() hopefully fd 3 */
#endif
  
  openlog("identd", LOG_CONS, LOG_DAEMON);
  
  {
      struct passwd * pw = getpwnam(nobodystr);
      
      if (pw)
      {
	  nobody = pw->pw_uid;
	  nogrp = pw->pw_gid;
      }
      else
      {
	  syslog(LOG_CRIT, "Cannot find user `nobody': %s", strerrno());
	  return -1;
      }
  }
  
  if (inetbind(getport()) < 0)
  {
      return -1;
  }
  
  /* */
  {
      int			 i;
      
      for (i = FCS; i < MAXCONNS + FCS; i++)
      {
	  close(i);
      }
  }
  
#ifdef DEBUG
#ifndef LOG_PERROR
#define LOG_PERROR 0
#endif
  openlog("identd", LOG_PERROR, LOG_DAEMON);
#else /* not DEBUG */
  godaemon();
  openlog("identd", 0, LOG_DAEMON);
  close(2);
  signal(SIGHUP, SIG_IGN);
#endif /* DEBUG */
  
  signal(SIGPIPE, SIG_IGN); /* connection closed when writing (raises ???) */
  
  writepid(nobody, nogrp);
  
  setegid(nogrp); setgid(nogrp); setuid(nobody); seteuid(nobody);
  
  {
      int i;
      
      for (i = 0; i < 4; i++)
      {
	  char *	id = (char)NULL;
	  unsigned int	rv = 0;
	  
	  switch (i)
	  {
	  case 0:
	    rv = (unsigned int)getegid();
	    id = "egid";
	    break;
	  case 1:
	    rv = (unsigned int)getgid();
	    id = "gid";
	    break;
	  case 2:
	    rv = (unsigned int)geteuid();
	    id = "euid";
	    break;
	  case 3:
	    rv = (unsigned int)getuid();
	    id = "uid";
	    break;
	  }
	  
	  if (rv == 0)
	  {
	      syslog(LOG_ERR,
		     "Can not drop all root privileges (%s) !!! %s !!!",
		     id, strerrno());
	      delpidfile();
	      return -1;
	  }
      }
  }
  
  while (2)
  {
      fd_set		rfds = G.readfds;
      struct timeval	tv = { 15, 0 };
      int		i;
      int		tim = time(NULL);
      
      TRACE(("calling select(): n = %d, rfds = 0x%x\n\n",
	     G.conncnt + FCS, *(int *)&rfds));
      
      select(G.conncnt + FCS, &rfds, NULL, NULL, G.conncnt? &tv: NULL);
      
      for (i = G.conncnt - 1; i >= 0; i--)
      {
	  int s = i + FCS;
	  
	  if (FD_ISSET(s, &rfds))
	  {
	      char *		buf = conns[i].buf;
	      unsigned int	len = conns[i].len;
	      unsigned int	l;
	      
	      TRACE(("data socket fd_isset %d\n", s));
	      
	      if ((int)(l = read(s, buf + len, sizeof conns[0].buf - len)) > 0)
	      {
		  if (checkInput(buf, len, l))
		  {
		      reply(s, buf);
		      goto deleteconn;
		  }
		  else if (len + l >= sizeof conns[0].buf)
		  {
		      replyError(s, "X-INVALID-REQUEST");
		      goto deleteconn;
		  }
		  else
		  {
		      conns[i].len += l;
		  }
	      }
	      else
	      {
		  goto deleteconn;
	      }
	      
	      conns[i].lasttime = tim;
	      continue;
	      
	  deleteconn:
	      deleteConn(s);
	  }
	  else
	  {
	      /* implement as time_after() in linux kernel sources ... */
	      if (conns[i].lasttime + MAXIDLETIME <= tim)
	      {
		  replyError(s, "X-TIMEOUT");
		  deleteConn(s);
	      }
	  }
      }
      
      if (FD_ISSET(0, &rfds))
      {
	  int s = accept(0, NULL, 0);
	  
	  TRACE(("server socket fd_isset, %d accepted\n", s));
	  
	  if (s < 0)
	  {
	      if (errno != EINTR) /* EINTR */
	      {
		  syslog(LOG_ERR, "accept: %s", strerrno());
	      }
	  }
	  else
	  {
	      if (G.conncnt == MAXCONNS)
	      {
		  i = closeOldest();
	      }
	      else
	      {
		  i = G.conncnt++;
	      }
	      
	      if (s != i + FCS)
	      {
		  movesocket(s, i + FCS);
	      }
	      
	      FD_SET(i + FCS, &G.readfds);
	      
	      conns[i].len = 0;
	      conns[i].lasttime = time(NULL);
	  }
      }
  }
}
Exemplo n.º 23
0
void WHTMLReport::on_file_p_textChanged( const QString & )
{
  checkInput();
}
void
SoItkLaplacianSegmentationLevelSetImageFilter::evaluate()
{
	if( mOutput )
	{
		mOutput->unref();
		mOutput = 0;
		SO_ENGINE_OUTPUT( Output, SoItkSFDataImage, setValue( 0 ) );
	}

	if( !FeatureImage.getValue() )
		return ;
	
	if( !Input0.getValue() )
		return ;
	
	if( !checkInput() )
	{
		SoDebugError::post( __FILE__, "Invalid Input Types" );
		return ;
	}

	try
	{
		switch( FeatureImage.getValue()->getNumDimension() )
		{
			case 2:
			{
				switch( FeatureImage.getValue()->getType() )
				{
					case SoItkDataImage::FLOAT:
					{
						typedef itk::Image< float, 2 > InputImageType;
						typedef itk::Image< float, 2 > OutputImageType;
						typedef itk::LaplacianSegmentationLevelSetImageFilter< InputImageType, OutputImageType > FilterType;
						
						FilterType::Pointer filter = FilterType::New();
						
						// Set the filter's inputs
						
						// Inherited from SoItkSegmentationLevelSetImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, FeatureScaling );
						SO_ITK_SET_FIELD_VALUE( filter, AdvectionScaling );
						SO_ITK_SET_FIELD_VALUE( filter, CurvatureScaling );
						typedef itk::Image< float, 2 > InputImageType;
						SO_ITK_SET_FIELD_DATA( filter, FeatureImage, InputImageType );
						SO_ITK_SET_FIELD_VALUE( filter, MaximumPropagationTimeStep );
						SO_ITK_SET_FIELD_VALUE( filter, UseMinimalCurvature );
						SO_ITK_SET_FIELD_VALUE( filter, ReverseExpansionDirection );
						SO_ITK_SET_FIELD_VALUE( filter, PropagationScaling );
						SO_ITK_SET_FIELD_VALUE( filter, MaximumCurvatureTimeStep );
						
						// Inherited from SoItkSparseFieldLevelSetImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, NumberOfLayers );
						SO_ITK_SET_FIELD_VALUE( filter, IsoSurfaceValue );
						SO_ITK_SET_FIELD_VALUE( filter, InterpolateSurfaceLocation );
						
						// Inherited from SoItkFiniteDifferenceImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, UseImageSpacing );
						SO_ITK_SET_FIELD_VALUE( filter, NumberOfIterations );
						SO_ITK_SET_FIELD_VALUE( filter, RMSChange );
						SO_ITK_SET_FIELD_VALUE( filter, ManualReinitialization );
						SO_ITK_SET_FIELD_VALUE( filter, MaximumRMSError );
						
						// Inherited from SoItkInPlaceImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, InPlace );
						
						// Inherited from SoItkImageToImageFilter
						typedef itk::Image< float, 2 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 0, InputImageType );
						
						
						
						// Start processing the ouputs
						filter->Update();
						
						// Retrieve the filter's outputs
						filter->GetOutput()->Register();
						mOutput = new SoItkDataImage( SoItkDataImage::FLOAT, 2,
							Input0.getValue()->getModelMatrix() );
						mOutput->ref();
						mOutput->setPointer( filter->GetOutput() );
					}
					break ;
				}
			}
			break ;
			case 3:
			{
				switch( FeatureImage.getValue()->getType() )
				{
					case SoItkDataImage::FLOAT:
					{
						typedef itk::Image< float, 3 > InputImageType;
						typedef itk::Image< float, 3 > OutputImageType;
						typedef itk::LaplacianSegmentationLevelSetImageFilter< InputImageType, OutputImageType > FilterType;
						
						FilterType::Pointer filter = FilterType::New();
						
						// Set the filter's inputs
						
						// Inherited from SoItkSegmentationLevelSetImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, FeatureScaling );
						SO_ITK_SET_FIELD_VALUE( filter, AdvectionScaling );
						SO_ITK_SET_FIELD_VALUE( filter, CurvatureScaling );
						typedef itk::Image< float, 3 > InputImageType;
						SO_ITK_SET_FIELD_DATA( filter, FeatureImage, InputImageType );
						SO_ITK_SET_FIELD_VALUE( filter, MaximumPropagationTimeStep );
						SO_ITK_SET_FIELD_VALUE( filter, UseMinimalCurvature );
						SO_ITK_SET_FIELD_VALUE( filter, ReverseExpansionDirection );
						SO_ITK_SET_FIELD_VALUE( filter, PropagationScaling );
						SO_ITK_SET_FIELD_VALUE( filter, MaximumCurvatureTimeStep );
						
						// Inherited from SoItkSparseFieldLevelSetImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, NumberOfLayers );
						SO_ITK_SET_FIELD_VALUE( filter, IsoSurfaceValue );
						SO_ITK_SET_FIELD_VALUE( filter, InterpolateSurfaceLocation );
						
						// Inherited from SoItkFiniteDifferenceImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, UseImageSpacing );
						SO_ITK_SET_FIELD_VALUE( filter, NumberOfIterations );
						SO_ITK_SET_FIELD_VALUE( filter, RMSChange );
						SO_ITK_SET_FIELD_VALUE( filter, ManualReinitialization );
						SO_ITK_SET_FIELD_VALUE( filter, MaximumRMSError );
						
						// Inherited from SoItkInPlaceImageFilter
						SO_ITK_SET_FIELD_VALUE( filter, InPlace );
						
						// Inherited from SoItkImageToImageFilter
						typedef itk::Image< float, 3 > InputImageType;
						SO_ITK_SET_FIELD_MDATA( filter, Input, 0, InputImageType );
						
						
						
						// Start processing the ouputs
						filter->Update();
						
						// Retrieve the filter's outputs
						filter->GetOutput()->Register();
						mOutput = new SoItkDataImage( SoItkDataImage::FLOAT, 3,
							Input0.getValue()->getModelMatrix() );
						mOutput->ref();
						mOutput->setPointer( filter->GetOutput() );
					}
					break ;
				}
			}
			break ;
		}
	}
	catch( itk::ExceptionObject& e )
	{
		SoDebugError::post( e.GetFile(), "line %d: %s", e.GetLine(), e.GetDescription() );
		return ;
	}
	catch(...)
	{
		SoDebugError::post( __FILE__, "Unknown Exception" );
		return ;
	}

	SO_ENGINE_OUTPUT( Output, SoItkSFDataImage, setValue( mOutput ) );
}
Exemplo n.º 25
0
/**
 * Returns the (1 x numVariables) Jacobian evaluated at x
 */
DenseMatrix BSpline::evalJacobian(DenseVector x) const
{
    checkInput(x);
    return coefficients.transpose()*evalBasisJacobian(x);
}
Exemplo n.º 26
0
AudioInfo BaseAudioSink::getInfo() noexcept{
	if(checkInput(0)) return getInfoFromSlot(0);
	return AudioInfo();
}
Exemplo n.º 27
0
void ConfigurationDialog::on_nameLineEdit_textChanged( const QString& text )
{
    checkInput();
}
Exemplo n.º 28
0
/*
 *  ======== smain ========
 */
Int smain(Int argc, String argv[])
{
    Char newTraceMask[MAXTRACESTRING];
    Server_Handle server = NULL;
    Bool finished = FALSE;
    Uns mode = PULLTRACE;
    Server_Status status;
    Int traceToken;
    String mask;
    Uns rate;

    /* interpret PULLTRACE mode args */
    if (argc == 3) {
        rate = atoi(argv[1]);
        mask = argv[2];
    }

    /* else, if no args, set mode to TRACEUTIL */
    else if (argc == 1) {
        mode = TRACEUTIL;
    }
    /* else, show usage */
    else {
        fprintf(stderr, usage, argv[0]);
        goto done;
    }

    /* reset, load, and start DSP Engine */
    if ((engine = Engine_open(engineName, NULL, NULL)) == NULL) {
        fprintf(stderr, "Error: can't open engine %s!\n", engineName);
        goto done;
    }

    /* setup file descriptor mask for checking for user key input */
    FD_ZERO(&fdMask);
    FD_SET(STDIN_FILENO, &fdMask);

    /* if standard output mode... */
    if (mode == PULLTRACE) {

        printf("Trace polling rate: %d msec\n", rate);
        rate *= 1000;
        printf("DSP trace mask: %s\n", mask);

        /* get server handle */
        server = Engine_getServer(engine);
        if (server == NULL) {
            fprintf(stderr, "Error: can't get server handle!\n");
            goto closeEngine;
        }

        /* connect for server trace data */
        status = Server_connectTrace(server, &traceToken);
        if (status == Server_EINUSE) {
            fprintf(stderr,
                "Error: server trace already in use by another process!\n");
            goto closeEngine;
        }
        else if (status != Server_EOK) {
            fprintf(stderr, "Error: server connect failed, status = 0x%x!\n",
                status);
            goto closeEngine;
        }

        /* server trace mask */
        status = Server_setTrace(server, mask);
        if (status != (Int) Engine_EOK) {
            fprintf(stderr, "Error: unable to set trace mask, status = 0x%x!\n",
                status);
            goto closeEngine;
        }

        printf("Hit <Enter> to exit, or, new trace mask and then <Enter>...\n");

        while (finished == FALSE) {

            dumpTrace(server);

            usleep(rate);

            if (checkInput(newTraceMask) == TRUE) {
                if (strlen(newTraceMask) == 0) {
                    finished = TRUE;
                }
                else {
                    printf("setting new trace mask: %s\n", newTraceMask);
                    status = Server_setTrace(server, newTraceMask);
                    if (status != (Int) Engine_EOK) {
                        fprintf(stderr,
                           "Error updating trace mask, status = 0x%x!\n",
                           status);
                    }
                }
            }
        };

        /* discconnect from server trace data */
        status = Server_disconnectTrace(server, traceToken);
        if (status != Server_EOK) {
            fprintf(stderr,
              "Error: unable to disconnect from server trace, status = 0x%x!\n",
                status);
        }
    }

    /* else, startup TraceUtil to retrieve trace/LOG data and write to files */
    else {

        TraceUtil_start(engineName);

        printf("Started TraceUtil thread\nHit <Enter> to exit...\n");

        getchar();

        TraceUtil_stop();
    }

    printf("Done.\n");

closeEngine:

    /* close the engine */
    if (engine) {
        Engine_close(engine);
    }

done:
    return (0);
}
Exemplo n.º 29
0
void KyraEngine_HoF::runLoop() {
	// Initialize debugger since how it should be fully usable
	_debugger->initialize();

	_screen->updateScreen();

	_runFlag = true;
	while (!shouldQuit() && _runFlag) {
		if (_deathHandler >= 0) {
			removeHandItem();
			delay(5);
			_drawNoShapeFlag = 0;
			_gui->optionsButton(0);
			_deathHandler = -1;

			if (!_runFlag || shouldQuit())
				break;
		}

		if (_system->getMillis() > _nextIdleAnim)
			showIdleAnim();

		if (queryGameFlag(0x159)) {
			dinoRide();
			resetGameFlag(0x159);
		}

		if (queryGameFlag(0x124) && !queryGameFlag(0x125)) {
			_mainCharacter.animFrame = 32;
			enterNewScene(39, -1, 0, 0, 0);
		}

		if (queryGameFlag(0xD8)) {
			resetGameFlag(0xD8);
			if (_mainCharacter.sceneId == 34) {
				if (queryGameFlag(0xD1)) {
					initTalkObject(28);
					npcChatSequence(getTableString(0xFA, _cCodeBuffer, 1), 28, 0x83, 0xFA);
					deinitTalkObject(28);
					enterNewScene(35, 4, 0, 0, 0);
				} else if (queryGameFlag(0xD0)) {
					initTalkObject(29);
					npcChatSequence(getTableString(0xFB, _cCodeBuffer, 1), 29, 0x83, 0xFB);
					deinitTalkObject(29);
					enterNewScene(33, 6, 0, 0, 0);
				}
			}
		}

		int inputFlag = checkInput(_buttonList, true);
		removeInputTop();

		update();

		if (inputFlag == 198 || inputFlag == 199) {
			_savedMouseState = _mouseState;
			handleInput(_mouseX, _mouseY);
		}

		//if (queryGameFlag(0x1EE) && inputFlag)
		//	sub_13B19(inputFlag);

		_system->delayMillis(10);
	}
}
Exemplo n.º 30
0
    // main function that runs the filter for a given input frame
    const bool RetinaFilter::runFilter(const std::valarray<float> &imageInput, const bool useAdaptiveFiltering, const bool processRetinaParvoMagnoMapping, const bool useColorMode, const bool inputIsColorMultiplexed)
    {
        // preliminary check
        bool processSuccess=true;
        if (!checkInput(imageInput, useColorMode))
            return false;

        // run the color multiplexing if needed and compute each suub filter of the retina:
        // -> local adaptation
        // -> contours OPL extraction
        // -> moving contours extraction

        // stability controls value update
        ++_ellapsedFramesSinceLastReset;

        _useColorMode=useColorMode;

        /* pointer to the appropriate input data after,
        * by default, if graylevel mode, the input is processed,
        * if color or something else must be considered, specific preprocessing are applied
        */

        const std::valarray<float> *selectedPhotoreceptorsLocalAdaptationInput= &imageInput;
        const std::valarray<float> *selectedPhotoreceptorsColorInput=&imageInput;

        //********** Following is input data specific photoreceptors processing
        if (_photoreceptorsLogSampling)
        {
            _photoreceptorsLogSampling->runProjection(imageInput, useColorMode);
            selectedPhotoreceptorsColorInput=selectedPhotoreceptorsLocalAdaptationInput=&(_photoreceptorsLogSampling->getSampledFrame());
        }

        if (useColorMode&& (!inputIsColorMultiplexed)) // not multiplexed color input case
        {
            _colorEngine.runColorMultiplexing(*selectedPhotoreceptorsColorInput);
            selectedPhotoreceptorsLocalAdaptationInput=&(_colorEngine.getMultiplexedFrame());
        }

        //********** Following is generic Retina processing

        // photoreceptors local adaptation
        _photoreceptorsPrefilter.runFilter_LocalAdapdation(*selectedPhotoreceptorsLocalAdaptationInput, _ParvoRetinaFilter.getHorizontalCellsOutput());
        // safety pixel values checks
        //_photoreceptorsPrefilter.normalizeGrayOutput_0_maxOutputValue(_maxOutputValue);

        // run parvo filter
        _ParvoRetinaFilter.runFilter(_photoreceptorsPrefilter.getOutput(), _useParvoOutput);

        if (_useParvoOutput)
        {
            _ParvoRetinaFilter.normalizeGrayOutputCentredSigmoide(); // models the saturation of the cells, usefull for visualisation of the ON-OFF Parvo Output, Bipolar cells outputs do not change !!!
            _ParvoRetinaFilter.centerReductImageLuminance(); // best for further spectrum analysis

            if (_normalizeParvoOutput_0_maxOutputValue)
                _ParvoRetinaFilter.normalizeGrayOutput_0_maxOutputValue(_maxOutputValue);
        }

        if (_useParvoOutput&&_useMagnoOutput)
        {
            _MagnoRetinaFilter.runFilter(_ParvoRetinaFilter.getBipolarCellsON(), _ParvoRetinaFilter.getBipolarCellsOFF());
            if (_normalizeMagnoOutput_0_maxOutputValue)
            {
                _MagnoRetinaFilter.normalizeGrayOutput_0_maxOutputValue(_maxOutputValue);
            }
            _MagnoRetinaFilter.normalizeGrayOutputNearZeroCentreredSigmoide();
        }

        if (_useParvoOutput&&_useMagnoOutput&&processRetinaParvoMagnoMapping)
        {
            _processRetinaParvoMagnoMapping();
            if (_useColorMode)
                _colorEngine.runColorDemultiplexing(_retinaParvoMagnoMappedFrame, useAdaptiveFiltering, _maxOutputValue);//_ColorEngine->getMultiplexedFrame());//_ParvoRetinaFilter->getPhotoreceptorsLPfilteringOutput());

            return processSuccess;
        }

        if (_useParvoOutput&&_useColorMode)
        {
            _colorEngine.runColorDemultiplexing(_ParvoRetinaFilter.getOutput(), useAdaptiveFiltering, _maxOutputValue);//_ColorEngine->getMultiplexedFrame());//_ParvoRetinaFilter->getPhotoreceptorsLPfilteringOutput());
            // compute A Cr1 Cr2 to LMS color space conversion
            //if (true)
            //  _applyImageColorSpaceConversion(_ColorEngine->getChrominance(), lmsTempBuffer.Buffer(), _LMStoACr1Cr2);
        }

        return processSuccess;
    }