/*
 * Copyright 1993 by Cub'x Systemes
 * 
 * All Rights Reserved
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for the  purpose of making new intuitiv'3d modules.
 * This copyright notice must appears in all copies that you distribute.
 * The name of Cub'x Systeme should not be used in advertising or publicity
 * without specific, written prior permission. 
 * CUB'X SYSTEMES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * CUB'X SYSTEMES BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
/******************************************************************************* 
 *                                                                             *
 *     Project AdvancedObject                                                  *
 *     ----------------------                                                  *
 *                                                                             *
 *                                                                             *
 *     File:SlideProjectorInsp.m                                               *
 *                                                                             *
 *                                                                             *
 *     Creation date:Fri Jul 30 15:25:35 GMT+0200 1993                         *
 *                                                                             *
 *                                                                             *
 *     Contents: An attribute inspector for the slide projector light          *
 *                                                                             *
 *                                                                             *
 *******************************************************************************/

#import <i3d/i3d_api.h>
#import "SlideProjectorInsp.h"
#import <appkit/Control.h>
#import "SlideProjector.h"

@implementation SlideProjectorInsp 


/*******************************************************************************
 *                                                                             *
 *                                Class methods                                *
 *                                                                             *
 *******************************************************************************/
+ (const char*)nibName
{
  return "SlideProjectorInsp";
}

/*******************************************************************************
 *                                                                             *
 *                                  Interface                                  *
 *                                                                             *
 *******************************************************************************
/*
 *  Target / action methods. Please see DistortedCubeInsp.nib
 * 
 * Please notice macro usage to be real-time if needed.
 */

- fieldOfViewChange: sender
{
  float v = [sender floatValue];
  if( v < 0 )
    v = 0;
  else if( v > 360.0 )
    v = 360.0;
  [sender setFloatValue: v];
  UPDATE_OBJECT_IF_NEED(setFieldOfView:, v);
  return self;
}

- upXChange: sender
{
  UPDATE_OBJECT_IF_NEED(setUpX:,[sender floatValue]);
  return self;
}

- upYChange: sender
{
  UPDATE_OBJECT_IF_NEED(setUpY:,[sender floatValue]);
  return self;
}

- upZChange: sender
{
  UPDATE_OBJECT_IF_NEED(setUpZ:,[sender floatValue]);
  return self;
}

- imageFileChange: sender
{
  UPDATE_OBJECT_IF_NEED(setSlideName:,[sender stringValue]);
  return self;
}

- setImageFile: sender
{
  id op = [CXOpenPanel new];
  static char *suffixe[] = { "tiff", "tx", NULL };

  [op allowMultipleFiles: NO];
  [op chooseDirectories: NO];
  [op setTitle:"Open image"];
  if( [op runModalForTypes:suffixe] )
    { 
      const char * s = [op filename];
      [imageFilet setStringValue: s];
      [self imageFileChange: imageFilet];
    }
  return self;
}

- shadowChange: sender
{
  UPDATE_OBJECT_IF_NEED( setUseShadow: , [sender state] ? YES : NO );
  return self;
}

- shadowDetailChange: sender
{
  float v = [sender floatValue];
  if( v < 1 )
    v = 1;
  else if( v > 100 )
    v = 100;
  [sender setFloatValue: v];
  UPDATE_OBJECT_IF_NEED( setShadowDetail:, v);
  return self;
}

/*******************************************************************************
 *                                                                             *
 *   Instance methods to be compatible with intuitiv'3d's inspector protocol.  *
 *                                                                             *
 *******************************************************************************/

- sendAllValueToObject: anObject
{
  [anObject setFieldOfView: [fieldOfViewt floatValue]];
  [anObject setUpX:         [upXt floatValue]];
  [anObject setUpY:         [upYt floatValue]];
  [anObject setUpZ:         [upZt floatValue]];
  [anObject setSlideName:   [imageFilet stringValue]];
  [anObject setUseShadow:   [shadowc state] ? YES : NO];
  [anObject setShadowDetail:[shadowDetailt floatValue]];
  return self;
}

- receiveAllValueFromObject: anObject
{
  [fieldOfViewt setFloatValue: [anObject fieldOfView]];
  [upXt        setFloatValue: [anObject upX]];
  [upYt        setFloatValue: [anObject upY]];
  [upZt        setFloatValue: [anObject upZ]];
  [imageFilet  setStringValue: [anObject slideName]];
  [shadowc     setState:      [anObject useShadow] ? YES : NO];
  [shadowDetailt setFloatValue: [anObject shadowDetail]];
  return self;
}

- (const char*) title
{
  return "Slide projector inspector";
}

@end




