Ejemplo n.º 1
0
void HDRCompositionInterface::__InputImages_Click( Button& sender, bool checked )
{
   if ( sender == GUI->AddFiles_PushButton )
   {
      OpenFileDialog d;
      d.EnableMultipleSelections();
      d.LoadImageFilters();
      d.SetCaption( "HDRComposition: Select Input Images" );

      if ( d.Execute() )
      {
         size_type i0 = TreeInsertionIndex( GUI->InputImages_TreeBox );
         for ( StringList::const_iterator i = d.FileNames().Begin(); i != d.FileNames().End(); ++i )
            instance.images.Insert( instance.images.At( i0++ ), HDRCompositionInstance::ImageItem( *i ) );

         UpdateInputImagesList();
         UpdateImageSelectionButtons();
      }
   }
   else if ( sender == GUI->MoveUp_PushButton )
   {
      TreeBox::Node* node = GUI->InputImages_TreeBox.CurrentNode();
      if ( node != 0 )
      {
         int idx = GUI->InputImages_TreeBox.ChildIndex( node );
         if ( idx > 0 )
         {
            HDRCompositionInstance::ImageItem item = instance.images[idx];
            instance.images.Remove( instance.images.At( idx ) );
            instance.images.Insert( instance.images.At( idx-1 ), item );
            UpdateInputImagesList();
            GUI->InputImages_TreeBox.SetCurrentNode( GUI->InputImages_TreeBox[idx-1] );
            UpdateImageSelectionButtons();
         }
      }
   }
   else if ( sender == GUI->MoveDown_PushButton )
   {
      TreeBox::Node* node = GUI->InputImages_TreeBox.CurrentNode();
      if ( node != 0 )
      {
         int idx = GUI->InputImages_TreeBox.ChildIndex( node );
         if ( idx < int( instance.images.Length()-1 ) )
         {
            HDRCompositionInstance::ImageItem item = instance.images[idx];
            instance.images.Remove( instance.images.At( idx ) );
            instance.images.Insert( instance.images.At( idx+1 ), item );
            UpdateInputImagesList();
            GUI->InputImages_TreeBox.SetCurrentNode( GUI->InputImages_TreeBox[idx+1] );
            UpdateImageSelectionButtons();
         }
      }
   }
   else if ( sender == GUI->SelectAll_PushButton )
   {
      GUI->InputImages_TreeBox.SelectAllNodes();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->InvertSelection_PushButton )
   {
      for ( int i = 0, n = GUI->InputImages_TreeBox.NumberOfChildren(); i < n; ++i )
         GUI->InputImages_TreeBox[i]->Select( !GUI->InputImages_TreeBox[i]->IsSelected() );

      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->ToggleSelected_PushButton )
   {
      for ( int i = 0, n = GUI->InputImages_TreeBox.NumberOfChildren(); i < n; ++i )
         if ( GUI->InputImages_TreeBox[i]->IsSelected() )
            instance.images[i].enabled = !instance.images[i].enabled;

      UpdateInputImagesList();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->RemoveSelected_PushButton )
   {
      HDRCompositionInstance::image_list newImages;
      for ( int i = 0, n = GUI->InputImages_TreeBox.NumberOfChildren(); i < n; ++i )
         if ( !GUI->InputImages_TreeBox[i]->IsSelected() )
            newImages.Add( instance.images[i] );
      instance.images = newImages;

      UpdateInputImagesList();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->Clear_PushButton )
   {
      instance.images.Clear();
      UpdateInputImagesList();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->FullPaths_CheckBox )
   {
      UpdateInputImagesList();
      UpdateImageSelectionButtons();
   }
}
void GradientsMergeMosaicInterface::__TargetImages_Click( Button& sender, bool checked )
{
   if ( sender == GUI->AddFiles_PushButton )
   {
      OpenFileDialog d;
      d.EnableMultipleSelections();
      d.LoadImageFilters();
      d.SetCaption( "GradientsMergeMosaic: Select Target Frames" );

      if ( d.Execute() )
      {
         size_type i0 = TreeInsertionIndex( GUI->TargetImages_TreeBox );
         for ( StringList::const_iterator i = d.FileNames().Begin(); i != d.FileNames().End(); ++i )
            instance.targetFrames.Insert( instance.targetFrames.At( i0++ ), GradientsMergeMosaicInstance::ImageItem( *i ) );
         UpdateTargetImagesList();
         UpdateImageSelectionButtons();
      }
   }
   else if ( sender == GUI->MoveUp_PushButton )
   {
     for (int i=0,n = GUI->TargetImages_TreeBox.NumberOfChildren(); i<n; ++i) {
       if ( GUI->TargetImages_TreeBox[i]->IsSelected() ) {
	 if(i==0) {
	   // first is selected, we cannot really do something about this
	   break;
	 } else {
	   // swap order with previous one
	   GradientsMergeMosaicInstance::ImageItem tmp=instance.targetFrames[i-1];
	   instance.targetFrames[i-1]=instance.targetFrames[i];
	   instance.targetFrames[i]=tmp;
	   GUI->TargetImages_TreeBox[i]->Select(false);
	   GUI->TargetImages_TreeBox[i-1]->Select(true);
	   UpdateTargetImageItem(i);
	   UpdateTargetImageItem(i-1);
	 }
       }
     }
     // FIXME this restores the original selection list, which is just what I dont want.
     // Added UpdateTargetImageItem() above which is slightly less efficient
     // UpdateTargetImagesList();
   }
   else if ( sender == GUI->MoveDown_PushButton )
   {
     for (int n = GUI->TargetImages_TreeBox.NumberOfChildren(),i=n-1; i>=0; --i) {
       if ( GUI->TargetImages_TreeBox[i]->IsSelected() ) {
	 if(i==n-1) {
	   // first is selected, we cannot really do something about this
	   break;
	 } else {
	   // swap order with next one
	   GradientsMergeMosaicInstance::ImageItem tmp=instance.targetFrames[i];
	   instance.targetFrames[i]=instance.targetFrames[i+1];
	   instance.targetFrames[i+1]=tmp;
	   GUI->TargetImages_TreeBox[i]->Select(false);
	   GUI->TargetImages_TreeBox[i+1]->Select(true);
	   UpdateTargetImageItem(i);
	   UpdateTargetImageItem(i+1);
	 }
       }
     }
     // FIXME this restores the original selection list, which is just what I dont want.
     // Added UpdateTargetImageItem() above which is slightly less efficient
     // UpdateTargetImagesList();
   }
   else if ( sender == GUI->SelectAll_PushButton )
   {
      GUI->TargetImages_TreeBox.SelectAllNodes();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->InvertSelection_PushButton )
   {
      for ( int i = 0, n = GUI->TargetImages_TreeBox.NumberOfChildren(); i < n; ++i )
         GUI->TargetImages_TreeBox[i]->Select( !GUI->TargetImages_TreeBox[i]->IsSelected() );
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->ToggleSelected_PushButton )
   {
      for ( int i = 0, n = GUI->TargetImages_TreeBox.NumberOfChildren(); i < n; ++i )
         if ( GUI->TargetImages_TreeBox[i]->IsSelected() )
            instance.targetFrames[i].enabled = !instance.targetFrames[i].enabled;
      UpdateTargetImagesList();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->RemoveSelected_PushButton )
   {
      GradientsMergeMosaicInstance::image_list newTargets;
      for ( int i = 0, n = GUI->TargetImages_TreeBox.NumberOfChildren(); i < n; ++i )
         if ( !GUI->TargetImages_TreeBox[i]->IsSelected() )
            newTargets.Add( instance.targetFrames[i] );
      instance.targetFrames = newTargets;
      UpdateTargetImagesList();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->Clear_PushButton )
   {
      instance.targetFrames.Clear();
      UpdateTargetImagesList();
      UpdateImageSelectionButtons();
   }
   else if ( sender == GUI->FullPaths_CheckBox )
   {
      UpdateTargetImagesList();
      UpdateImageSelectionButtons();
   }
}