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"
25 #include <gdk/gdkkeysyms.h>
27 #include "debugging/debugging.h"
30 #include "iselection.h"
33 #include "math/vector.h"
34 #include "math/aabb.h"
35 #include "generic/callback.h"
37 #include "gtkutil/menu.h"
38 #include "gtkutil/image.h"
40 #include "mainframe.h"
44 #include "texwindow.h"
50 PatchCreator* g_patchCreator = 0;
52 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 ){
54 GlobalSelectionSystem().setSelectedAll( false );
56 NodeSmartReference node( g_patchCreator->createPatch() );
57 Node_getTraversable( Map_FindOrInsertWorldspawn( g_map ) )->insert( node );
59 Patch* patch = Node_getPatch( node );
60 patch->SetShader( shader );
62 patch->ConstructPrefab( aabb, eType, axis, width, height );
63 patch->controlPointsChanged();
66 scene::Path patchpath( makeReference( GlobalSceneGraph().root() ) );
67 patchpath.push( makeReference( *Map_GetWorldspawn( g_map ) ) );
68 patchpath.push( makeReference( node.get() ) );
69 Instance_getSelectable( *graph.find( patchpath ) )->setSelected( true );
73 void PatchAutoCapTexture( Patch& patch ) {
75 AABB box = patch.localAABB();
76 float x = box.extents.x();
77 float y = box.extents.y();
78 float z = box.extents.z();
80 int cap_direction = -1;
83 else if ( y < x && y < z )
85 else if ( z < x && z < x )
88 if ( cap_direction >= 0 )
89 patch.ProjectTexture(cap_direction);
91 patch.NaturalTexture();
94 void Patch_AutoCapTexture(){
95 UndoableCommand command( "patchAutoCapTexture" );
96 Scene_forEachVisibleSelectedPatch( &PatchAutoCapTexture );
100 void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, const char* shader ){
101 if ( ( type == eCapEndCap || type == eCapIEndCap )
102 && patch.getWidth() != 5 ) {
103 globalErrorStream() << "cannot create end-cap - patch width != 5\n";
106 if ( ( type == eCapBevel || type == eCapIBevel )
107 && patch.getWidth() != 3 && patch.getWidth() != 5 ) {
108 globalErrorStream() << "cannot create bevel-cap - patch width != 3\n";
111 if ( type == eCapCylinder
112 && patch.getWidth() != 9 ) {
113 globalErrorStream() << "cannot create cylinder-cap - patch width != 9\n";
118 NodeSmartReference cap( g_patchCreator->createPatch() );
119 Node_getTraversable( instance.path().parent() )->insert( cap );
121 Patch* cap_patch = Node_getPatch( cap );
122 patch.MakeCap( cap_patch, type, ROW, true );
123 cap_patch->SetShader( shader );
124 PatchAutoCapTexture(*cap_patch);
126 scene::Path path( instance.path() );
128 path.push( makeReference( cap.get() ) );
129 selectPath( path, true );
133 NodeSmartReference cap( g_patchCreator->createPatch() );
134 Node_getTraversable( instance.path().parent() )->insert( cap );
136 Patch* cap_patch = Node_getPatch( cap );
137 patch.MakeCap( cap_patch, type, ROW, false );
138 cap_patch->SetShader( shader );
139 PatchAutoCapTexture(*cap_patch);
141 scene::Path path( instance.path() );
143 path.push( makeReference( cap.get() ) );
144 selectPath( path, true );
149 typedef std::vector<scene::Instance*> InstanceVector;
154 PATCHCAP_INVERTED_BEVEL,
155 PATCHCAP_INVERTED_ENDCAP,
159 EMessageBoxReturn DoCapDlg( ECapDialog *type );
161 void Scene_PatchDoCap_Selected( scene::Graph& graph, const char* shader ){
164 if ( DoCapDlg( &nType ) == eIDOK ) {
168 case PATCHCAP_INVERTED_BEVEL:
174 case PATCHCAP_INVERTED_ENDCAP:
177 case PATCHCAP_ENDCAP:
180 case PATCHCAP_CYLINDER:
181 eType = eCapCylinder;
184 ERROR_MESSAGE( "invalid patch cap type" );
188 InstanceVector instances;
189 Scene_forEachVisibleSelectedPatchInstance([&](PatchInstance &patch) {
190 instances.push_back(&patch);
192 for ( InstanceVector::const_iterator i = instances.begin(); i != instances.end(); ++i )
194 Patch_makeCaps( *Node_getPatch( ( *i )->path().top() ), *( *i ), eType, shader );
199 void Patch_deform( Patch& patch, scene::Instance& instance, const int deform ){
202 for (PatchControlIter i = patch.begin(); i != patch.end(); ++i)
204 PatchControl& control = *i;
205 int randomNumber = int( deform * (float(std::rand()) / float(RAND_MAX)));
206 control.m_vertex[2] += randomNumber;
209 patch.controlPointsChanged();
212 void Scene_PatchDeform( scene::Graph& graph, const int deform )
214 InstanceVector instances;
215 Scene_forEachVisibleSelectedPatchInstance([&](PatchInstance &patch) {
216 instances.push_back(&patch);
218 for ( InstanceVector::const_iterator i = instances.begin(); i != instances.end(); ++i )
220 Patch_deform( *Node_getPatch( ( *i )->path().top() ), *( *i ), deform );
225 void Patch_thicken( Patch& patch, scene::Instance& instance, const float thickness, bool seams, const int axis ){
227 // Create a new patch node
228 NodeSmartReference node(g_patchCreator->createPatch());
229 // Insert the node into worldspawn
230 Node_getTraversable(Map_FindOrInsertWorldspawn(g_map))->insert(node);
232 // Retrieve the contained patch from the node
233 Patch* targetPatch = Node_getPatch(node);
235 // Create the opposite patch with the given thickness = distance
238 targetPatch->createThickenedOpposite(patch, thickness, axis, no12, no34);
240 // Now select the newly created patches
242 scene::Path patchpath(makeReference(GlobalSceneGraph().root()));
243 patchpath.push(makeReference(*Map_GetWorldspawn(g_map)));
244 patchpath.push(makeReference(node.get()));
245 Instance_getSelectable(*GlobalSceneGraph().find(patchpath))->setSelected(true);
248 if (seams && thickness != 0.0f) {
257 // Now create the four walls
258 for ( ; i < iend; i++ ) {
259 // Allocate new patch
260 NodeSmartReference node = NodeSmartReference(g_patchCreator->createPatch());
261 // Insert each node into worldspawn
262 Node_getTraversable(Map_FindOrInsertWorldspawn(g_map))->insert(node);
264 // Retrieve the contained patch from the node
265 Patch* wallPatch = Node_getPatch(node);
267 // Create the wall patch by passing i as wallIndex
268 wallPatch->createThickenedWall( patch, *targetPatch, i);
270 if( ( wallPatch->localAABB().extents[0] <= 0.00005 && wallPatch->localAABB().extents[1] <= 0.00005 ) ||
271 ( wallPatch->localAABB().extents[1] <= 0.00005 && wallPatch->localAABB().extents[2] <= 0.00005 ) ||
272 ( wallPatch->localAABB().extents[0] <= 0.00005 && wallPatch->localAABB().extents[2] <= 0.00005 ) ){
273 //globalOutputStream() << "Thicken: Discarding degenerate patch.\n";
274 Node_getTraversable( Map_FindOrInsertWorldspawn(g_map) )->erase( node );
277 // Now select the newly created patches
279 scene::Path patchpath(makeReference(GlobalSceneGraph().root()));
280 patchpath.push(makeReference(*Map_GetWorldspawn(g_map)));
281 patchpath.push(makeReference(node.get()));
282 Instance_getSelectable(*GlobalSceneGraph().find(patchpath))->setSelected(true);
287 // Invert the target patch so that it faces the opposite direction
288 targetPatch->InvertMatrix();
291 void Scene_PatchThicken( scene::Graph& graph, const int thickness, bool seams, const int axis )
293 InstanceVector instances;
294 Scene_forEachVisibleSelectedPatchInstance([&](PatchInstance &patch) {
295 instances.push_back(&patch);
297 for ( InstanceVector::const_iterator i = instances.begin(); i != instances.end(); ++i )
299 Patch_thicken( *Node_getPatch( ( *i )->path().top() ), *( *i ), thickness, seams, axis );
304 Patch* Scene_GetUltimateSelectedVisiblePatch(){
305 if ( GlobalSelectionSystem().countSelected() != 0 ) {
306 scene::Node& node = GlobalSelectionSystem().ultimateSelected().path().top();
307 if ( node.visible() ) {
308 return Node_getPatch( node );
315 void Scene_PatchCapTexture_Selected( scene::Graph& graph ){
316 Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
317 patch.ProjectTexture(Patch::m_CycleCapIndex);
319 Patch::m_CycleCapIndex = ( Patch::m_CycleCapIndex == 0 ) ? 1 : ( Patch::m_CycleCapIndex == 1 ) ? 2 : 0;
323 void Scene_PatchFlipTexture_Selected( scene::Graph& graph, int axis ){
324 Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
325 patch.FlipTexture(axis);
329 void Scene_PatchNaturalTexture_Selected( scene::Graph& graph ){
330 Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
331 patch.NaturalTexture();
337 void Scene_PatchInsertRemove_Selected( scene::Graph& graph, bool bInsert, bool bColumn, bool bFirst ){
338 Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
339 patch.InsertRemove(bInsert, bColumn, bFirst);
343 void Scene_PatchInvert_Selected( scene::Graph& graph ){
344 Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
345 patch.InvertMatrix();
349 void Scene_PatchRedisperse_Selected( scene::Graph& graph, EMatrixMajor major ){
350 Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
351 patch.Redisperse(major);
355 void Scene_PatchSmooth_Selected( scene::Graph& graph, EMatrixMajor major ){
356 Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
361 void Scene_PatchTranspose_Selected( scene::Graph& graph ){
362 Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
363 patch.TransposeMatrix();
367 void Scene_PatchSetShader_Selected( scene::Graph& graph, const char* name ){
368 Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
369 patch.SetShader(name);
374 void Scene_PatchGetShader_Selected( scene::Graph& graph, CopiedString& name ){
375 Patch* patch = Scene_GetUltimateSelectedVisiblePatch();
377 name = patch->GetShader();
381 void Scene_PatchSelectByShader( scene::Graph& graph, const char* name ){
382 Scene_forEachVisiblePatchInstance([&](PatchInstance &patch) {
383 if (shader_equal(patch.getPatch().GetShader(), name)) {
384 patch.setSelected(true);
390 void Scene_PatchFindReplaceShader( scene::Graph& graph, const char* find, const char* replace ){
391 Scene_forEachVisiblePatch([&](Patch &patch) {
392 if (shader_equal(patch.GetShader(), find)) {
393 patch.SetShader(replace);
398 void Scene_PatchFindReplaceShader_Selected( scene::Graph& graph, const char* find, const char* replace ){
399 Scene_forEachVisibleSelectedPatch([&](Patch &patch) {
400 if (shader_equal(patch.GetShader(), find)) {
401 patch.SetShader(replace);
407 AABB PatchCreator_getBounds(){
408 AABB aabb( aabb_for_minmax( Select_getWorkZone().d_work_min, Select_getWorkZone().d_work_max ) );
410 float gridSize = GetGridSize();
412 if ( aabb.extents[0] == 0 ) {
413 aabb.extents[0] = gridSize;
415 if ( aabb.extents[1] == 0 ) {
416 aabb.extents[1] = gridSize;
418 if ( aabb.extents[2] == 0 ) {
419 aabb.extents[2] = gridSize;
422 if ( aabb_valid( aabb ) ) {
425 return AABB( Vector3( 0, 0, 0 ), Vector3( 64, 64, 64 ) );
428 void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, int defcols, int maxrows, int maxcols );
430 void Patch_XactCylinder(){
431 UndoableCommand undo( "patchCreateXactCylinder" );
433 DoNewPatchDlg( eXactCylinder, 3, 7, 3, 13, 0, 0 );
436 void Patch_XactSphere(){
437 UndoableCommand undo( "patchCreateXactSphere" );
439 DoNewPatchDlg( eXactSphere, 5, 7, 7, 13, 0, 0 );
442 void Patch_XactCone(){
443 UndoableCommand undo( "patchCreateXactCone" );
445 DoNewPatchDlg( eXactCone, 3, 7, 3, 13, 0, 0 );
448 void Patch_Cylinder(){
449 UndoableCommand undo( "patchCreateCylinder" );
451 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eCylinder, GlobalXYWnd_getCurrentViewType() );
454 void Patch_DenseCylinder(){
455 UndoableCommand undo( "patchCreateDenseCylinder" );
457 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eDenseCylinder, GlobalXYWnd_getCurrentViewType() );
460 void Patch_VeryDenseCylinder(){
461 UndoableCommand undo( "patchCreateVeryDenseCylinder" );
463 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eVeryDenseCylinder, GlobalXYWnd_getCurrentViewType() );
466 void Patch_SquareCylinder(){
467 UndoableCommand undo( "patchCreateSquareCylinder" );
469 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eSqCylinder, GlobalXYWnd_getCurrentViewType() );
473 UndoableCommand undo( "patchCreateCaps" );
475 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eEndCap, GlobalXYWnd_getCurrentViewType() );
479 UndoableCommand undo( "patchCreateBevel" );
481 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eBevel, GlobalXYWnd_getCurrentViewType() );
485 UndoableCommand undo( "patchCreateSphere" );
487 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eSphere, GlobalXYWnd_getCurrentViewType() );
490 void Patch_SquareBevel(){
493 void Patch_SquareEndcap(){
497 UndoableCommand undo( "patchCreateCone" );
499 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), eCone, GlobalXYWnd_getCurrentViewType() );
503 UndoableCommand undo( "patchCreatePlane" );
505 DoNewPatchDlg( ePlane, 3, 3, 3, 3, 0, 0 );
508 void Patch_InsertInsertColumn(){
509 UndoableCommand undo( "patchInsertColumns" );
511 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, true, false );
514 void Patch_InsertAddColumn(){
515 UndoableCommand undo( "patchAddColumns" );
517 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, true, true );
520 void Patch_InsertInsertRow(){
521 UndoableCommand undo( "patchInsertRows" );
523 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, false, false );
526 void Patch_InsertAddRow(){
527 UndoableCommand undo( "patchAddRows" );
529 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), true, false, true );
532 void Patch_DeleteFirstColumn(){
533 UndoableCommand undo( "patchDeleteFirstColumns" );
535 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), false, true, true );
538 void Patch_DeleteLastColumn(){
539 UndoableCommand undo( "patchDeleteLastColumns" );
541 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), false, true, false );
544 void Patch_DeleteFirstRow(){
545 UndoableCommand undo( "patchDeleteFirstRows" );
547 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), false, false, true );
550 void Patch_DeleteLastRow(){
551 UndoableCommand undo( "patchDeleteLastRows" );
553 Scene_PatchInsertRemove_Selected( GlobalSceneGraph(), false, false, false );
557 UndoableCommand undo( "patchInvert" );
559 Scene_PatchInvert_Selected( GlobalSceneGraph() );
562 void Patch_RedisperseRows(){
563 UndoableCommand undo( "patchRedisperseRows" );
565 Scene_PatchRedisperse_Selected( GlobalSceneGraph(), ROW );
568 void Patch_RedisperseCols(){
569 UndoableCommand undo( "patchRedisperseColumns" );
571 Scene_PatchRedisperse_Selected( GlobalSceneGraph(), COL );
574 void Patch_SmoothRows(){
575 UndoableCommand undo( "patchSmoothRows" );
577 Scene_PatchSmooth_Selected( GlobalSceneGraph(), ROW );
580 void Patch_SmoothCols(){
581 UndoableCommand undo( "patchSmoothColumns" );
583 Scene_PatchSmooth_Selected( GlobalSceneGraph(), COL );
586 void Patch_Transpose(){
587 UndoableCommand undo( "patchTranspose" );
589 Scene_PatchTranspose_Selected( GlobalSceneGraph() );
593 // FIXME: add support for patch cap creation
594 // Patch_CapCurrent();
595 UndoableCommand undo( "patchCreateCaps" );
597 Scene_PatchDoCap_Selected( GlobalSceneGraph(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) );
600 void Patch_CycleProjection(){
601 UndoableCommand undo( "patchCycleUVProjectionAxis" );
603 Scene_PatchCapTexture_Selected( GlobalSceneGraph() );
607 void Patch_OverlayOn(){
611 void Patch_OverlayOff(){
614 void Patch_FlipTextureX(){
615 UndoableCommand undo( "patchFlipTextureU" );
617 Scene_PatchFlipTexture_Selected( GlobalSceneGraph(), 0 );
620 void Patch_FlipTextureY(){
621 UndoableCommand undo( "patchFlipTextureV" );
623 Scene_PatchFlipTexture_Selected( GlobalSceneGraph(), 1 );
626 void Patch_NaturalTexture(){
627 UndoableCommand undo( "patchNaturalTexture" );
629 Scene_PatchNaturalTexture_Selected( GlobalSceneGraph() );
632 void Patch_CapTexture(){
633 UndoableCommand command( "patchCapTexture" );
635 Scene_PatchCapTexture_Selected( GlobalSceneGraph() );
638 void Patch_ResetTexture(){
640 if ( DoTextureLayout( &fx, &fy ) == eIDOK ) {
641 UndoableCommand command( "patchTileTexture" );
642 Scene_PatchTileTexture_Selected( GlobalSceneGraph(), fx, fy );
646 void Patch_FitTexture(){
647 UndoableCommand command( "patchFitTexture" );
649 Scene_PatchTileTexture_Selected( GlobalSceneGraph(), 1, 1 );
652 void DoPatchDeformDlg();
655 UndoableCommand undo( "patchDeform" );
660 void DoPatchThickenDlg();
662 void Patch_Thicken(){
663 UndoableCommand undo( "patchThicken" );
672 class filter_patch_all : public PatchFilter
675 bool filter( const Patch& patch ) const {
680 class filter_patch_shader : public PatchFilter
682 const char* m_shader;
684 filter_patch_shader( const char* shader ) : m_shader( shader ){
686 bool filter( const Patch& patch ) const {
687 return shader_equal( patch.GetShader(), m_shader );
691 class filter_patch_flags : public PatchFilter
695 filter_patch_flags( int flags ) : m_flags( flags ){
697 bool filter( const Patch& patch ) const {
698 return ( patch.getShaderFlags() & m_flags ) != 0;
703 filter_patch_all g_filter_patch_all;
704 filter_patch_shader g_filter_patch_clip( "textures/common/clip" );
705 filter_patch_shader g_filter_patch_weapclip( "textures/common/weapclip" );
706 filter_patch_flags g_filter_patch_translucent( QER_TRANS );
708 void PatchFilters_construct(){
709 add_patch_filter( g_filter_patch_all, EXCLUDE_CURVES );
710 add_patch_filter( g_filter_patch_clip, EXCLUDE_CLIP );
711 add_patch_filter( g_filter_patch_weapclip, EXCLUDE_CLIP );
712 add_patch_filter( g_filter_patch_translucent, EXCLUDE_TRANSLUCENT );
716 #include "preferences.h"
718 void Patch_constructPreferences( PreferencesPage& page ){
719 page.appendEntry( "Patch Subdivide Threshold", g_PatchSubdivideThreshold );
721 void Patch_constructPage( PreferenceGroup& group ){
722 PreferencesPage page( group.createPage( "Patches", "Patch Display Preferences" ) );
723 Patch_constructPreferences( page );
725 void Patch_registerPreferencesPage(){
726 PreferencesDialog_addDisplayPage( makeCallbackF(Patch_constructPage) );
730 #include "preferencesystem.h"
732 void PatchPreferences_construct(){
733 GlobalPreferenceSystem().registerPreference( "Subdivisions", make_property_string( g_PatchSubdivideThreshold ) );
737 #include "generic/callback.h"
739 void Patch_registerCommands(){
740 GlobalCommands_insert( "InvertCurveTextureX", makeCallbackF(Patch_FlipTextureX), Accelerator( 'I', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
741 GlobalCommands_insert( "InvertCurveTextureY", makeCallbackF(Patch_FlipTextureY), Accelerator( 'I', (GdkModifierType)GDK_SHIFT_MASK ) );
742 GlobalCommands_insert( "IncPatchColumn", makeCallbackF(Patch_InsertInsertColumn), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
743 GlobalCommands_insert( "IncPatchRow", makeCallbackF(Patch_InsertInsertRow), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
744 GlobalCommands_insert( "DecPatchColumn", makeCallbackF(Patch_DeleteLastColumn), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
745 GlobalCommands_insert( "DecPatchRow", makeCallbackF(Patch_DeleteLastRow), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) );
746 GlobalCommands_insert( "NaturalizePatch", makeCallbackF(Patch_NaturalTexture), Accelerator( 'N', (GdkModifierType)GDK_CONTROL_MASK ) );
747 GlobalCommands_insert( "PatchCylinder", makeCallbackF(Patch_Cylinder) );
748 GlobalCommands_insert( "PatchDenseCylinder", makeCallbackF(Patch_DenseCylinder) );
749 GlobalCommands_insert( "PatchVeryDenseCylinder", makeCallbackF(Patch_VeryDenseCylinder) );
750 GlobalCommands_insert( "PatchSquareCylinder", makeCallbackF(Patch_SquareCylinder) );
751 GlobalCommands_insert( "PatchXactCylinder", makeCallbackF(Patch_XactCylinder) );
752 GlobalCommands_insert( "PatchXactSphere", makeCallbackF(Patch_XactSphere) );
753 GlobalCommands_insert( "PatchXactCone", makeCallbackF(Patch_XactCone) );
754 GlobalCommands_insert( "PatchEndCap", makeCallbackF(Patch_Endcap) );
755 GlobalCommands_insert( "PatchBevel", makeCallbackF(Patch_Bevel) );
756 GlobalCommands_insert( "PatchSquareBevel", makeCallbackF(Patch_SquareBevel) );
757 GlobalCommands_insert( "PatchSquareEndcap", makeCallbackF(Patch_SquareEndcap) );
758 GlobalCommands_insert( "PatchCone", makeCallbackF(Patch_Cone) );
759 GlobalCommands_insert( "PatchSphere", makeCallbackF(Patch_Sphere) );
760 GlobalCommands_insert( "SimplePatchMesh", makeCallbackF(Patch_Plane), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) );
761 GlobalCommands_insert( "PatchInsertInsertColumn", makeCallbackF(Patch_InsertInsertColumn), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
762 GlobalCommands_insert( "PatchInsertAddColumn", makeCallbackF(Patch_InsertAddColumn) );
763 GlobalCommands_insert( "PatchInsertInsertRow", makeCallbackF(Patch_InsertInsertRow), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
764 GlobalCommands_insert( "PatchInsertAddRow", makeCallbackF(Patch_InsertAddRow) );
765 GlobalCommands_insert( "PatchDeleteFirstColumn", makeCallbackF(Patch_DeleteFirstColumn) );
766 GlobalCommands_insert( "PatchDeleteLastColumn", makeCallbackF(Patch_DeleteLastColumn), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
767 GlobalCommands_insert( "PatchDeleteFirstRow", makeCallbackF(Patch_DeleteFirstRow), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) );
768 GlobalCommands_insert( "PatchDeleteLastRow", makeCallbackF(Patch_DeleteLastRow) );
769 GlobalCommands_insert( "InvertCurve", makeCallbackF(Patch_Invert), Accelerator( 'I', (GdkModifierType)GDK_CONTROL_MASK ) );
770 GlobalCommands_insert( "RedisperseRows", makeCallbackF(Patch_RedisperseRows), Accelerator( 'E', (GdkModifierType)GDK_CONTROL_MASK ) );
771 GlobalCommands_insert( "RedisperseCols", makeCallbackF(Patch_RedisperseCols), Accelerator( 'E', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
772 GlobalCommands_insert( "SmoothRows", makeCallbackF(Patch_SmoothRows), Accelerator( 'W', (GdkModifierType)GDK_CONTROL_MASK ) );
773 GlobalCommands_insert( "SmoothCols", makeCallbackF(Patch_SmoothCols), Accelerator( 'W', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
774 GlobalCommands_insert( "MatrixTranspose", makeCallbackF(Patch_Transpose), Accelerator( 'M', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
775 GlobalCommands_insert( "CapCurrentCurve", makeCallbackF(Patch_Cap), Accelerator( 'C', (GdkModifierType)GDK_SHIFT_MASK ) );
776 GlobalCommands_insert( "CycleCapTexturePatch", makeCallbackF(Patch_CycleProjection), Accelerator( 'N', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
777 GlobalCommands_insert( "MakeOverlayPatch", makeCallbackF(Patch_OverlayOn), Accelerator( 'Y' ) );
778 GlobalCommands_insert( "ClearPatchOverlays", makeCallbackF(Patch_OverlayOff), Accelerator( 'L', (GdkModifierType)GDK_CONTROL_MASK ) );
779 GlobalCommands_insert( "PatchDeform", makeCallbackF(Patch_Deform) );
780 GlobalCommands_insert( "PatchThicken", makeCallbackF(Patch_Thicken) );
783 void Patch_constructToolbar( ui::Toolbar toolbar ){
784 toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "cap_curve.png", "CapCurrentCurve" );
787 void Patch_constructMenu( ui::Menu menu ){
788 create_menu_item_with_mnemonic( menu, "Cylinder", "PatchCylinder" );
790 auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" );
791 if ( g_Layout_enableDetachableMenus.m_value ) {
792 menu_tearoff( menu_in_menu );
794 create_menu_item_with_mnemonic( menu_in_menu, "Dense Cylinder", "PatchDenseCylinder" );
795 create_menu_item_with_mnemonic( menu_in_menu, "Very Dense Cylinder", "PatchVeryDenseCylinder" );
796 create_menu_item_with_mnemonic( menu_in_menu, "Square Cylinder", "PatchSquareCylinder" );
797 create_menu_item_with_mnemonic( menu_in_menu, "Exact Cylinder...", "PatchXactCylinder" );
799 menu_separator( menu );
800 create_menu_item_with_mnemonic( menu, "End cap", "PatchEndCap" );
801 create_menu_item_with_mnemonic( menu, "Bevel", "PatchBevel" );
803 // auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "More End caps, Bevels" );
804 // if ( g_Layout_enableDetachableMenus.m_value ) {
805 // menu_tearoff( menu_in_menu );
807 create_menu_item_with_mnemonic( menu, "Square Endcap", "PatchSquareBevel" );
808 create_menu_item_with_mnemonic( menu, "Square Bevel", "PatchSquareEndcap" );
810 menu_separator( menu );
811 create_menu_item_with_mnemonic( menu, "Cone", "PatchCone" );
812 create_menu_item_with_mnemonic( menu, "Exact Cone...", "PatchXactCone" );
813 menu_separator( menu );
814 create_menu_item_with_mnemonic( menu, "Sphere", "PatchSphere" );
815 create_menu_item_with_mnemonic( menu, "Exact Sphere...", "PatchXactSphere" );
816 menu_separator( menu );
817 create_menu_item_with_mnemonic( menu, "Simple Patch Mesh...", "SimplePatchMesh" );
818 menu_separator( menu );
820 auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert" );
821 if ( g_Layout_enableDetachableMenus.m_value ) {
822 menu_tearoff( menu_in_menu );
824 create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Columns", "PatchInsertAddColumn" );
825 create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Columns", "PatchInsertInsertColumn" );
826 menu_separator( menu_in_menu );
827 create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Rows", "PatchInsertAddRow" );
828 create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Rows", "PatchInsertInsertRow" );
831 auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Delete" );
832 if ( g_Layout_enableDetachableMenus.m_value ) {
833 menu_tearoff( menu_in_menu );
835 create_menu_item_with_mnemonic( menu_in_menu, "First (2) Columns", "PatchDeleteFirstColumn" );
836 create_menu_item_with_mnemonic( menu_in_menu, "Last (2) Columns", "PatchDeleteLastColumn" );
837 menu_separator( menu_in_menu );
838 create_menu_item_with_mnemonic( menu_in_menu, "First (2) Rows", "PatchDeleteFirstRow" );
839 create_menu_item_with_mnemonic( menu_in_menu, "Last (2) Rows", "PatchDeleteLastRow" );
841 menu_separator( menu );
843 auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Matrix" );
844 if ( g_Layout_enableDetachableMenus.m_value ) {
845 menu_tearoff( menu_in_menu );
847 create_menu_item_with_mnemonic( menu_in_menu, "Invert", "InvertCurve" );
848 // auto menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Re-disperse" );
849 // if ( g_Layout_enableDetachableMenus.m_value ) {
850 // menu_tearoff( menu_3 );
852 menu_separator( menu_in_menu );
853 create_menu_item_with_mnemonic( menu, "Rows", "RedisperseRows" );
854 create_menu_item_with_mnemonic( menu, "Columns", "RedisperseCols" );
855 // auto menu_4 = create_sub_menu_with_mnemonic( menu_in_menu, "Smooth" );
856 // if ( g_Layout_enableDetachableMenus.m_value ) {
857 // menu_tearoff( menu_4 );
859 create_menu_item_with_mnemonic( menu, "Rows", "SmoothRows" );
860 create_menu_item_with_mnemonic( menu, "Columns", "SmoothCols" );
861 create_menu_item_with_mnemonic( menu_in_menu, "Transpose", "MatrixTranspose" );
864 menu_separator( menu );
865 create_menu_item_with_mnemonic( menu, "Cap Selection", "CapCurrentCurve" );
866 create_menu_item_with_mnemonic( menu, "Cycle Cap Texture", "CycleCapTexturePatch" );
867 menu_separator( menu );
869 auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Texture" );
870 if ( g_Layout_enableDetachableMenus.m_value ) {
871 menu_tearoff( menu_in_menu );
873 create_menu_item_with_mnemonic( menu_in_menu, "Cycle Projection", "CycleCapTexturePatch" );
874 create_menu_item_with_mnemonic( menu_in_menu, "Naturalize", "NaturalizePatch" );
875 create_menu_item_with_mnemonic( menu_in_menu, "Invert X", "InvertCurveTextureX" );
876 create_menu_item_with_mnemonic( menu_in_menu, "Invert Y", "InvertCurveTextureY" );
879 menu_separator( menu );
881 auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Overlay" );
882 if ( g_Layout_enableDetachableMenus.m_value ) {
883 menu_tearoff( menu_in_menu );
885 create_menu_item_with_mnemonic( menu_in_menu, "Set", "MakeOverlayPatch" );
886 create_menu_item_with_mnemonic( menu_in_menu, "Clear", "ClearPatchOverlays" );
888 menu_separator( menu );
889 create_menu_item_with_mnemonic( menu, "Deform...", "PatchDeform" );
890 create_menu_item_with_mnemonic( menu, "Thicken...", "PatchThicken" );
894 #include "gtkutil/dialog.h"
895 #include "gtkutil/widget.h"
897 void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, int defcols, int maxrows, int maxcols ){
900 ui::Window window = MainFrame_getWindow().create_dialog_window("Patch density", G_CALLBACK(dialog_delete_callback ), &dialog );
902 auto accel = ui::AccelGroup(ui::New);
903 window.add_accel_group( accel );
904 auto width = ui::ComboBoxText(ui::New);
905 auto height = ui::ComboBoxText(ui::New);
907 auto hbox = create_dialog_hbox( 4, 4 );
910 auto table = create_dialog_table( 2, 2, 4, 4 );
911 hbox.pack_start( table, TRUE, TRUE, 0 );
913 auto label = ui::Label( "Width:" );
915 table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
916 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
919 auto label = ui::Label( "Height:" );
921 table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
922 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
927 #define D_ITEM( x ) if ( x >= mincols && ( !maxcols || x <= maxcols ) ) gtk_combo_box_text_append_text( combo, #x )
942 D_ITEM( 31 ); // MAX_PATCH_SIZE is 32, so we should be able to do 31...
945 table.attach(combo, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
949 #define D_ITEM( x ) if ( x >= minrows && ( !maxrows || x <= maxrows ) ) gtk_combo_box_text_append_text( combo, #x )
964 D_ITEM( 31 ); // MAX_PATCH_SIZE is 32, so we should be able to do 31...
967 table.attach(combo, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
972 auto vbox = create_dialog_vbox( 4 );
973 hbox.pack_start( vbox, TRUE, TRUE, 0 );
975 auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
976 vbox.pack_start( button, FALSE, FALSE, 0 );
977 widget_make_default( button );
978 gtk_widget_grab_focus( button );
979 gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
982 auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
983 vbox.pack_start( button, FALSE, FALSE, 0 );
984 gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
990 gtk_combo_box_set_active( width, ( defcols - mincols ) / 2 );
991 gtk_combo_box_set_active( height, ( defrows - minrows ) / 2 );
993 if ( modal_dialog_show( window, dialog ) == eIDOK ) {
994 int w = gtk_combo_box_get_active( width ) * 2 + mincols;
995 int h = gtk_combo_box_get_active( height ) * 2 + minrows;
997 Scene_PatchConstructPrefab( GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), prefab, GlobalXYWnd_getCurrentViewType(), w, h );
1004 void DoPatchDeformDlg(){
1008 ui::Window window = create_dialog_window( MainFrame_getWindow(), "Patch deform", G_CALLBACK( dialog_delete_callback ), &dialog );
1010 GtkAccelGroup* accel = gtk_accel_group_new();
1011 gtk_window_add_accel_group( window, accel );
1014 auto hbox = create_dialog_hbox( 4, 4 );
1015 gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
1017 auto table = create_dialog_table( 2, 2, 4, 4 );
1018 gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
1020 GtkLabel* label = GTK_LABEL( gtk_label_new( "Max deform:" ) );
1021 gtk_widget_show( GTK_WIDGET( label ) );
1022 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
1023 (GtkAttachOptions) ( GTK_FILL ),
1024 (GtkAttachOptions) ( 0 ), 0, 0 );
1025 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
1028 GtkWidget* entry = gtk_entry_new();
1029 gtk_entry_set_text( GTK_ENTRY( entry ), "16" );
1030 gtk_widget_show( entry );
1031 gtk_table_attach( table, entry, 1, 2, 0, 1,
1032 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1033 (GtkAttachOptions) ( 0 ), 0, 0 );
1039 auto vbox = create_dialog_vbox( 4 );
1040 hbox.pack_start( vbox, FALSE, FALSE, 0 );
1042 auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
1043 vbox.pack_start( button, FALSE, FALSE, 0 );
1044 widget_make_default( button );
1045 gtk_widget_grab_focus( button );
1046 gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
1049 auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
1050 vbox.pack_start( button, FALSE, FALSE, 0 );
1051 gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
1056 if ( modal_dialog_show( window, dialog ) == eIDOK ) {
1057 int deform = static_cast<int>( atoi( gtk_entry_get_text( GTK_ENTRY( deformW ) ) ) );
1058 Scene_PatchDeform( GlobalSceneGraph(), deform );
1061 gtk_widget_destroy( GTK_WIDGET( window ) );
1066 EMessageBoxReturn DoCapDlg( ECapDialog* type ){
1068 ModalDialogButton ok_button( dialog, eIDOK );
1069 ModalDialogButton cancel_button( dialog, eIDCANCEL );
1070 ui::Widget bevel{ui::null};
1071 ui::Widget ibevel{ui::null};
1072 ui::Widget endcap{ui::null};
1073 ui::Widget iendcap{ui::null};
1074 ui::Widget cylinder{ui::null};
1076 ui::Window window = MainFrame_getWindow().create_modal_dialog_window( "Cap", dialog );
1078 auto accel_group = ui::AccelGroup(ui::New);
1079 window.add_accel_group( accel_group );
1082 auto hbox = create_dialog_hbox( 4, 4 );
1086 // Gef: Added a vbox to contain the toggle buttons
1087 auto radio_vbox = create_dialog_vbox( 4 );
1088 hbox.add(radio_vbox);
1091 auto table = ui::Table( 5, 2, FALSE );
1093 radio_vbox.pack_start( table, TRUE, TRUE, 0 );
1094 gtk_table_set_row_spacings( table, 5 );
1095 gtk_table_set_col_spacings( table, 5 );
1098 auto image = new_local_image( "cap_bevel.png" );
1100 table.attach(image, {0, 1, 0, 1}, {GTK_FILL, 0});
1103 auto image = new_local_image( "cap_endcap.png" );
1105 table.attach(image, {0, 1, 1, 2}, {GTK_FILL, 0});
1108 auto image = new_local_image( "cap_ibevel.png" );
1110 table.attach(image, {0, 1, 2, 3}, {GTK_FILL, 0});
1113 auto image = new_local_image( "cap_iendcap.png" );
1115 table.attach(image, {0, 1, 3, 4}, {GTK_FILL, 0});
1118 auto image = new_local_image( "cap_cylinder.png" );
1120 table.attach(image, {0, 1, 4, 5}, {GTK_FILL, 0});
1125 ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Bevel" ));
1127 table.attach(button, {1, 2, 0, 1}, {GTK_FILL | GTK_EXPAND, 0});
1128 group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
1133 ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Endcap" ));
1135 table.attach(button, {1, 2, 1, 2}, {GTK_FILL | GTK_EXPAND, 0});
1136 group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
1141 ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Inverted Bevel" ));
1143 table.attach(button, {1, 2, 2, 3}, {GTK_FILL | GTK_EXPAND, 0});
1144 group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
1149 ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Inverted Endcap" ));
1151 table.attach(button, {1, 2, 3, 4}, {GTK_FILL | GTK_EXPAND, 0});
1152 group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
1157 ui::Widget button = ui::Widget::from(gtk_radio_button_new_with_label( group, "Cylinder" ));
1159 table.attach(button, {1, 2, 4, 5}, {GTK_FILL | GTK_EXPAND, 0});
1160 group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
1168 auto vbox = create_dialog_vbox( 4 );
1169 hbox.pack_start( vbox, FALSE, FALSE, 0 );
1171 auto button = create_modal_dialog_button( "OK", ok_button );
1172 vbox.pack_start( button, FALSE, FALSE, 0 );
1173 widget_make_default( button );
1174 gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
1177 auto button = create_modal_dialog_button( "Cancel", cancel_button );
1178 vbox.pack_start( button, FALSE, FALSE, 0 );
1179 gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
1184 // Initialize dialog
1185 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( bevel ), TRUE );
1187 EMessageBoxReturn ret = modal_dialog_show( window, dialog );
1188 if ( ret == eIDOK ) {
1189 if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( bevel ) ) ) {
1190 *type = PATCHCAP_BEVEL;
1192 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( endcap ) ) ) {
1193 *type = PATCHCAP_ENDCAP;
1195 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( ibevel ) ) ) {
1196 *type = PATCHCAP_INVERTED_BEVEL;
1198 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( iendcap ) ) ) {
1199 *type = PATCHCAP_INVERTED_ENDCAP;
1201 else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( cylinder ) ) ) {
1202 *type = PATCHCAP_CYLINDER;
1212 void DoPatchThickenDlg(){
1214 GtkWidget* thicknessW;
1219 GtkWidget* radNormals;
1221 ui::Window window = create_dialog_window( MainFrame_getWindow(), "Patch thicken", G_CALLBACK( dialog_delete_callback ), &dialog );
1223 GtkAccelGroup* accel = gtk_accel_group_new();
1224 gtk_window_add_accel_group( window, accel );
1227 auto hbox = create_dialog_hbox( 4, 4 );
1228 gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
1230 auto table = create_dialog_table( 2, 4, 4, 4 );
1231 gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
1233 GtkLabel* label = GTK_LABEL( gtk_label_new( "Thickness:" ) );
1234 gtk_widget_show( GTK_WIDGET( label ) );
1235 gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
1236 (GtkAttachOptions) ( GTK_FILL ),
1237 (GtkAttachOptions) ( 0 ), 0, 0 );
1238 gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
1241 GtkWidget* entry = gtk_entry_new();
1242 gtk_entry_set_text( GTK_ENTRY( entry ), "16" );
1243 gtk_widget_set_size_request( entry, 40, -1 );
1244 gtk_widget_show( entry );
1245 gtk_table_attach( table, entry, 1, 2, 0, 1,
1246 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1247 (GtkAttachOptions) ( 0 ), 0, 0 );
1252 // Create the "create seams" label
1253 GtkWidget* _seamsCheckBox = gtk_check_button_new_with_label( "Side walls" );
1254 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( _seamsCheckBox ), TRUE );
1255 gtk_widget_show( _seamsCheckBox );
1256 gtk_table_attach( table, _seamsCheckBox, 3, 4, 0, 1,
1257 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1258 (GtkAttachOptions) ( 0 ), 0, 0 );
1259 seamsW = _seamsCheckBox;
1263 // Create the radio button group for choosing the extrude axis
1264 GtkWidget* _radNormals = gtk_radio_button_new_with_label( NULL, "Normal" );
1265 GtkWidget* _radX = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_radNormals), "X" );
1266 GtkWidget* _radY = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_radNormals), "Y" );
1267 GtkWidget* _radZ = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(_radNormals), "Z" );
1268 gtk_widget_show( _radNormals );
1269 gtk_widget_show( _radX );
1270 gtk_widget_show( _radY );
1271 gtk_widget_show( _radZ );
1274 // Pack the buttons into the table
1275 gtk_table_attach( table, _radNormals, 0, 1, 1, 2,
1276 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1277 (GtkAttachOptions) ( 0 ), 0, 0 );
1278 gtk_table_attach( table, _radX, 1, 2, 1, 2,
1279 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1280 (GtkAttachOptions) ( 0 ), 0, 0 );
1281 gtk_table_attach( table, _radY, 2, 3, 1, 2,
1282 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1283 (GtkAttachOptions) ( 0 ), 0, 0 );
1284 gtk_table_attach( table, _radZ, 3, 4, 1, 2,
1285 (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
1286 (GtkAttachOptions) ( 0 ), 0, 0 );
1290 radNormals = _radNormals;
1294 auto vbox = create_dialog_vbox( 4 );
1295 hbox.pack_start( vbox, FALSE, FALSE, 0 );
1297 auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
1298 vbox.pack_start( button, FALSE, FALSE, 0 );
1299 widget_make_default( button );
1300 gtk_widget_grab_focus( button );
1301 gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
1304 auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
1305 vbox.pack_start( button, FALSE, FALSE, 0 );
1306 gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
1311 if ( modal_dialog_show( window, dialog ) == eIDOK ) {
1314 float thickness = static_cast<float>( atoi( gtk_entry_get_text( GTK_ENTRY( thicknessW ) ) ) );
1315 seams = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( seamsW )) ? true : false;
1317 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radX))) {
1320 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radY))) {
1323 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radZ))) {
1327 // Extrude along normals
1330 Scene_PatchThicken( GlobalSceneGraph(), thickness, seams, axis );
1333 gtk_widget_destroy( GTK_WIDGET( window ) );