2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "patchmanip.h"
24 #include "debugging/debugging.h"
27 #include "iselection.h"
30 #include "math/vector.h"
31 #include "math/aabb.h"
32 #include "generic/callback.h"
34 #include "gtkutil/menu.h"
35 #include "gtkutil/image.h"
37 #include "mainframe.h"
41 #include "texwindow.h"
47 PatchCreator* g_patchCreator = 0;
49 void Scene_PatchConstructPrefab( scene::Graph& graph, const AABB aabb, const char* shader, EPatchPrefab eType, int axis, std::size_t width = 3, std::size_t height = 3 ){
51 GlobalSelectionSystem().setSelectedAll( false );
53 NodeSmartReference node( g_patchCreator->createPatch() );
54 Node_getTraversable( Map_FindOrInsertWorldspawn( g_map ) )->insert( node );
56 Patch* patch = Node_getPatch( node );
57 patch->SetShader( shader );
59 patch->ConstructPrefab( aabb, eType, axis, width, height );
60 patch->controlPointsChanged();
63 scene::Path patchpath( makeReference( GlobalSceneGraph().root() ) );
64 patchpath.push( makeReference( *Map_GetWorldspawn( g_map ) ) );
65 patchpath.push( makeReference( node.get() ) );
66 Instance_getSelectable( *graph.find( patchpath ) )->setSelected( true );
71 void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, const char* shader ){
72 if ( ( type == eCapEndCap || type == eCapIEndCap )
73 && patch.getWidth() != 5 ) {
74 globalErrorStream() << "cannot create end-cap - patch width != 5\n";
77 if ( ( type == eCapBevel || type == eCapIBevel )
78 && patch.getWidth() != 3 && patch.getWidth() != 5 ) {
79 globalErrorStream() << "cannot create bevel-cap - patch width != 3\n";
82 if ( type == eCapCylinder
83 && patch.getWidth() != 9 ) {
84 globalErrorStream() << "cannot create cylinder-cap - patch width != 9\n";
89 NodeSmartReference cap( g_patchCreator->createPatch() );
90 Node_getTraversable( instance.path().parent() )->insert( cap );
92 patch.MakeCap( Node_getPatch( cap ), type, ROW, true );
93 Node_getPatch( cap )->SetShader( shader );
95 scene::Path path( instance.path() );
97 path.push( makeReference( cap.get() ) );
98 selectPath( path, true );
102 NodeSmartReference cap( g_patchCreator->createPatch() );
103 Node_getTraversable( instance.path().parent() )->insert( cap );
105 patch.MakeCap( Node_getPatch( cap ), type, ROW, false );
106 Node_getPatch( cap )->SetShader( shader );
108 scene::Path path( instance.path() );
110 path.push( makeReference( cap.get() ) );
111 selectPath( path, true );
116 typedef std::vector<scene::Instance*> InstanceVector;
118 class PatchStoreInstance
120 InstanceVector& m_instances;
122 PatchStoreInstance( InstanceVector& instances ) : m_instances( instances ){
124 void operator()( PatchInstance& patch ) const {
125 m_instances.push_back( &patch );
132 PATCHCAP_INVERTED_BEVEL,
133 PATCHCAP_INVERTED_ENDCAP,
137 EMessageBoxReturn DoCapDlg( ECapDialog *type );
139 void Scene_PatchDoCap_Selected( scene::Graph& graph, const char* shader ){
142 if ( DoCapDlg( &nType ) == eIDOK ) {
146 case PATCHCAP_INVERTED_BEVEL:
152 case PATCHCAP_INVERTED_ENDCAP:
155 case PATCHCAP_ENDCAP:
158 case PATCHCAP_CYLINDER:
159 eType = eCapCylinder;
162 ERROR_MESSAGE( "invalid patch cap type" );
166 InstanceVector instances;
167 Scene_forEachVisibleSelectedPatchInstance( PatchStoreInstance( instances ) );
168 for ( InstanceVector::const_iterator i = instances.begin(); i != instances.end(); ++i )
170 Patch_makeCaps( *Node_getPatch( ( *i )->path().top() ), *( *i ), eType, shader );
175 void Patch_deform( Patch& patch, scene::Instance& instance, const int deform ){
178 for (PatchControlIter i = patch.begin(); i != patch.end(); ++i)
180 PatchControl& control = *i;
181 int randomNumber = int( deform * (float(std::rand()) / float(RAND_MAX)));
182 control.m_vertex[2] += randomNumber;
185 patch.controlPointsChanged();
188 void Scene_PatchDeform( scene::Graph& graph, const int deform )
190 InstanceVector instances;
191 Scene_forEachVisibleSelectedPatchInstance( PatchStoreInstance( instances ) );
192 for ( InstanceVector::const_iterator i = instances.begin(); i != instances.end(); ++i )
194 Patch_deform( *Node_getPatch( ( *i )->path().top() ), *( *i ), deform );
199 Patch* Scene_GetUltimateSelectedVisiblePatch(){
200 if ( GlobalSelectionSystem().countSelected() != 0 ) {
201 scene::Node& node = GlobalSelectionSystem().ultimateSelected().path().top();
202 if ( node.visible() ) {
203 return Node_getPatch( node );
210 class PatchCapTexture
213 void operator()( Patch& patch ) const {
214 patch.ProjectTexture( Patch::m_CycleCapIndex );
218 void Scene_PatchCapTexture_Selected( scene::Graph& graph ){
219 Scene_forEachVisibleSelectedPatch( PatchCapTexture() );
220 Patch::m_CycleCapIndex = ( Patch::m_CycleCapIndex == 0 ) ? 1 : ( Patch::m_CycleCapIndex == 1 ) ? 2 : 0;
224 class PatchFlipTexture
228 PatchFlipTexture( int axis ) : m_axis( axis ){
230 void operator()( Patch& patch ) const {
231 patch.FlipTexture( m_axis );
235 void Scene_PatchFlipTexture_Selected( scene::Graph& graph, int axis ){
236 Scene_forEachVisibleSelectedPatch( PatchFlipTexture( axis ) );
239 class PatchNaturalTexture
242 void operator()( Patch& patch ) const {
243 patch.NaturalTexture();
247 void Scene_PatchNaturalTexture_Selected( scene::Graph& graph ){
248 Scene_forEachVisibleSelectedPatch( PatchNaturalTexture() );
253 class PatchInsertRemove
255 bool m_insert, m_column, m_first;
257 PatchInsertRemove( bool insert, bool column, bool first ) : m_insert( insert ), m_column( column ), m_first( first ){
259 void operator()( Patch& patch ) const {
260 patch.InsertRemove( m_insert, m_column, m_first );
264 void Scene_PatchInsertRemove_Selected( scene::Graph& graph, bool bInsert, bool bColumn, bool bFirst ){
265 Scene_forEachVisibleSelectedPatch( PatchInsertRemove( bInsert, bColumn, bFirst ) );
268 class PatchInvertMatrix
271 void operator()( Patch& patch ) const {
272 patch.InvertMatrix();
276 void Scene_PatchInvert_Selected( scene::Graph& graph ){
277 Scene_forEachVisibleSelectedPatch( PatchInvertMatrix() );
280 class PatchRedisperse
282 EMatrixMajor m_major;
284 PatchRedisperse( EMatrixMajor major ) : m_major( major ){
286 void operator()( Patch& patch ) const {
287 patch.Redisperse( m_major );
291 void Scene_PatchRedisperse_Selected( scene::Graph& graph, EMatrixMajor major ){
292 Scene_forEachVisibleSelectedPatch( PatchRedisperse( major ) );
297 EMatrixMajor m_major;
299 PatchSmooth( EMatrixMajor major ) : m_major( major ){
301 void operator()( Patch& patch ) const {
302 patch.Smooth( m_major );
306 void Scene_PatchSmooth_Selected( scene::Graph& graph, EMatrixMajor major ){
307 Scene_forEachVisibleSelectedPatch( PatchSmooth( major ) );
310 class PatchTransposeMatrix
313 void operator()( Patch& patch ) const {
314 patch.TransposeMatrix();
318 void Scene_PatchTranspose_Selected( scene::Graph& graph ){
319 Scene_forEachVisibleSelectedPatch( PatchTransposeMatrix() );
326 PatchSetShader( const char* name )
329 void operator()( Patch& patch ) const {
330 patch.SetShader( m_name );
334 void Scene_PatchSetShader_Selected( scene::Graph& graph, const char* name ){
335 Scene_forEachVisibleSelectedPatch( PatchSetShader( name ) );
339 void Scene_PatchGetShader_Selected( scene::Graph& graph, CopiedString& name ){
340 Patch* patch = Scene_GetUltimateSelectedVisiblePatch();
342 name = patch->GetShader();
346 class PatchSelectByShader
350 inline PatchSelectByShader( const char* name )
353 void operator()( PatchInstance& patch ) const {
354 if ( shader_equal( patch.getPatch().GetShader(), m_name ) ) {
355 patch.setSelected( true );
360 void Scene_PatchSelectByShader( scene::Graph& graph, const char* name ){
361 Scene_forEachVisiblePatchInstance( PatchSelectByShader( name ) );
365 class PatchFindReplaceShader
368 const char* m_replace;
370 PatchFindReplaceShader( const char* find, const char* replace ) : m_find( find ), m_replace( replace ){
372 void operator()( Patch& patch ) const {
373 if ( shader_equal( patch.GetShader(), m_find ) ) {
374 patch.SetShader( m_replace );
379 void Scene_PatchFindReplaceShader( scene::Graph& graph, const char* find, const char* replace ){
380 Scene_forEachVisiblePatch( PatchFindReplaceShader( find, replace ) );
383 void Scene_PatchFindReplaceShader_Selected( scene::Graph& graph, const char* find, const char* replace ){
384 Scene_forEachVisibleSelectedPatch( PatchFindReplaceShader( find, replace ) );
388 AABB PatchCreator_getBounds(){
389 AABB aabb( aabb_for_minmax( Select_getWorkZone().d_work_min, Select_getWorkZone().d_work_max ) );
391 float gridSize = GetGridSize();
393 if ( aabb.extents[0] == 0 ) {
394 aabb.extents[0] = gridSize;
396 if ( aabb.extents[1] == 0 ) {
397 aabb.extents[1] = gridSize;
399 if ( aabb.extents[2] == 0 ) {
400 aabb.extents[2] = gridSize;
403 if ( aabb_valid( aabb ) ) {
406 return AABB( Vector3( 0, 0, 0 ), Vector3( 64, 64, 64 ) );
409 void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, int defcols, int maxrows, int maxcols );
411 void Patch_XactCylinder(){
412 UndoableCommand undo( "patchCreateXactCylinder" );
414 DoNewPatchDlg( eXactCylinder, 3, 7, 3, 13, 0, 0 );
417 void Patch_XactSphere(){
418 UndoableCommand undo( "patchCreateXactSphere" );
420 DoNewPatchDlg( eXactSphere, 5, 7, 7, 13, 0, 0 );
423 void Patch_XactCone(){
424 UndoableCommand undo( "patchCreateXactCone" );
426 DoNewPatchDlg( eXactCone, 3, 7, 3, 13, 0, 0 );
429 void Patch_Cylinder(){
430 UndoableCommand undo( "patchCreateCylinder" );
432 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eCylinder, GlobalXYWnd_getCurrentViewType() );
435 void Patch_DenseCylinder(){
436 UndoableCommand undo( "patchCreateDenseCylinder" );
438 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eDenseCylinder, GlobalXYWnd_getCurrentViewType() );
441 void Patch_VeryDenseCylinder(){
442 UndoableCommand undo( "patchCreateVeryDenseCylinder" );
444 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eVeryDenseCylinder, GlobalXYWnd_getCurrentViewType() );
447 void Patch_SquareCylinder(){
448 UndoableCommand undo( "patchCreateSquareCylinder" );
450 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eSqCylinder, GlobalXYWnd_getCurrentViewType() );
454 UndoableCommand undo( "patchCreateCaps" );
456 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eEndCap, GlobalXYWnd_getCurrentViewType() );
460 UndoableCommand undo( "patchCreateBevel" );
462 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eBevel, GlobalXYWnd_getCurrentViewType() );
466 UndoableCommand undo( "patchCreateSphere" );
468 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eSphere, GlobalXYWnd_getCurrentViewType() );
471 void Patch_SquareBevel(){
474 void Patch_SquareEndcap(){
478 UndoableCommand undo( "patchCreateCone" );
480 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eCone, GlobalXYWnd_getCurrentViewType() );
484 UndoableCommand undo( "patchCreatePlane" );
486 DoNewPatchDlg( ePlane, 3, 3, 3, 3, 0, 0 );
489 void Patch_InsertInsertColumn(){
490 UndoableCommand undo( "patchInsertColumns" );
492 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, true, false );
495 void Patch_InsertAddColumn(){
496 UndoableCommand undo( "patchAddColumns" );
498 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, true, true );
501 void Patch_InsertInsertRow(){
502 UndoableCommand undo( "patchInsertRows" );
504 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, false, false );
507 void Patch_InsertAddRow(){
508 UndoableCommand undo( "patchAddRows" );
510 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, false, true );
513 void Patch_DeleteFirstColumn(){
514 UndoableCommand undo( "patchDeleteFirstColumns" );
516 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), false, true, true );
519 void Patch_DeleteLastColumn(){
520 UndoableCommand undo( "patchDeleteLastColumns" );
522 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), false, true, false );
525 void Patch_DeleteFirstRow(){
526 UndoableCommand undo( "patchDeleteFirstRows" );
528 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), false, false, true );
531 void Patch_DeleteLastRow(){
532 UndoableCommand undo( "patchDeleteLastRows" );
534 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), false, false, false );
538 UndoableCommand undo( "patchInvert" );
540 Scene_PatchInvert_Selected( GlobalSceneGraph() );
543 void Patch_RedisperseRows(){
544 UndoableCommand undo( "patchRedisperseRows" );
546 Scene_PatchRedisperse_Selected( GlobalSceneGraph(), ROW );
549 void Patch_RedisperseCols(){
550 UndoableCommand undo( "patchRedisperseColumns" );
552 Scene_PatchRedisperse_Selected( GlobalSceneGraph(), COL );
555 void Patch_SmoothRows(){
556 UndoableCommand undo( "patchSmoothRows" );
558 Scene_PatchSmooth_Selected( GlobalSceneGraph(), ROW );
561 void Patch_SmoothCols(){
562 UndoableCommand undo( "patchSmoothColumns" );
564 Scene_PatchSmooth_Selected( GlobalSceneGraph(), COL );
567 void Patch_Transpose(){
568 UndoableCommand undo( "patchTranspose" );
570 Scene_PatchTranspose_Selected( GlobalSceneGraph() );
574 // FIXME: add support for patch cap creation
575 // Patch_CapCurrent();
576 UndoableCommand undo( "patchCreateCaps" );
578 Scene_PatchDoCap_Selected( GlobalSceneGraph(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) );
581 void Patch_CycleProjection(){
582 UndoableCommand undo( "patchCycleUVProjectionAxis" );
584 Scene_PatchCapTexture_Selected( GlobalSceneGraph() );
588 void Patch_OverlayOn(){
592 void Patch_OverlayOff(){
595 void Patch_FlipTextureX(){
596 UndoableCommand undo( "patchFlipTextureU" );
598 Scene_PatchFlipTexture_Selected( GlobalSceneGraph(), 0 );
601 void Patch_FlipTextureY(){
602 UndoableCommand undo( "patchFlipTextureV" );
604 Scene_PatchFlipTexture_Selected( GlobalSceneGraph(), 1 );
607 void Patch_NaturalTexture(){
608 UndoableCommand undo( "patchNaturalTexture" );
610 Scene_PatchNaturalTexture_Selected( GlobalSceneGraph() );
613 void DoPatchDeformDlg();
616 UndoableCommand undo( "patchDeform" );
627 class filter_patch_all : public PatchFilter
630 bool filter( const Patch& patch ) const {
635 class filter_patch_shader : public PatchFilter
637 const char* m_shader;
639 filter_patch_shader( const char* shader ) : m_shader( shader ){
641 bool filter( const Patch& patch ) const {
642 return shader_equal( patch.GetShader(), m_shader );
646 class filter_patch_flags : public PatchFilter
650 filter_patch_flags( int flags ) : m_flags( flags ){
652 bool filter( const Patch& patch ) const {
653 return ( patch.getShaderFlags() & m_flags ) != 0;
658 filter_patch_all g_filter_patch_all;
659 filter_patch_shader g_filter_patch_clip( "textures/common/clip" );
660 filter_patch_shader g_filter_patch_weapclip( "textures/common/weapclip" );
661 filter_patch_flags g_filter_patch_translucent( QER_TRANS );
663 void PatchFilters_construct(){
664 add_patch_filter( g_filter_patch_all, EXCLUDE_CURVES );
665 add_patch_filter( g_filter_patch_clip, EXCLUDE_CLIP );
666 add_patch_filter( g_filter_patch_weapclip, EXCLUDE_CLIP );
667 add_patch_filter( g_filter_patch_translucent, EXCLUDE_TRANSLUCENT );
671 #include "preferences.h"
673 void Patch_constructPreferences( PreferencesPage& page ){
674 page.appendEntry( "Patch Subdivide Threshold", g_PatchSubdivideThreshold );
676 void Patch_constructPage( PreferenceGroup& group ){
677 PreferencesPage page( group.createPage( "Patches", "Patch Display Preferences" ) );
678 Patch_constructPreferences( page );
680 void Patch_registerPreferencesPage(){
681 PreferencesDialog_addDisplayPage( FreeCaller1<PreferenceGroup&, Patch_constructPage>() );
685 #include "preferencesystem.h"
687 void PatchPreferences_construct(){
688 GlobalPreferenceSystem().registerPreference( "Subdivisions", IntImportStringCaller( g_PatchSubdivideThreshold ), IntExportStringCaller( g_PatchSubdivideThreshold ) );
692 #include "generic/callback.h"
694 void Patch_registerCommands(){
695 GlobalCommands_insert( "InvertCurveTextureX", FreeCaller<Patch_FlipTextureX>(), Accelerator( 'I', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
696 GlobalCommands_insert( "InvertCurveTextureY", FreeCaller<Patch_FlipTextureY>(), Accelerator( 'I', (GdkModifierType)GDK_SHIFT_MASK ) );
697 GlobalCommands_insert( "IncPatchColumn", FreeCaller<Patch_InsertInsertColumn>(), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
698 GlobalCommands_insert( "IncPatchRow", FreeCaller<Patch_InsertInsertRow>(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
699 GlobalCommands_insert( "DecPatchColumn", FreeCaller<Patch_DeleteLastColumn>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
700 GlobalCommands_insert( "DecPatchRow", FreeCaller<Patch_DeleteLastRow>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) );
701 GlobalCommands_insert( "NaturalizePatch", FreeCaller<Patch_NaturalTexture>(), Accelerator( 'N', (GdkModifierType)GDK_CONTROL_MASK ) );
702 GlobalCommands_insert( "PatchCylinder", FreeCaller<Patch_Cylinder>() );
703 GlobalCommands_insert( "PatchDenseCylinder", FreeCaller<Patch_DenseCylinder>() );
704 GlobalCommands_insert( "PatchVeryDenseCylinder", FreeCaller<Patch_VeryDenseCylinder>() );
705 GlobalCommands_insert( "PatchSquareCylinder", FreeCaller<Patch_SquareCylinder>() );
706 GlobalCommands_insert( "PatchXactCylinder", FreeCaller<Patch_XactCylinder>() );
707 GlobalCommands_insert( "PatchXactSphere", FreeCaller<Patch_XactSphere>() );
708 GlobalCommands_insert( "PatchXactCone", FreeCaller<Patch_XactCone>() );
709 GlobalCommands_insert( "PatchEndCap", FreeCaller<Patch_Endcap>() );
710 GlobalCommands_insert( "PatchBevel", FreeCaller<Patch_Bevel>() );
711 GlobalCommands_insert( "PatchSquareBevel", FreeCaller<Patch_SquareBevel>() );
712 GlobalCommands_insert( "PatchSquareEndcap", FreeCaller<Patch_SquareEndcap>() );
713 GlobalCommands_insert( "PatchCone", FreeCaller<Patch_Cone>() );
714 GlobalCommands_insert( "PatchSphere", FreeCaller<Patch_Sphere>() );
715 GlobalCommands_insert( "SimplePatchMesh", FreeCaller<Patch_Plane>(), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) );
716 GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller<Patch_InsertInsertColumn>() );
717 GlobalCommands_insert( "PatchInsertAddColumn", FreeCaller<Patch_InsertAddColumn>() );
718 GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller<Patch_InsertInsertRow>() );
719 GlobalCommands_insert( "PatchInsertAddRow", FreeCaller<Patch_InsertAddRow>() );
720 GlobalCommands_insert( "PatchDeleteFirstColumn", FreeCaller<Patch_DeleteFirstColumn>() );
721 GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller<Patch_DeleteLastColumn>() );
722 GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller<Patch_DeleteFirstRow>() );
723 GlobalCommands_insert( "PatchDeleteLastRow", FreeCaller<Patch_DeleteLastRow>() );
724 GlobalCommands_insert( "InvertCurve", FreeCaller<Patch_Invert>(), Accelerator( 'I', (GdkModifierType)GDK_CONTROL_MASK ) );
725 GlobalCommands_insert( "RedisperseRows", FreeCaller<Patch_RedisperseRows>(), Accelerator( 'E', (GdkModifierType)GDK_CONTROL_MASK ) );
726 GlobalCommands_insert( "RedisperseCols", FreeCaller<Patch_RedisperseCols>(), Accelerator( 'E', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
727 GlobalCommands_insert( "SmoothRows", FreeCaller<Patch_SmoothRows>(), Accelerator( 'W', (GdkModifierType)GDK_CONTROL_MASK ) );
728 GlobalCommands_insert( "SmoothCols", FreeCaller<Patch_SmoothCols>(), Accelerator( 'W', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
729 GlobalCommands_insert( "MatrixTranspose", FreeCaller<Patch_Transpose>(), Accelerator( 'M', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
730 GlobalCommands_insert( "CapCurrentCurve", FreeCaller<Patch_Cap>(), Accelerator( 'C', (GdkModifierType)GDK_SHIFT_MASK ) );
731 GlobalCommands_insert( "CycleCapTexturePatch", FreeCaller<Patch_CycleProjection>(), Accelerator( 'N', (GdkModifierType)GDK_SHIFT_MASK ) );
732 GlobalCommands_insert( "MakeOverlayPatch", FreeCaller<Patch_OverlayOn>(), Accelerator( 'Y' ) );
733 GlobalCommands_insert( "ClearPatchOverlays", FreeCaller<Patch_OverlayOff>(), Accelerator( 'L', (GdkModifierType)GDK_CONTROL_MASK ) );
734 GlobalCommands_insert( "PatchDeform", FreeCaller<Patch_Deform>() );
737 void Patch_constructToolbar( GtkToolbar* toolbar ){
738 toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "curve_cap.bmp", "CapCurrentCurve" );
741 void Patch_constructMenu( GtkMenu* menu ){
742 create_menu_item_with_mnemonic( menu, "Cylinder", "PatchCylinder" );
744 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" );
745 if ( g_Layout_enableDetachableMenus.m_value ) {
746 menu_tearoff( menu_in_menu );
748 create_menu_item_with_mnemonic( menu_in_menu, "Dense Cylinder", "PatchDenseCylinder" );
749 create_menu_item_with_mnemonic( menu_in_menu, "Very Dense Cylinder", "PatchVeryDenseCylinder" );
750 create_menu_item_with_mnemonic( menu_in_menu, "Square Cylinder", "PatchSquareCylinder" );
751 create_menu_item_with_mnemonic( menu_in_menu, "Exact Cylinder...", "PatchXactCylinder" );
753 menu_separator( menu );
754 create_menu_item_with_mnemonic( menu, "End cap", "PatchEndCap" );
755 create_menu_item_with_mnemonic( menu, "Bevel", "PatchBevel" );
757 // GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More End caps, Bevels" );
758 // if ( g_Layout_enableDetachableMenus.m_value ) {
759 // menu_tearoff( menu_in_menu );
761 create_menu_item_with_mnemonic( menu, "Square Endcap", "PatchSquareBevel" );
762 create_menu_item_with_mnemonic( menu, "Square Bevel", "PatchSquareEndcap" );
764 menu_separator( menu );
765 create_menu_item_with_mnemonic( menu, "Cone", "PatchCone" );
766 create_menu_item_with_mnemonic( menu, "Exact Cone...", "PatchXactCone" );
767 menu_separator( menu );
768 create_menu_item_with_mnemonic( menu, "Sphere", "PatchSphere" );
769 create_menu_item_with_mnemonic( menu, "Exact Sphere...", "PatchXactSphere" );
770 menu_separator( menu );
771 create_menu_item_with_mnemonic( menu, "Simple Patch Mesh...", "SimplePatchMesh" );
772 menu_separator( menu );
774 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert" );
775 if ( g_Layout_enableDetachableMenus.m_value ) {
776 menu_tearoff( menu_in_menu );
778 create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Columns", "PatchInsertInsertColumn" );
779 create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Columns", "PatchInsertAddColumn" );
780 menu_separator( menu_in_menu );
781 create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Rows", "PatchInsertInsertRow" );
782 create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Rows", "PatchInsertAddRow" );
785 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Delete" );
786 if ( g_Layout_enableDetachableMenus.m_value ) {
787 menu_tearoff( menu_in_menu );
789 create_menu_item_with_mnemonic( menu_in_menu, "First (2) Columns", "PatchDeleteFirstColumn" );
790 create_menu_item_with_mnemonic( menu_in_menu, "Last (2) Columns", "PatchDeleteLastColumn" );
791 menu_separator( menu_in_menu );
792 create_menu_item_with_mnemonic( menu_in_menu, "First (2) Rows", "PatchDeleteFirstRow" );
793 create_menu_item_with_mnemonic( menu_in_menu, "Last (2) Rows", "PatchDeleteLastRow" );
795 menu_separator( menu );
797 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Matrix" );
798 if ( g_Layout_enableDetachableMenus.m_value ) {
799 menu_tearoff( menu_in_menu );
801 create_menu_item_with_mnemonic( menu_in_menu, "Invert", "InvertCurve" );
802 create_menu_item_with_mnemonic( menu_in_menu, "Transpose", "MatrixTranspose" );
803 // GtkMenu* menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Re-disperse" );
804 // if ( g_Layout_enableDetachableMenus.m_value ) {
805 // menu_tearoff( menu_3 );
807 menu_separator( menu_in_menu );
808 create_menu_item_with_mnemonic( menu_in_menu, "Re-disperse Rows", "RedisperseRows" );
809 create_menu_item_with_mnemonic( menu_in_menu, "Re-disperse Columns", "RedisperseCols" );
810 // GtkMenu* menu_4 = create_sub_menu_with_mnemonic( menu_in_menu, "Smooth" );
811 // if ( g_Layout_enableDetachableMenus.m_value ) {
812 // menu_tearoff( menu_4 );
814 menu_separator( menu_in_menu );
815 create_menu_item_with_mnemonic( menu_in_menu, "Smooth Rows", "SmoothRows" );
816 create_menu_item_with_mnemonic( menu_in_menu, "Smooth Columns", "SmoothCols" );
818 menu_separator( menu );
819 create_menu_item_with_mnemonic( menu, "Cap Selection", "CapCurrentCurve" );
820 menu_separator( menu );
822 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Texture" );
823 if ( g_Layout_enableDetachableMenus.m_value ) {
824 menu_tearoff( menu_in_menu );
826 create_menu_item_with_mnemonic( menu_in_menu, "Cycle Projection", "CycleCapTexturePatch" );
827 create_menu_item_with_mnemonic( menu_in_menu, "Naturalize", "NaturalizePatch" );
828 create_menu_item_with_mnemonic( menu_in_menu, "Invert X", "InvertCurveTextureX" );
829 create_menu_item_with_mnemonic( menu_in_menu, "Invert Y", "InvertCurveTextureY" );
832 menu_separator( menu );
834 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Overlay" );
835 if ( g_Layout_enableDetachableMenus.m_value ) {
836 menu_tearoff( menu_in_menu );
838 create_menu_item_with_mnemonic( menu_in_menu, "Set", "MakeOverlayPatch" );
839 create_menu_item_with_mnemonic( menu_in_menu, "Clear", "ClearPatchOverlays" );
841 menu_separator( menu );
842 create_menu_item_with_mnemonic( menu, "Deform...", "PatchDeform" );
846 #include <gtk/gtkbox.h>
847 #include <gtk/gtktable.h>
848 #include <gtk/gtktogglebutton.h>
849 #include <gtk/gtkradiobutton.h>
850 #include <gtk/gtkcombobox.h>
851 #include <gtk/gtklabel.h>
852 #include "gtkutil/dialog.h"
853 #include "gtkutil/widget.h"
855 void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, int defcols, int maxrows, int maxcols ){
860 GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch density", G_CALLBACK( dialog_delete_callback ), &dialog );
862 GtkAccelGroup* accel = gtk_accel_group_new();
863 gtk_window_add_accel_group( window, accel );
866 GtkHBox* hbox = create_dialog_hbox( 4, 4 );
867 gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
869 GtkTable* table = create_dialog_table( 2, 2, 4, 4 );
870 gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
872 GtkLabel* label = GTK_LABEL( gtk_label_new( "Width:" ) );
873 gtk_widget_show( GTK_WIDGET( label ) );
874 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
875 (GtkAttachOptions) ( GTK_FILL ),
876 (GtkAttachOptions) ( 0 ), 0, 0 );
877 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
880 GtkLabel* label = GTK_LABEL( gtk_label_new( "Height:" ) );
881 gtk_widget_show( GTK_WIDGET( label ) );
882 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
883 (GtkAttachOptions) ( GTK_FILL ),
884 (GtkAttachOptions) ( 0 ), 0, 0 );
885 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
889 GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() );
890 #define D_ITEM( x ) if ( x >= mincols && ( !maxcols || x <= maxcols ) ) gtk_combo_box_append_text( combo, # x )
905 D_ITEM( 31 ); // MAX_PATCH_SIZE is 32, so we should be able to do 31...
907 gtk_widget_show( GTK_WIDGET( combo ) );
908 gtk_table_attach( table, GTK_WIDGET( combo ), 1, 2, 0, 1,
909 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
910 (GtkAttachOptions) ( 0 ), 0, 0 );
915 GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() );
916 #define D_ITEM( x ) if ( x >= minrows && ( !maxrows || x <= maxrows ) ) gtk_combo_box_append_text( combo, # x )
931 D_ITEM( 31 ); // MAX_PATCH_SIZE is 32, so we should be able to do 31...
933 gtk_widget_show( GTK_WIDGET( combo ) );
934 gtk_table_attach( table, GTK_WIDGET( combo ), 1, 2, 1, 2,
935 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
936 (GtkAttachOptions) ( 0 ), 0, 0 );
943 GtkVBox* vbox = create_dialog_vbox( 4 );
944 gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
946 GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
947 gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
948 widget_make_default( GTK_WIDGET( button ) );
949 gtk_widget_grab_focus( GTK_WIDGET( button ) );
950 gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
953 GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
954 gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
955 gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
961 gtk_combo_box_set_active( width, ( defcols - mincols ) / 2 );
962 gtk_combo_box_set_active( height, ( defrows - minrows ) / 2 );
964 if ( modal_dialog_show( window, dialog ) == eIDOK ) {
965 int w = gtk_combo_box_get_active( width ) * 2 + mincols;
966 int h = gtk_combo_box_get_active( height ) * 2 + minrows;
968 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), prefab, GlobalXYWnd_getCurrentViewType(), w, h );
971 gtk_widget_destroy( GTK_WIDGET( window ) );
975 void DoPatchDeformDlg(){
979 GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch deform", G_CALLBACK( dialog_delete_callback ), &dialog );
981 GtkAccelGroup* accel = gtk_accel_group_new();
982 gtk_window_add_accel_group( window, accel );
985 GtkHBox* hbox = create_dialog_hbox( 4, 4 );
986 gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
988 GtkTable* table = create_dialog_table( 2, 2, 4, 4 );
989 gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
991 GtkLabel* label = GTK_LABEL( gtk_label_new( "Max deform:" ) );
992 gtk_widget_show( GTK_WIDGET( label ) );
993 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
994 (GtkAttachOptions) ( GTK_FILL ),
995 (GtkAttachOptions) ( 0 ), 0, 0 );
996 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
999 GtkWidget* entry = gtk_entry_new();
1000 gtk_entry_set_text( GTK_ENTRY( entry ), "16" );
1001 gtk_widget_show( entry );
1002 gtk_table_attach( table, entry, 1, 2, 0, 1,
1003 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1004 (GtkAttachOptions) ( 0 ), 0, 0 );
1010 GtkVBox* vbox = create_dialog_vbox( 4 );
1011 gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
1013 GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
1014 gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
1015 widget_make_default( GTK_WIDGET( button ) );
1016 gtk_widget_grab_focus( GTK_WIDGET( button ) );
1017 gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
1020 GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
1021 gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
1022 gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
1027 if ( modal_dialog_show( window, dialog ) == eIDOK ) {
1028 int deform = static_cast<int>( atoi( gtk_entry_get_text( GTK_ENTRY( deformW ) ) ) );
1029 Scene_PatchDeform( GlobalSceneGraph(), deform );
1032 gtk_widget_destroy( GTK_WIDGET( window ) );
1037 EMessageBoxReturn DoCapDlg( ECapDialog* type ){
1039 ModalDialogButton ok_button( dialog, eIDOK );
1040 ModalDialogButton cancel_button( dialog, eIDCANCEL );
1045 GtkWidget* cylinder;
1047 GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Cap", dialog );
1049 GtkAccelGroup *accel_group = gtk_accel_group_new();
1050 gtk_window_add_accel_group( window, accel_group );
1053 GtkHBox* hbox = create_dialog_hbox( 4, 4 );
1054 gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
1057 // Gef: Added a vbox to contain the toggle buttons
1058 GtkVBox* radio_vbox = create_dialog_vbox( 4 );
1059 gtk_container_add( GTK_CONTAINER( hbox ), GTK_WIDGET( radio_vbox ) );
1062 GtkTable* table = GTK_TABLE( gtk_table_new( 5, 2, FALSE ) );
1063 gtk_widget_show( GTK_WIDGET( table ) );
1064 gtk_box_pack_start( GTK_BOX( radio_vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
1065 gtk_table_set_row_spacings( table, 5 );
1066 gtk_table_set_col_spacings( table, 5 );
1069 GtkImage* image = new_local_image( "cap_bevel.bmp" );
1070 gtk_widget_show( GTK_WIDGET( image ) );
1071 gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 0, 1,
1072 (GtkAttachOptions) ( GTK_FILL ),
1073 (GtkAttachOptions) ( 0 ), 0, 0 );
1076 GtkImage* image = new_local_image( "cap_endcap.bmp" );
1077 gtk_widget_show( GTK_WIDGET( image ) );
1078 gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 1, 2,
1079 (GtkAttachOptions) ( GTK_FILL ),
1080 (GtkAttachOptions) ( 0 ), 0, 0 );
1083 GtkImage* image = new_local_image( "cap_ibevel.bmp" );
1084 gtk_widget_show( GTK_WIDGET( image ) );
1085 gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 2, 3,
1086 (GtkAttachOptions) ( GTK_FILL ),
1087 (GtkAttachOptions) ( 0 ), 0, 0 );
1090 GtkImage* image = new_local_image( "cap_iendcap.bmp" );
1091 gtk_widget_show( GTK_WIDGET( image ) );
1092 gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 3, 4,
1093 (GtkAttachOptions) ( GTK_FILL ),
1094 (GtkAttachOptions) ( 0 ), 0, 0 );
1097 GtkImage* image = new_local_image( "cap_cylinder.bmp" );
1098 gtk_widget_show( GTK_WIDGET( image ) );
1099 gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 4, 5,
1100 (GtkAttachOptions) ( GTK_FILL ),
1101 (GtkAttachOptions) ( 0 ), 0, 0 );
1106 GtkWidget* button = gtk_radio_button_new_with_label( group, "Bevel" );
1107 gtk_widget_show( button );
1108 gtk_table_attach( table, button, 1, 2, 0, 1,
1109 (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
1110 (GtkAttachOptions) ( 0 ), 0, 0 );
1111 group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
1116 GtkWidget* button = gtk_radio_button_new_with_label( group, "Endcap" );
1117 gtk_widget_show( button );
1118 gtk_table_attach( table, button, 1, 2, 1, 2,
1119 (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
1120 (GtkAttachOptions) ( 0 ), 0, 0 );
1121 group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
1126 GtkWidget* button = gtk_radio_button_new_with_label( group, "Inverted Bevel" );
1127 gtk_widget_show( button );
1128 gtk_table_attach( table, button, 1, 2, 2, 3,
1129 (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
1130 (GtkAttachOptions) ( 0 ), 0, 0 );
1131 group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
1136 GtkWidget* button = gtk_radio_button_new_with_label( group, "Inverted Endcap" );
1137 gtk_widget_show( button );
1138 gtk_table_attach( table, button, 1, 2, 3, 4,
1139 (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
1140 (GtkAttachOptions) ( 0 ), 0, 0 );
1141 group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
1146 GtkWidget* button = gtk_radio_button_new_with_label( group, "Cylinder" );
1147 gtk_widget_show( button );
1148 gtk_table_attach( table, button, 1, 2, 4, 5,
1149 (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
1150 (GtkAttachOptions) ( 0 ), 0, 0 );
1151 group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
1159 GtkVBox* vbox = create_dialog_vbox( 4 );
1160 gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 );
1162 GtkButton* button = create_modal_dialog_button( "OK", ok_button );
1163 gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
1164 widget_make_default( GTK_WIDGET( button ) );
1165 gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
1168 GtkButton* button = create_modal_dialog_button( "Cancel", cancel_button );
1169 gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
1170 gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
1175 // Initialize dialog
1176 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( bevel ), TRUE );
1178 EMessageBoxReturn ret = modal_dialog_show( window, dialog );
1179 if ( ret == eIDOK ) {
1180 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( bevel ) ) ) {
1181 *type = PATCHCAP_BEVEL;
1183 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( endcap ) ) ) {
1184 *type = PATCHCAP_ENDCAP;
1186 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( ibevel ) ) ) {
1187 *type = PATCHCAP_INVERTED_BEVEL;
1189 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( iendcap ) ) ) {
1190 *type = PATCHCAP_INVERTED_ENDCAP;
1192 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( cylinder ) ) ) {
1193 *type = PATCHCAP_CYLINDER;
1197 gtk_widget_destroy( GTK_WIDGET( window ) );