This is BBRegionGraphicsController.m in view mode; [Download] [Up]
/* BBRegionGraphicsController.m
*
* This subclass of MiscInspector is in charge of a regions graphics
* settings.
*
* For more interface-info see the header file. In depth information
* can be found here in the source-code.
*
* Written by: Thomas Engel
* Created: 17.01.1994 (Copyleft)
* Last modified: 30.05.1994
*/
#import "BBRegionGraphicsController.h"
#import "../../BBRegion.h"
#import "../../BBRenderingStyle.h"
@implementation BBRegionGraphicsController
- renderConfDidChange:sender
{
// Should we continue to show the render settings ? If this is a region
// We will either delete the old setting or we will create a new setting
// that is a copy of the molecules settings.
id ourRegion;
ourRegion = [self selection];
if( [renderConfigSwitch state] == 1 )
{
// We will create a copy of the molecules settings where needed.
// Big BUG! Never gets free!
if( ![ourRegion doesHaveRotationStyle] )
{
[ourRegion setRotationStyle:[[[ourRegion molecule]
rotationStyle] copy]];
}
}
else
{
// We don't want to remove any molecules render style!!
if( ourRegion != [ourRegion molecule] )
[ourRegion setRotationStyle:nil];
}
[self revertRenderPopUps];
[self touch:self];
return self;
}
- ok:sender
{
// Here we'll take the values and apply them to the objects
id ourRegion;
id config;
int anInt;
ourRegion = [self selection];
[ourRegion setShapesInRegionColor:[regionColorSwitch state]];
[ourRegion setColor:[regionColorWell color]];
// If we had a private render config we will adopt the settings too.
if( [ourRegion doesHaveRotationStyle] )
{
config = [ourRegion rotationStyle];
switch( [[[[surfacePopUpCover target] itemList] selectedCell] tag] )
{
case BB_PointCloud: anInt = N3D_PointCloud; break;
case BB_WireFrame: anInt = N3D_WireFrame; break;
case BB_ShadedWireFrame: anInt = N3D_ShadedWireFrame; break;
case BB_FacetedSolids: anInt = N3D_FacetedSolids; break;
default: anInt = N3D_SmoothSolids;
}
[config setSurfaceType:(N3DSurfaceType)anInt];
anInt = [[[[geometryPopUpCover target] itemList] selectedCell] tag];
[config setGeometryType:(BBGeometryType)anInt];
/*
popUp = [shaderPopUpCover target];
[popUp setTarget:self];
[popUp setAction:@selector(touch:)];
[[popUp itemList] selectCellWithTag:[config geometryType]];
[shaderPopUpCover setTitle:[popUp selectedItem]];
*/
anInt = [[[[ratePopUpCover target] itemList] selectedCell] tag];
[config setShadingQuality:(BBQualityType)anInt];
anInt = [[[[approxPopUpCover target] itemList] selectedCell] tag];
[config setGeometryQuality:(BBQualityType)anInt];
}
return [super ok:sender];
}
- revert:sender
{
// Init the defauls. Take care of the color.
id ourRegion;
[super revert:sender];
ourRegion = [self selection];
[regionColorSwitch setState:[ourRegion shapesInRegionColor]];
[regionColorWell setColor:[ourRegion color]];
[self revertRenderPopUps];
return self;
}
- revertRenderPopUps
{
// Init the popUps. This is easier by code than by hand inside IB.
// We have to take care that the displayed Buttontitle is the same as the
// title of the cell we will select to be the start off.
// Only real region can turn on and of they settings.
id ourRegion;
id config;
id popUp;
int style;
ourRegion = [self selection];
if( ourRegion == [ourRegion molecule] )
{
[renderConfigSwitch setEnabled:NO];
[renderConfigSwitch setTransparent:YES];
}
else
{
[renderConfigSwitch setEnabled:YES];
[renderConfigSwitch setTransparent:NO];
}
// If the shape has a rotation style we will show the box.
// If it does not we will hide the view and do nothing. Quite easy.
if( ![ourRegion doesHaveRotationStyle] )
{
[renderConfigSwitch setState:0];
[renderConfigView removeFromSuperview];
[view display];
return self;
}
[renderConfigSwitch setState:1];
[view addSubview:renderConfigView];
// The surface seting is somewhat difficult because I don't want to rely on
// NeXTs typedefs when I set the tags in my NIB.
config = [ourRegion rotationStyle];
switch( [config surfaceType] )
{
case N3D_PointCloud: style = BB_PointCloud; break;
case N3D_WireFrame: style = BB_WireFrame; break;
case N3D_ShadedWireFrame: style = BB_ShadedWireFrame; break;
case N3D_FacetedSolids: style = BB_FacetedSolids; break;
default: style = BB_SmoothSolids;
}
popUp = [surfacePopUpCover target];
[popUp setTarget:self];
[popUp setAction:@selector(touch:)];
[[popUp itemList] selectCellWithTag:style];
[surfacePopUpCover setTitle:[popUp selectedItem]];
popUp = [geometryPopUpCover target];
[popUp setTarget:self];
[popUp setAction:@selector(touch:)];
[[popUp itemList] selectCellWithTag:[config geometryType]];
[geometryPopUpCover setTitle:[popUp selectedItem]];
/*
popUp = [shaderPopUpCover target];
[popUp setTarget:self];
[popUp setAction:@selector(touch:)];
[[popUp itemList] selectCellWithTag:[config geometryType]];
[shaderPopUpCover setTitle:[popUp selectedItem]];
*/
popUp = [ratePopUpCover target];
[popUp setTarget:self];
[popUp setAction:@selector(touch:)];
[[popUp itemList] selectCellWithTag:[config shadingQuality]];
[ratePopUpCover setTitle:[popUp selectedItem]];
popUp = [approxPopUpCover target];
[popUp setTarget:self];
[popUp setAction:@selector(touch:)];
[[popUp itemList] selectCellWithTag:[config geometryQuality]];
[approxPopUpCover setTitle:[popUp selectedItem]];
// Here is the final redraw. We need one to reflect the changes.
[view display];
return self;
}
- willSwapOut
{
[(NXColorWell *)regionColorWell deactivate];
return [super willSwapOut];
}
@end
/*
* History: 12.05.94 Converted to fit BB... naming
*
* 09.03.94 Made it the regions graphics inspector
*
* 17.01.94 First implementation.
*
*
* Bugs: - Created Render settings never get free!.
*/These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.