void ColorCalibrationInterface::__Click( Button& sender, bool checked )
{
   if ( sender == GUI->WhiteReferenceView_ToolButton )
   {
      ViewSelectionDialog d( instance.whiteReferenceViewId );
      if ( d.Execute() == StdDialogCode::Ok )
      {
         instance.whiteReferenceViewId = d.Id();
         GUI->WhiteReferenceView_Edit.SetText( WHITE_REFERENCE_ID );
      }
   }
   else if ( sender == GUI->BackgroundReferenceView_ToolButton )
   {
      ViewSelectionDialog d( instance.backgroundReferenceViewId );
      if ( d.Execute() == StdDialogCode::Ok )
      {
         instance.backgroundReferenceViewId = d.Id();
         GUI->BackgroundReferenceView_Edit.SetText( BACKGROUND_REFERENCE_ID );
      }
   }
   else if ( sender == GUI->OutputWhiteReferenceMask_CheckBox )
      instance.outputWhiteReferenceMask = checked;
   else if ( sender == GUI->OutputBackgroundReferenceMask_CheckBox )
      instance.outputBackgroundReferenceMask = checked;
   else if ( sender == GUI->WhiteROISelectPreview_Button )
   {
      PreviewSelectionDialog d;
      if ( d.Execute() )
         if ( !d.Id().IsEmpty() )
         {
            View view = View::ViewById( d.Id() );
            if ( !view.IsNull() )
            {
               instance.whiteROI = view.Window().PreviewRect( view.Id() );
               UpdateControls();
            }
         }
   }
   else if ( sender == GUI->BackgroundROISelectPreview_Button )
   {
      PreviewSelectionDialog d;
      if ( d.Execute() )
         if ( !d.Id().IsEmpty() )
         {
            View view = View::ViewById( d.Id() );
            if ( !view.IsNull() )
            {
               instance.backgroundROI = view.Window().PreviewRect( view.Id() );
               UpdateControls();
            }
         }
   }
}
Beispiel #2
0
int FITSHeaderProcess::ProcessCommandLine( const StringList& argv ) const
{
   ArgumentList arguments =
   ExtractArguments( argv, ArgumentItemMode::AsViews,
                     ArgumentOption::AllowWildcards|ArgumentOption::NoPreviews );

   FITSHeaderInstance instance( this );

   bool launchInterface = false;
   int count = 0;

   for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
   {
      const Argument& arg = *i;

      if ( arg.IsNumeric() )
         throw Error( "Unknown numeric argument: " + arg.Token() );
      else if ( arg.IsString() )
         throw Error( "Unknown string argument: " + arg.Token() );
      else if ( arg.IsSwitch() )
         throw Error( "Unknown switch argument: " + arg.Token() );
      else if ( arg.IsLiteral() )
         throw Error( "Unknown argument: " + arg.Token() );
      else if ( arg.IsItemList() )
      {
         ++count;

         if ( arg.Items().IsEmpty() )
         {
            Console().WriteLn( "No view(s) found: " + arg.Token() );
            continue;
         }

         for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
         {
            View v = View::ViewById( *j );
            if ( v.IsNull() )
               throw Error( "No such view: " + *j );
            instance.LaunchOn( v );
         }
      }
   }

   if ( launchInterface )
      instance.LaunchInterface();
   else if ( count == 0 )
   {
      if ( ImageWindow::ActiveWindow().IsNull() )
         throw Error( "There is no active image window." );
      instance.LaunchOnCurrentWindow();
   }

   return 0;
}
Beispiel #3
0
// ----------------------------------------------------------------------------
void MergeCFAInterface::__ViewList_ViewSelected( ViewList& sender, View& view )
{
   String id(view.Id());
   if ( sender == GUI->CFA0_ViewList )
   {
      // CFA0 selected -> try to find CFA 1,2,3 view automaticaly
      m_instance.p_viewId[0] = id;

      if (!id.EndsWith('0')) return;

      id.DeleteRight(id.Length()-1); //delete last char

      for (int cfaIndex = 3; cfaIndex > 0; --cfaIndex )
      {
         String cfaViewId( id + String( cfaIndex ) );

         View v = ImageWindow::WindowById( cfaViewId ).MainView();

         if (v.IsNull())
         {
            Console().WriteLn("not found id:" + cfaViewId);
         }
         else
         {
            Console().WriteLn("found id:" + cfaViewId);
            m_instance.p_viewId[cfaIndex] = cfaViewId;

            switch (cfaIndex)
            {
               case 1:
                  GUI->CFA1_ViewList.SelectView(v);
                  break;

               case 2:
                  GUI->CFA2_ViewList.SelectView(v);
                  break;

               case 3:
                  GUI->CFA3_ViewList.SelectView(v);
            }
         }
      }
   }
   else if( sender == GUI->CFA1_ViewList ) m_instance.p_viewId[1] = id;
   else if( sender == GUI->CFA2_ViewList ) m_instance.p_viewId[2] = id;
   else if( sender == GUI->CFA3_ViewList ) m_instance.p_viewId[3] = id;
}
void HDRCompositionInterface::__FittingRegion_Click( Button& sender, bool checked )
{
   if ( sender == GUI->SelectPreview_Button )
   {
      PreviewSelectionDialog d;
      if ( d.Execute() )
         if ( !d.Id().IsEmpty() )
         {
            View view = View::ViewById( d.Id() );
            if ( !view.IsNull() )
            {
               instance.fittingRect = view.Window().PreviewRect( view.Id() );
               UpdateFittingRegionControls();
            }
         }
   }
}
Beispiel #5
0
static void FindPreviews( StringList& items, const ImageWindow& w, const String& previewId )
{
   if ( previewId.HasWildcards() )
   {
      Array<View> P = w.Previews();
      for ( size_type i = 0; i < P.Length(); ++i )
         if ( String( P[i].Id() ).WildMatch( previewId ) )
            AddView( items, P[i] );
   }
   else
   {
      View p = w.PreviewById( IsoString( previewId ) );
      if ( p.IsNull() )
         throw ParseError( "Preview not found", previewId );
      AddView( items, p );
   }
}
void ChannelCombinationInterface::__TargetImage_ViewSelected( ViewList& /*sender*/, View& view )
{
   for ( int i = 0; i < 3; ++i )
      instance.channelId[i].Clear();

   if ( !view.IsNull() )
   {
      IsoString baseId = view.Id();
      for ( int i = 0; i < 3; ++i )
      {
         String suffix = String( '_' ) + ColorSpaceId::ChannelId( instance.colorSpace, i );
         if ( !View::ViewById( baseId + suffix ).IsNull() )
            instance.channelId[i] = baseId + suffix;
      }
   }

   UpdateControls();
}
void ScreenTransferFunctionInstance::GetViewSTF( const View& view )
{
   if ( !view.IsNull() )
   {
      View::stf_list F;
      view.GetScreenTransferFunctions( F );
      for ( int c = 0; c < 4; ++c )
      {
         STF& f = stf[c];
         const HistogramTransformation& H = F[c];
         f.m = H.MidtonesBalance();
         f.c0 = H.ShadowsClipping();
         f.c1 = H.HighlightsClipping();
         f.r0 = H.LowRange();
         f.r1 = H.HighRange();
      }

      interaction = view.IsColor() ? STFInteraction::SeparateChannels : STFInteraction::Grayscale;
   }
}
void MultiViewSelectionDialog::ButtonClick( Button& sender, bool checked )
{
   if ( sender == SelectAll_PushButton )
   {
      for ( int i = 0, n = Views_TreeBox.NumberOfChildren(); i < n; ++i )
      {
         TreeBox::Node* node = Views_TreeBox[i];
         if ( node != nullptr )
            node->Check();
      }
   }
   else if ( sender == UnselectAll_PushButton )
   {
      for ( int i = 0, n = Views_TreeBox.NumberOfChildren(); i < n; ++i )
      {
         TreeBox::Node* node = Views_TreeBox[i];
         if ( node != nullptr )
            node->Uncheck();
      }
   }
   else if ( sender == OK_PushButton )
   {
      m_selectedViews.Clear();
      for ( int i = 0, n = Views_TreeBox.NumberOfChildren(); i < n; ++i )
      {
         const TreeBox::Node* node = Views_TreeBox[i];
         if ( node != nullptr && node->IsChecked() )
         {
            View view = View::ViewById( node->Text( 0 ) );
            if ( !view.IsNull() )
               m_selectedViews.Add( view );
         }
      }
      Ok();
   }
   else if ( sender == Cancel_PushButton )
   {
      m_selectedViews.Clear();
      Cancel();
   }
}
Beispiel #9
0
int BinarizeProcess::ProcessCommandLine( const StringList& argv ) const
{
   ArgumentList arguments =
   ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards );

   BinarizeInstance instance( this );

   bool launchInterface = false;
   int count = 0;

   for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
   {
      const Argument& arg = *i;

      if ( arg.IsNumeric() )
      {
         if ( arg.Id() == "t" || arg.Id() == "threshold" )
         {
            instance.level[0] = instance.level[1] = instance.level[2] = ArgumentThresholdValue( arg );
            instance.isGlobal = true;
         }
         else if ( arg.Id() == "tR" || arg.Id() == "thresholdR" )
         {
            instance.level[0] = ArgumentThresholdValue( arg );
            instance.isGlobal = false;
         }
         else if ( arg.Id() == "tG" || arg.Id() == "thresholdG" )
         {
            instance.level[1] = ArgumentThresholdValue( arg );
            instance.isGlobal = false;
         }
         else if ( arg.Id() == "tB" || arg.Id() == "thresholdB" )
         {
            instance.level[2] = ArgumentThresholdValue( arg );
            instance.isGlobal = false;
         }
         else
            throw Error( "Unknown numeric argument: " + arg.Token() );
      }
      else if ( arg.IsString() )
         throw Error( "Unknown string argument: " + arg.Token() );
      else if ( arg.IsSwitch() )
         throw Error( "Unknown switch argument: " + arg.Token() );
      else if ( arg.IsLiteral() )
      {
         if ( arg.Id() == "-interface" )
            launchInterface = true;
         else if ( arg.Id() == "-help" )
         {
            ShowHelp();
            return 0;
         }
         else
            throw Error( "Unknown argument: " + arg.Token() );
      }
      else if ( arg.IsItemList() )
      {
         ++count;

         if ( arg.Items().IsEmpty() )
         {
            Console().WriteLn( "No view(s) found: " + arg.Token() );
            continue;
         }

         for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
         {
            View v = View::ViewById( *j );
            if ( v.IsNull() )
               throw Error( "No such view: " + *j );
            instance.LaunchOn( v );
         }
      }
   }

   if ( launchInterface )
      instance.LaunchInterface();
   else if ( count == 0 )
   {
      if ( ImageWindow::ActiveWindow().IsNull() )
         throw Error( "There is no active image window." );
      instance.LaunchOnCurrentView();
   }

   return 0;
}
Beispiel #10
0
int MaskedStretchProcess::ProcessCommandLine( const StringList& argv ) const
{
   ArgumentList arguments =
   ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards );

   MaskedStretchInstance instance( this );

   bool launchInterface = false;
   int count = 0;

   for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
   {
      const Argument& arg = *i;

      if ( arg.IsNumeric() )
      {
         if ( arg.Id() == "b" || arg.Id() == "-background" )
         {
            double b = arg.NumericValue();
            if ( b < TheMSTargetBackgroundParameter->MinimumValue() ||
                 b > TheMSTargetBackgroundParameter->MaximumValue() )
               throw Error( "Target background parameter out of range" );
            instance.p_targetBackground = b;
         }
         else if ( arg.Id() == "n" || arg.Id() == "-iterations" )
         {
            int n = TruncInt( arg.NumericValue() );
            if ( n < int( TheMSNumberOfIterationsParameter->MinimumValue() ) ||
                 n > int( TheMSNumberOfIterationsParameter->MaximumValue() ) )
               throw Error( "Number of iterations parameter out of range" );
            instance.p_numberOfIterations = n;
         }
         else
            throw Error( "Unknown numeric argument: " + arg.Token() );
      }
      else if ( arg.IsString() )
      {
         if ( arg.Id() == "m" || arg.Id() == "-mask-type" )
         {
            if ( arg.StringValue() == "I" || arg.StringValue() == "intensity" )
               instance.p_maskType = MSMaskType::Intensity;
            else if ( arg.StringValue() == "V" || arg.StringValue() == "value" )
               instance.p_maskType = MSMaskType::Value;
         }
         else
            throw Error( "Unknown string argument: " + arg.Token() );
      }
      else if ( arg.IsSwitch() )
      {
         throw Error( "Unknown switch argument: " + arg.Token() );
      }
      else if ( arg.IsLiteral() )
      {
         if ( arg.Id() == "-interface" )
            launchInterface = true;
         else if ( arg.Id() == "-help" )
         {
            ShowHelp();
            return 0;
         }
         else
            throw Error( "Unknown argument: " + arg.Token() );
      }
      else if ( arg.IsItemList() )
      {
         ++count;

         if ( arg.Items().IsEmpty() )
         {
            Console().WriteLn( "No view(s) found: " + arg.Token() );
            continue;
         }

         for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
         {
            View v = View::ViewById( *j );
            if ( v.IsNull() )
               throw Error( "No such view: " + *j );
            instance.LaunchOn( v );
         }
      }
   }

   if ( launchInterface )
      instance.LaunchInterface();
   else if ( count == 0 )
   {
      if ( ImageWindow::ActiveWindow().IsNull() )
         throw Error( "There is no active image window." );
      instance.LaunchOnCurrentView();
   }

   return 0;
}
Beispiel #11
0
void B3EInterface::__Clicked( Button& sender, bool checked )
{
   if ( sender == GUI->InputImage1_ToolButton )
   {
      ViewSelectionDialog d( instance.p_inputView[0].id );
      d.SetWindowTitle( "Select First Input Image" );
      if ( d.Execute() )
         instance.p_inputView[0].id = d.Id();
      GUI->InputImage1_Edit.SetText( instance.p_inputView[0].id );
   }
   else if ( sender == GUI->InputImage2_ToolButton )
   {
      ViewSelectionDialog d( instance.p_inputView[1].id );
      d.SetWindowTitle( "Select Second Input Image" );
      if ( d.Execute() )
         instance.p_inputView[1].id = d.Id();
      GUI->InputImage2_Edit.SetText( instance.p_inputView[1].id );
   }
   else if ( sender == GUI->OutOfRangeMask_CheckBox )
   {
      instance.p_outOfRangeMask = checked;
   }
   else if ( sender == GUI->BackgroundReferenceView1_ToolButton )
   {
      ViewSelectionDialog d( instance.p_inputView[0].backgroundReferenceViewId );
      d.SetWindowTitle( "Select First Background Reference Image" );
      if ( d.Execute() == StdDialogCode::Ok )
      {
         instance.p_inputView[0].backgroundReferenceViewId = d.Id();
         GUI->BackgroundReferenceView1_Edit.SetText( BACKGROUND_REFERENCE_ID1 );
      }
   }
   else if ( sender == GUI->OutputBackgroundReferenceMask1_CheckBox )
      instance.p_inputView[0].outputBackgroundReferenceMask = checked;
   else if ( sender == GUI->BackgroundROISelectPreview1_Button )
   {
      PreviewSelectionDialog d;
      d.SetWindowTitle( "Select First Background ROI" );
      if ( d.Execute() )
         if ( !d.Id().IsEmpty() )
         {
            View view = View::ViewById( d.Id() );
            if ( !view.IsNull() )
               instance.p_inputView[0].backgroundROI = view.Window().PreviewRect( view.Id() );
         }
   }
   else if ( sender == GUI->BackgroundReferenceView2_ToolButton )
   {
      ViewSelectionDialog d( instance.p_inputView[1].backgroundReferenceViewId );
      d.SetWindowTitle( "Select Second Background Reference Image" );
      if ( d.Execute() == StdDialogCode::Ok )
      {
         instance.p_inputView[1].backgroundReferenceViewId = d.Id();
         GUI->BackgroundReferenceView2_Edit.SetText( BACKGROUND_REFERENCE_ID2 );
      }
   }
   else if ( sender == GUI->OutputBackgroundReferenceMask2_CheckBox )
      instance.p_inputView[1].outputBackgroundReferenceMask = checked;
   else if ( sender == GUI->BackgroundROISelectPreview2_Button )
   {
      PreviewSelectionDialog d;
      d.SetWindowTitle( "Select Second Background ROI" );
      if ( d.Execute() )
         if ( !d.Id().IsEmpty() )
         {
            View view = View::ViewById( d.Id() );
            if ( !view.IsNull() )
               instance.p_inputView[1].backgroundROI = view.Window().PreviewRect( view.Id() );
         }
   }
   UpdateControls();
}
void DrizzleIntegrationInterface::__Click( Button& sender, bool checked )
{
   if ( sender == GUI->AddFiles_PushButton )
   {
      FileFilter drzFiles;
      drzFiles.SetDescription( "Drizzle Data Files" );
      drzFiles.AddExtension( ".drz" );

      OpenFileDialog d;
      d.EnableMultipleSelections();
      d.Filters().Clear();
      d.Filters().Add( drzFiles );
      d.SetCaption( "DrizzleIntegration: Select Drizzle Data Files" );
      if ( d.Execute() )
      {
         size_type i0 = TreeInsertionIndex( GUI->InputData_TreeBox );
         for ( StringList::const_iterator i = d.FileNames().Begin(); i != d.FileNames().End(); ++i )
            m_instance.p_inputData.Insert( m_instance.p_inputData.At( i0++ ), DrizzleIntegrationInstance::DataItem( *i ) );
         UpdateInputDataList();
         UpdateDataSelectionButtons();
      }
   }
   else if ( sender == GUI->SelectAll_PushButton )
   {
      GUI->InputData_TreeBox.SelectAllNodes();
      UpdateDataSelectionButtons();
   }
   else if ( sender == GUI->InvertSelection_PushButton )
   {
      for ( int i = 0, n = GUI->InputData_TreeBox.NumberOfChildren(); i < n; ++i )
         GUI->InputData_TreeBox[i]->Select( !GUI->InputData_TreeBox[i]->IsSelected() );
      UpdateDataSelectionButtons();
   }
   else if ( sender == GUI->ToggleSelected_PushButton )
   {
      for ( int i = 0, n = GUI->InputData_TreeBox.NumberOfChildren(); i < n; ++i )
         if ( GUI->InputData_TreeBox[i]->IsSelected() )
            m_instance.p_inputData[i].enabled = !m_instance.p_inputData[i].enabled;
      UpdateInputDataList();
      UpdateDataSelectionButtons();
   }
   else if ( sender == GUI->RemoveSelected_PushButton )
   {
      DrizzleIntegrationInstance::input_data_list newImages;
      for ( int i = 0, n = GUI->InputData_TreeBox.NumberOfChildren(); i < n; ++i )
         if ( !GUI->InputData_TreeBox[i]->IsSelected() )
            newImages.Add( m_instance.p_inputData[i] );
      m_instance.p_inputData = newImages;
      UpdateInputDataList();
      UpdateDataSelectionButtons();
   }
   else if ( sender == GUI->Clear_PushButton )
   {
      m_instance.p_inputData.Clear();
      UpdateInputDataList();
      UpdateDataSelectionButtons();
   }
   else if ( sender == GUI->FullPaths_CheckBox )
   {
      UpdateInputDataList();
      UpdateDataSelectionButtons();
   }
   else if ( sender == GUI->InputDirectory_ToolButton )
   {
      GetDirectoryDialog d;
      d.SetCaption( "DrizzleIntegration: Select Input Directory" );
      if ( d.Execute() )
         GUI->InputDirectory_Edit.SetText( m_instance.p_inputDirectory = d.Directory() );
   }
   else if ( sender == GUI->EnableRejection_CheckBox )
   {
      m_instance.p_enableRejection = checked;
   }
   else if ( sender == GUI->EnableImageWeighting_CheckBox )
   {
      m_instance.p_enableImageWeighting = checked;
   }
   else if ( sender == GUI->EnableSurfaceSplines_CheckBox )
   {
      m_instance.p_enableSurfaceSplines = checked;
   }
   else if ( sender == GUI->ClosePreviousImages_CheckBox )
   {
      m_instance.p_closePreviousImages = checked;
   }
   else if ( sender == GUI->SelectPreview_Button )
   {
      PreviewSelectionDialog d;
      if ( d.Execute() )
         if ( !d.Id().IsEmpty() )
         {
            View view = View::ViewById( d.Id() );
            if ( !view.IsNull() )
            {
               m_instance.p_roi = view.Window().PreviewRect( view.Id() );
               UpdateROIControls();
            }
         }
   }
}
int FluxCalibrationProcess::ProcessCommandLine( const StringList& argv ) const
{
   ArgumentList arguments =
      ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards );

   FluxCalibrationInstance instance( this );

   bool launchInterface = false;
   int count = 0;

   for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
   {
      const Argument& arg = *i;

      if ( arg.IsNumeric() )
      {
         if ( arg.Id() == "l" || arg.Id() == "-wavelength" )
            instance.p_wavelength = arg.NumericValue();
         else if ( arg.Id() == "tr" || arg.Id() == "-transmissivity" )
            instance.p_transmissivity = arg.NumericValue();
         else if ( arg.Id() == "w" || arg.Id() == "-filter-width" )
            instance.p_filterWidth = arg.NumericValue();
         else if ( arg.Id() == "a" || arg.Id() == "-aperture" )
            instance.p_aperture = arg.NumericValue();
         else if ( arg.Id() == "o" || arg.Id() == "-central-obstruction" )
            instance.p_centralObstruction = arg.NumericValue();
         else if ( arg.Id() == "t" || arg.Id() == "-exposure-time" )
            instance.p_exposureTime = arg.NumericValue();
         else if ( arg.Id() == "e" || arg.Id() == "-atmospheric-extinction" )
            instance.p_atmosphericExtinction = arg.NumericValue();
         else if ( arg.Id() == "G" || arg.Id() == "-sensor-gain" )
            instance.p_sensorGain = arg.NumericValue();
         else if ( arg.Id() == "qe" || arg.Id() == "-quantum-efficiency" )
            instance.p_quantumEfficiency = arg.NumericValue();
         else
            throw Error( "Unknown numeric argument: " + arg.Token() );
      }
      else if ( arg.IsString() )
      {
            throw Error( "Unknown string argument: " + arg.Token() );
      }
      else if ( arg.IsSwitch() )
      {
            throw Error( "Unknown switch argument: " + arg.Token() );
      }
      else if ( arg.IsLiteral() )
      {
         // These are standard parameters that all processes should provide.
         if ( arg.Id() == "-interface" )
            launchInterface = true;
         else if ( arg.Id() == "-help" )
         {
            ShowHelp();
            return 0;
         }
         else
            throw Error( "Unknown argument: " + arg.Token() );
      }
      else if ( arg.IsItemList() )
      {
         ++count;

         if ( arg.Items().IsEmpty() )
         {
            Console().WriteLn( "No view(s) found: " + arg.Token() );
            throw;
         }

         for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
         {
            View v = View::ViewById( *j );
            if ( v.IsNull() )
               throw Error( "No such view: " + *j );
            instance.LaunchOn( v );
         }
      }
   }

   if ( launchInterface )
      instance.LaunchInterface();
   else if ( count == 0 )
   {
      if ( ImageWindow::ActiveWindow().IsNull() )
         throw Error( "There is no active image window." );
      instance.LaunchOnCurrentView();
   }

   return 0;
}
Beispiel #14
0
int B3EProcess::ProcessCommandLine( const StringList& argv ) const
{
   ArgumentList arguments =
      ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards );

   B3EInstance instance( this );

   bool launchInterface = false;
   int count = 0;

   for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
   {
      const Argument& arg = *i;

      if ( arg.IsNumeric() )
      {
         throw Error( "Unknown numeric argument: " + arg.Token() );
      }
      else if ( arg.IsString() )
      {
         throw Error( "Unknown string argument: " + arg.Token() );
      }
      else if ( arg.IsSwitch() )
      {
         throw Error( "Unknown switch argument: " + arg.Token() );
      }
      else if ( arg.IsLiteral() )
      {
         // These are standard parameters that all processes should provide.
         if ( arg.Id() == "-interface" )
            launchInterface = true;
         else if ( arg.Id() == "-help" )
         {
            ShowHelp();
            return 0;
         }
         else
            throw Error( "Unknown argument: " + arg.Token() );
      }
      else if ( arg.IsItemList() )
      {
         ++count;

         if ( arg.Items().IsEmpty() )
         {
            Console().WriteLn( "No view(s) found: " + arg.Token() );
            throw;
         }

         for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
         {
            View v = View::ViewById( *j );
            if ( v.IsNull() )
               throw Error( "No such view: " + *j );
            instance.LaunchOn( v );
         }
      }
   }

   if ( launchInterface )
      instance.LaunchInterface();
   else if ( count == 0 )
   {
      if ( ImageWindow::ActiveWindow().IsNull() )
         throw Error( "There is no active image window." );
      instance.LaunchOnCurrentView();
   }

   return 0;
}
int LocalHistogramEqualizationProcess::ProcessCommandLine( const StringList& argv ) const
{
   ArgumentList arguments =
      ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards );

   LocalHistogramEqualizationInstance instance( this );

   bool launchInterface = false;
   int count = 0;

   for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
   {
      const Argument& arg = *i;

      if ( arg.IsNumeric() )
      {
         if (arg.Id() == "r" || arg.Id() == "-radius") instance.radius = (int)arg.NumericValue();
         else if (arg.Id() == "l" || arg.Id() == "-limit") instance.slopeLimit = arg.NumericValue();
         else if (arg.Id() == "a" || arg.Id() == "-amount") instance.amount = arg.NumericValue();
         else if (arg.Id() == "h" || arg.Id() == "-hist")
         {
            int bins = (int)arg.NumericValue();
            if (bins == 8) instance.histogramBins = LHEHistogramBins::Bit8;
            else if (bins == 10) instance.histogramBins = LHEHistogramBins::Bit10;
            else if (bins == 12) instance.histogramBins = LHEHistogramBins::Bit12;
            else throw Error( "Invalid value for '-h' argument. Allowed values are 8, 10 or 12" );
         }
         else throw Error( "Unknown numeric argument: " + arg.Token() );
      }
      else if ( arg.IsString() )
      {
         throw Error( "Unknown string argument: " + arg.Token() );
      }
      else if ( arg.IsSwitch() )
      {
         if (arg.Id() == "c" || arg.Id() == "-circular") instance.circularKernel = arg.SwitchState();
         else throw Error( "Unknown switch argument: " + arg.Token() );
      }
      else if ( arg.IsLiteral() )
      {
         if (arg.Id() == "c" || arg.Id() == "-circular") instance.circularKernel = true;
         // These are standard parameters that all processes should provide.
         else if ( arg.Id() == "-interface" )
            launchInterface = true;
         else if ( arg.Id() == "-help" )
         {
            ShowHelp();
            return 0;
         }
         else
            throw Error( "Unknown argument: " + arg.Token() );
      }
      else if ( arg.IsItemList() )
      {
         ++count;

         if ( arg.Items().IsEmpty() )
         {
            Console().WriteLn( "No view(s) found: " + arg.Token() );
            throw;
         }

         for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
         {
            View v = View::ViewById( *j );
            if ( v.IsNull() )
               throw Error( "No such view: " + *j );
            instance.LaunchOn( v );
         }
      }
   }

   if ( launchInterface )
      instance.LaunchInterface();
   else if ( count == 0 )
   {
      if ( ImageWindow::ActiveWindow().IsNull() )
         throw Error( "There is no active image window." );
      instance.LaunchOnCurrentView();
   }

   return 0;
}
Beispiel #16
0
int LinearFitProcess::ProcessCommandLine( const StringList& argv ) const
{
   ArgumentList arguments =
   ExtractArguments( argv, ArgumentItemMode::AsViews, ArgumentOption::AllowWildcards );

   LinearFitInstance instance( this );

   bool launchInterface = false;
   int count = 0;

   for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
   {
      const Argument& arg = *i;

      if ( arg.IsNumeric() )
      {
         if ( arg.Id() == "r0" || arg.Id() == "reject-low" )
         {
            CHECK_IN_NORM_RANGE;
            instance.rejectLow = arg.NumericValue();
         }
         else if ( arg.Id() == "r1" || arg.Id() == "reject-high" )
         {
            CHECK_IN_NORM_RANGE;
            instance.rejectHigh = arg.NumericValue();
         }
         else
            throw Error( "Unknown numeric argument: " + arg.Token() );
      }
      else if ( arg.IsString() )
      {
         if ( arg.Id() == "v" || arg.Id() == "reference-view" )
            instance.referenceViewId = arg.StringValue();
         else
            throw Error( "Unknown string argument: " + arg.Token() );
      }
      else if ( arg.IsSwitch() )
      {
         throw Error( "Unknown switch argument: " + arg.Token() );
      }
      else if ( arg.IsLiteral() )
      {
         if ( arg.Id() == "-interface" )
            launchInterface = true;
         else if ( arg.Id() == "-help" )
         {
            ShowHelp();
            return 0;
         }
         else
            throw Error( "Unknown argument: " + arg.Token() );
      }
      else if ( arg.IsItemList() )
      {
         ++count;

         if ( arg.Items().IsEmpty() )
         {
            Console().WriteLn( "No view(s) found: " + arg.Token() );
            throw;
         }

         for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
         {
            View v = View::ViewById( *j );
            if ( v.IsNull() )
               throw Error( "No such view: " + *j );
            if ( v.FullId() != IsoString( instance.referenceViewId ).Trimmed() )
               instance.LaunchOn( v );
            else
               Console().WarningLn( "<end><cbr>** Skipping reference view: " + v.FullId() );
         }
      }
   }

   if ( launchInterface )
      instance.LaunchInterface();
   else if ( count == 0 )
   {
      if ( ImageWindow::ActiveWindow().IsNull() )
         throw Error( "There is no active image window." );
      instance.LaunchOnCurrentView();
   }

   return 0;
}
int AssignICCProfileProcess::ProcessCommandLine( const StringList& argv ) const
{
   ArgumentList arguments =
   ExtractArguments( argv,
                     ArgumentItemMode::AsViews,
                     ArgumentOption::AllowWildcards|ArgumentOption::NoPreviews );

   AssignICCProfileInstance instance( this );

   bool launchInterface = false;
   int count = 0;

   for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
   {
      const Argument& arg = *i;

      if ( arg.IsNumeric() )
         throw Error( "Unknown numeric argument: " + arg.Token() );
      else if ( arg.IsString() )
      {
         if ( arg.Id() == "profile" )
         {
            instance.targetProfile = arg.StringValue();
            instance.targetProfile.Trim();
            if ( instance.targetProfile.IsEmpty() )
               throw Error( "Empty profile identifier: " + arg.Token() );
         }
         else if ( arg.Id() == "filename" )
         {
            String filename = arg.StringValue();
            filename.Trim();
            if ( filename.IsEmpty() )
               throw Error( "Empty file name: " + arg.Token() );

            instance.targetProfile.Clear();

            StringList dirs = ICCProfile::ProfileDirectories();
            for ( StringList::const_iterator i = dirs.Begin(); i != dirs.End(); ++i )
            {
               String path = *i + '/' + filename;
               if ( File::Exists( path ) )
               {
                  ICCProfile icc( path );
                  if ( icc.IsProfile() )
                  {
                     instance.targetProfile = icc.Description();
                     break;
                  }
               }
            }

            if ( instance.targetProfile.IsEmpty() )
               throw Error( "The specified file name does not correspond to a valid ICC profile: " + filename );
         }
         else
            throw Error( "Unknown string argument: " + arg.Token() );
      }
      else if ( arg.IsSwitch() )
      {
         if ( arg.Id() == "default" )
            instance.mode = arg.SwitchState() ? AssignMode::AssignDefaultProfile : AssignMode::AssignNewProfile;
         else if ( arg.Id() == "untag" )
            instance.mode = arg.SwitchState() ? AssignMode::LeaveUntagged : AssignMode::AssignNewProfile;
         else
            throw Error( "Unknown switch argument: " + arg.Token() );
      }
      else if ( arg.IsLiteral() )
      {
         if ( arg.Id() == "default" )
            instance.mode = AssignMode::AssignDefaultProfile;
         else if ( arg.Id() == "untag" )
            instance.mode = AssignMode::LeaveUntagged;
         else if ( arg.Id() == "-interface" )
            launchInterface = true;
         else if ( arg.Id() == "-help" )
         {
            ShowHelp();
            return 0;
         }
         else
            throw Error( "Unknown argument: " + arg.Token() );
      }
      else if ( arg.IsItemList() )
      {
         ++count;

         if ( arg.Items().IsEmpty() )
         {
            Console().WriteLn( "No view(s) found: " + arg.Token() );
            continue;
         }

         for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
         {
            View v = View::ViewById( *j );
            if ( v.IsNull() )
               throw Error( "No such view: " + *j );
            instance.LaunchOn( v );
         }
      }
   }

   if ( launchInterface )
      instance.LaunchInterface();
   else if ( count == 0 )
   {
      if ( ImageWindow::ActiveWindow().IsNull() )
         throw Error( "There is no active image window." );
      instance.LaunchOnCurrentWindow();
   }

   return 0;
}
int ICCProfileTransformationProcess::ProcessCommandLine( const StringList& argv ) const
{
   ArgumentList arguments =
   ExtractArguments( argv,
                     ArgumentItemMode::AsViews,
                     ArgumentOption::AllowWildcards|ArgumentOption::NoPreviews );

   ICCProfileTransformationInstance instance( this );

   bool launchInterface = false;
   int count = 0;

   for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i )
   {
      const Argument& arg = *i;

      if ( arg.IsNumeric() )
      {
         throw Error( "Unknown numeric argument: " + arg.Token() );
      }
      else if ( arg.IsString() )
      {
         if ( arg.Id() == "profile" )
         {
            instance.targetProfile = arg.StringValue();
            instance.targetProfile.Trim();
            if ( instance.targetProfile.IsEmpty() )
               throw Error( "Empty profile identifier: " + arg.Token() );
         }
         else if ( arg.Id() == "filename" )
         {
            String filename = arg.StringValue();
            filename.Trim();
            if ( filename.IsEmpty() )
               throw Error( "Empty file name: " + arg.Token() );

            instance.targetProfile.Clear();

            StringList dirs = ICCProfile::ProfileDirectories();
            for ( StringList::const_iterator i = dirs.Begin(); i != dirs.End(); ++i )
            {
               String path = *i + '/' + filename;
               if ( File::Exists( path ) )
               {
                  ICCProfile icc( path );
                  if ( icc.IsProfile() )
                  {
                     instance.targetProfile = icc.Description();
                     break;
                  }
               }
            }

            if ( instance.targetProfile.IsEmpty() )
               throw Error( "The specified file name does not correspond to a valid ICC profile: " + filename );
         }
         else if ( arg.Id() == "rendering-intent" )
         {
            if ( arg.StringValue() == "perceptual" )
               instance.renderingIntent = ICCTRenderingIntent::Perceptual;
            else if ( arg.StringValue() == "saturation" )
               instance.renderingIntent = ICCTRenderingIntent::Saturation;
            else if ( arg.StringValue() == "relative" || arg.StringValue() == "relative-colorimetric" )
               instance.renderingIntent = ICCTRenderingIntent::RelativeColorimetric;
            else if ( arg.StringValue() == "absolute" || arg.StringValue() == "absolute-colorimetric" )
               instance.renderingIntent = ICCTRenderingIntent::AbsoluteColorimetric;
            else
               throw Error( "Invalid rendering intent: " + arg.Token() );
         }
         else
            throw Error( "Unknown string argument: " + arg.Token() );
      }
      else if ( arg.IsSwitch() )
      {
         if ( arg.Id() == "to-default-profile" )
            instance.toDefaultProfile = arg.SwitchState();
         else if ( arg.Id() == "black-point-compensation" )
            instance.useBlackPointCompensation = arg.SwitchState();
         else if ( arg.Id() == "floating-point-transform" )
            instance.useFloatingPointTransformation = arg.SwitchState();
         else
            throw Error( "Unknown switch argument: " + arg.Token() );
      }
      else if ( arg.IsLiteral() )
      {
         if ( arg.Id() == "to-default-profile" )
            instance.toDefaultProfile = true;
         else if ( arg.Id() == "black-point-compensation" )
            instance.useBlackPointCompensation = true;
         else if ( arg.Id() == "floating-point-transform" )
            instance.useFloatingPointTransformation = true;
         else if ( arg.Id() == "-interface" )
            launchInterface = true;
         else if ( arg.Id() == "-help" )
         {
            ShowHelp();
            return 0;
         }
         else
            throw Error( "Unknown argument: " + arg.Token() );
      }
      else if ( arg.IsItemList() )
      {
         ++count;

         if ( arg.Items().IsEmpty() )
         {
            Console().WriteLn( "No view(s) found: " + arg.Token() );
            continue;
         }

         for ( StringList::const_iterator j = arg.Items().Begin(); j != arg.Items().End(); ++j )
         {
            View v = View::ViewById( *j );
            if ( v.IsNull() )
               throw Error( "No such view: " + *j );
            instance.LaunchOn( v );
         }
      }
   }

   if ( launchInterface )
      instance.LaunchInterface();
   else if ( count == 0 )
   {
      if ( ImageWindow::ActiveWindow().IsNull() )
         throw Error( "There is no active image window." );
      instance.LaunchOnCurrentWindow();
   }

   return 0;
}