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(); } } } }
void ImageIdentifierInterface::__ViewDrop( Control& sender, const Point& pos, const View& view, unsigned modifiers ) { if ( sender == GUI->Identifier_Edit ) if ( view.IsMainView() ) { instance.SetId( view.Id() ); UpdateControls(); } }
// ---------------------------------------------------------------------------- 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(); } } } }
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(); }
ArgumentList ExtractArguments( const StringList& argv, argument_item_mode mode, ArgumentOptions options ) { bool noItems = mode == ArgumentItemMode::NoItems; bool itemsAsFiles = mode == ArgumentItemMode::AsFiles; bool itemsAsViews = mode == ArgumentItemMode::AsViews; bool allowWildcards = !noItems && options.IsFlagSet( ArgumentOption::AllowWildcards ); bool noPreviews = itemsAsViews && options.IsFlagSet( ArgumentOption::NoPreviews ); bool recursiveDirSearch = itemsAsFiles && allowWildcards && options.IsFlagSet( ArgumentOption::RecursiveDirSearch ); bool recursiveSearchArgs = recursiveDirSearch && options.IsFlagSet( ArgumentOption::RecursiveSearchArgs ); // This is the recursive search mode flag, controlled by --r[+|-] bool recursiveSearch = false; // The list of existing view identifiers, in case itemsAsViews = true. SortedStringList imageIds; // The list of extracted arguments ArgumentList arguments; for ( StringList::const_iterator i = argv.Begin(); i != argv.End(); ++i ) { if ( i->StartsWith( '-' ) ) { Argument arg( i->At( 1 ) ); if ( recursiveSearchArgs && arg.Id() == s_recursiveSearchArg ) { if ( arg.IsSwitch() ) recursiveSearch = arg.SwitchState(); else if ( arg.IsLiteral() ) recursiveSearch = true; else arguments.Add( arg ); } else arguments.Add( arg ); } else { if ( noItems ) throw ParseError( "Non-parametric arguments are not allowed", *i ); StringList items; if ( itemsAsFiles ) { String fileName = *i; if ( fileName.StartsWith( '\"' ) ) fileName.Delete( 0 ); if ( fileName.EndsWith( '\"' ) ) fileName.Delete( fileName.UpperBound() ); fileName.Trim(); if ( fileName.IsEmpty() ) throw ParseError( "Empty path specification", *i ); fileName = File::FullPath( fileName ); if ( fileName.HasWildcards() ) { if ( !allowWildcards ) throw ParseError( "Wildcards not allowed", fileName ); items = SearchDirectory( fileName, recursiveSearch ); } else items.Add( fileName ); } else if ( itemsAsViews ) { String viewId = *i; if ( !allowWildcards ) if ( viewId.HasWildcards() ) throw ParseError( "Wildcards not allowed", viewId ); size_type p = viewId.Find( "->" ); if ( p != String::notFound ) { if ( noPreviews ) throw ParseError( "Preview identifiers not allowed", viewId ); String imageId = viewId.Left( p ); if ( imageId.IsEmpty() ) throw ParseError( "Missing image identifier", viewId ); String previewId = viewId.Substring( p+2 ); if ( previewId.IsEmpty() ) throw ParseError( "Missing preview identifier", viewId ); FindPreviews( items, imageId, previewId ); } else { if ( viewId.HasWildcards() ) { Array<ImageWindow> W = ImageWindow::AllWindows(); for ( size_type i = 0; i < W.Length(); ++i ) { View v = W[i].MainView(); if ( String( v.Id() ).WildMatch( viewId ) ) AddView( items, v ); } } else { ImageWindow w = ImageWindow::WindowById( IsoString( viewId ) ); if ( w.IsNull() ) throw ParseError( "Image not found", viewId ); AddView( items, w.MainView() ); } } } else items.Add( *i ); Argument arg( *i, items ); arguments.Add( arg ); } } return arguments; }
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(); }
bool ChannelCombinationInstance::ExecuteGlobal() { ImageWindow sourceWindow[ 3 ]; ImageVariant sourceImage[ 3 ]; int numberOfSources = 0; int width = 0, height = 0; bool floatSample = false; int bitsPerSample = 0; for ( int i = 0; i < 3; ++i ) if ( channelEnabled[i] && !channelId[i].IsEmpty() ) { sourceWindow[i] = ImageWindow::WindowById( channelId[i] ); if ( sourceWindow[i].IsNull() ) throw Error( "ChannelCombination: Source image not found: " + channelId[i] ); sourceImage[i] = sourceWindow[i].MainView().Image(); if ( !sourceImage[i] ) throw Error( "ChannelCombination: Invalid source image: " + channelId[i] ); if ( sourceImage[i]->IsColor() ) throw Error( "ChannelCombination: Invalid source color space: " + channelId[i] ); if ( sourceImage[i].IsFloatSample() ) floatSample = true; if ( sourceImage[i].BitsPerSample() > bitsPerSample ) bitsPerSample = sourceImage[i].BitsPerSample(); if ( width == 0 ) { width = sourceImage[i]->Width(); height = sourceImage[i]->Height(); } else { if ( sourceImage[i]->Width() != width || sourceImage[i]->Height() != height ) throw Error( "ChannelCombination: Incompatible source image dimensions: " + channelId[i] ); } ++numberOfSources; } if ( numberOfSources == 0 ) throw Error( "ChannelCombination: No source image(s)." ); ImageWindow w( width, height, 3, bitsPerSample, floatSample, true, true ); if ( w.IsNull() ) throw Error( "ChannelCombination: Unable to create target image." ); View mainView = w.MainView(); AutoViewLock lock( mainView ); try { ImageVariant image = mainView.Image(); Console().EnableAbort(); StandardStatus status; image->SetStatusCallback( &status ); const char* what = ""; switch ( colorSpace ) { case ColorSpaceId::RGB: what = "RGB channels"; break; case ColorSpaceId::CIEXYZ: what = "normalized CIE XYZ components"; break; case ColorSpaceId::CIELab: what = "normalized CIE L*a*b* components"; break; case ColorSpaceId::CIELch: what = "normalized CIE L*c*h* components"; break; case ColorSpaceId::HSV: what = "normalized HSV components"; break; case ColorSpaceId::HSI: what = "normalized HSI components"; break; } image->Status().Initialize( String( "Combining " ) + what, image->NumberOfPixels() ); String baseId = mainView.Id(); Rect r = image->Bounds(); if ( image.IsFloatSample() ) switch ( image.BitsPerSample() ) { case 32: CombineChannels( static_cast<Image&>( *image ), colorSpace, baseId, r, sourceImage[0], sourceImage[1], sourceImage[2] ); break; case 64: CombineChannels( static_cast<DImage&>( *image ), colorSpace, baseId, r, sourceImage[0], sourceImage[1], sourceImage[2] ); break; } else switch ( image.BitsPerSample() ) { case 8: CombineChannels( static_cast<UInt8Image&>( *image ), colorSpace, baseId, r, sourceImage[0], sourceImage[1], sourceImage[2] ); break; case 16: CombineChannels( static_cast<UInt16Image&>( *image ), colorSpace, baseId, r, sourceImage[0], sourceImage[1], sourceImage[2] ); break; case 32: CombineChannels( static_cast<UInt32Image&>( *image ), colorSpace, baseId, r, sourceImage[0], sourceImage[1], sourceImage[2] ); break; } w.Show(); return true; } catch ( ... ) { w.Close(); throw; } }
bool ChannelCombinationInstance::ExecuteOn( View& view ) { ImageWindow sourceWindow[ 3 ]; ImageVariant sourceImage[ 3 ]; AutoViewLock lock( view ); ImageVariant image = view.Image(); if ( image.IsComplexSample() ) throw Error( "ChannelCombination cannot be executed on complex images." ); if ( image->ColorSpace() != ColorSpace::RGB ) throw Error( "ChannelCombination requires a RGB color image." ); Console().EnableAbort(); StandardStatus status; image->SetStatusCallback( &status ); String baseId; Rect r; int w0, h0; if ( view.IsPreview() ) { ImageWindow w = view.Window(); View mainView = w.MainView(); baseId = mainView.Id(); r = w.PreviewRect( view.Id() ); mainView.GetSize( w0, h0 ); } else { baseId = view.Id(); r = image->Bounds(); w0 = r.Width(); h0 = r.Height(); } int numberOfSources = 0; for ( int i = 0; i < 3; ++i ) if ( channelEnabled[i] ) { String id = channelId[i]; if ( id.IsEmpty() ) id = baseId + '_' + ColorSpaceId::ChannelId( colorSpace, i ); sourceWindow[i] = ImageWindow::WindowById( id ); if ( sourceWindow[i].IsNull() ) throw Error( "ChannelCombination: Source image not found: " + id ); sourceImage[i] = sourceWindow[i].MainView().Image(); if ( !sourceImage[i] ) throw Error( "ChannelCombination: Invalid source image: " + id ); if ( sourceImage[i]->IsColor() ) throw Error( "ChannelCombination: Invalid source color space: " + id ); if ( sourceImage[i]->Width() != w0 || sourceImage[i]->Height() != h0 ) throw Error( "ChannelCombination: Incompatible source image dimensions: " + id ); ++numberOfSources; } if ( numberOfSources == 0 ) return false; const char* what = ""; switch ( colorSpace ) { case ColorSpaceId::RGB: what = "RGB channels"; break; case ColorSpaceId::CIEXYZ: what = "normalized CIE XYZ components"; break; case ColorSpaceId::CIELab: what = "normalized CIE L*a*b* components"; break; case ColorSpaceId::CIELch: what = "normalized CIE L*c*h* components"; break; case ColorSpaceId::HSV: what = "normalized HSV components"; break; case ColorSpaceId::HSI: what = "normalized HSI components"; break; } image->Status().Initialize( String( "Combining " ) + what, image->NumberOfPixels() ); if ( image.IsFloatSample() ) switch ( image.BitsPerSample() ) { case 32: CombineChannels( static_cast<Image&>( *image ), colorSpace, baseId, r, sourceImage[0], sourceImage[1], sourceImage[2] ); break; case 64: CombineChannels( static_cast<DImage&>( *image ), colorSpace, baseId, r, sourceImage[0], sourceImage[1], sourceImage[2] ); break; } else switch ( image.BitsPerSample() ) { case 8: CombineChannels( static_cast<UInt8Image&>( *image ), colorSpace, baseId, r, sourceImage[0], sourceImage[1], sourceImage[2] ); break; case 16: CombineChannels( static_cast<UInt16Image&>( *image ), colorSpace, baseId, r, sourceImage[0], sourceImage[1], sourceImage[2] ); break; case 32: CombineChannels( static_cast<UInt32Image&>( *image ), colorSpace, baseId, r, sourceImage[0], sourceImage[1], sourceImage[2] ); break; } return true; }
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(); } } } }