Skip to content

Commit

Permalink
#401: Patch/Insert options disabled without selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Mott committed Aug 10, 2022
1 parent 032f59e commit 7382095
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
6 changes: 3 additions & 3 deletions install/menu.xml
Expand Up @@ -252,7 +252,7 @@
</subMenu>

<subMenu name="patch" caption="&amp;Patch">
<menuItem name="simplePatch" caption="Create Simple Patch Mesh" command="CreateSimplePatchDialog" />
<menuItem name="simplePatch" caption="Create Simple Patch..." command="CreateSimplePatchDialog" />
<menuSeparator />
<menuItem name="endcap" caption="Create End cap" command="PatchEndCap" />
<menuItem name="bevel" caption="Create Bevel" command="PatchBevel" />
Expand Down Expand Up @@ -307,8 +307,8 @@
</subMenu>

<menuSeparator />
<menuItem name="thickenPatches" caption="Thicken Selected Patches..." command="ThickenPatchDialog" />
<menuItem name="capselection" caption="Cap Selection..." command="PatchCapDialog" icon="curve_cap.png" />
<menuItem name="thickenPatches" caption="Thicken..." command="ThickenPatchDialog" />
<menuItem name="capselection" caption="Cap..." command="PatchCapDialog" icon="curve_cap.png" />
<menuSeparator />
<menuItem name="stitchTextures" caption="Stitch Patch Textures" command="StitchPatchTexture" />
<menuItem name="bulgePatch" caption="Bulge Patch..." command="BulgePatchDialog" />
Expand Down
28 changes: 22 additions & 6 deletions radiantcore/patch/PatchModule.cpp
Expand Up @@ -90,12 +90,27 @@ void PatchModule::registerPatchCommands()
GlobalCommandSystem().addCommand("CreateSimplePatchMesh", patch::algorithm::createSimplePatch,
{ cmd::ARGTYPE_INT, cmd::ARGTYPE_INT | cmd::ARGTYPE_OPTIONAL, cmd::ARGTYPE_INT | cmd::ARGTYPE_OPTIONAL }); // dimX, dimY, removeSelectedBrush

GlobalCommandSystem().addCommand("PatchInsertColumnEnd", selection::algorithm::insertPatchColumnsAtEnd);
GlobalCommandSystem().addCommand("PatchInsertColumnBeginning", selection::algorithm::insertPatchColumnsAtBeginning);
GlobalCommandSystem().addCommand("PatchInsertRowEnd", selection::algorithm::insertPatchRowsAtEnd);
GlobalCommandSystem().addCommand("PatchInsertRowBeginning", selection::algorithm::insertPatchRowsAtBeginning);
GlobalCommandSystem().addWithCheck(
"PatchInsertColumnEnd",
cmd::noArgs(selection::algorithm::insertPatchColumnsAtEnd),
selection::pred::havePatch
);
GlobalCommandSystem().addWithCheck(
"PatchInsertColumnBeginning",
cmd::noArgs(selection::algorithm::insertPatchColumnsAtBeginning),
selection::pred::havePatch);
GlobalCommandSystem().addWithCheck(
"PatchInsertRowEnd",
cmd::noArgs(selection::algorithm::insertPatchRowsAtEnd),
selection::pred::havePatch
);
GlobalCommandSystem().addWithCheck(
"PatchInsertRowBeginning",
cmd::noArgs(selection::algorithm::insertPatchRowsAtBeginning),
selection::pred::havePatch
);

GlobalCommandSystem().addCommand("PatchDeleteColumnBeginning", selection::algorithm::deletePatchColumnsFromBeginning);
GlobalCommandSystem().addCommand("PatchDeleteColumnBeginning", selection::algorithm::deletePatchColumnsFromBeginning);
GlobalCommandSystem().addCommand("PatchDeleteColumnEnd", selection::algorithm::deletePatchColumnsFromEnd);
GlobalCommandSystem().addCommand("PatchDeleteRowBeginning", selection::algorithm::deletePatchRowsFromBeginning);
GlobalCommandSystem().addCommand("PatchDeleteRowEnd", selection::algorithm::deletePatchRowsFromEnd);
Expand All @@ -115,7 +130,8 @@ void PatchModule::registerPatchCommands()
"ThickenSelectedPatches", selection::algorithm::thickenPatches,
{cmd::ARGTYPE_DOUBLE, cmd::ARGTYPE_INT, cmd::ARGTYPE_INT} // thickness, create_seams, axis
);
GlobalCommandSystem().addWithCheck("StitchPatchTexture", patch::algorithm::stitchTextures,
GlobalCommandSystem().addWithCheck("StitchPatchTexture",
cmd::noArgs(patch::algorithm::stitchTextures),
[] { return selection::pred::havePatchesExact(2); });
GlobalCommandSystem().addCommand("BulgePatch", patch::algorithm::bulge, {cmd::ARGTYPE_DOUBLE});
GlobalCommandSystem().addWithCheck("WeldSelectedPatches",
Expand Down
2 changes: 1 addition & 1 deletion radiantcore/patch/algorithm/General.cpp
Expand Up @@ -89,7 +89,7 @@ void thicken(const PatchNodePtr& sourcePatch, float thickness, bool createSeams,
targetPatch->invertMatrix();
}

void stitchTextures(const cmd::ArgumentList& args)
void stitchTextures()
{
// Get all the selected patches
PatchPtrVector patchList = selection::algorithm::getSelectedPatches();
Expand Down
2 changes: 1 addition & 1 deletion radiantcore/patch/algorithm/General.h
Expand Up @@ -23,7 +23,7 @@ namespace algorithm
*/
void thicken(const PatchNodePtr& sourcePatch, float thickness, bool createSeams, int axis);

void stitchTextures(const cmd::ArgumentList& args);
void stitchTextures();

void bulge(const cmd::ArgumentList& args);

Expand Down
8 changes: 4 additions & 4 deletions radiantcore/selection/algorithm/Patch.cpp
Expand Up @@ -93,28 +93,28 @@ void capPatch(const cmd::ArgumentList& args)
}
}

void insertPatchColumnsAtEnd(const cmd::ArgumentList& args)
void insertPatchColumnsAtEnd()
{
UndoableCommand undo("patchInsertColumnsAtEnd");
// true = insert, true = columns, false = end
GlobalSelectionSystem().foreachPatch([&] (IPatch& patch) { patch.insertRemove(true, true, false); });
}

void insertPatchColumnsAtBeginning(const cmd::ArgumentList& args)
void insertPatchColumnsAtBeginning()
{
UndoableCommand undo("patchInsertColumnsAtBeginning");
// true = insert, true = columns, true = at beginning
GlobalSelectionSystem().foreachPatch([&] (IPatch& patch) { patch.insertRemove(true, true, true); });
}

void insertPatchRowsAtEnd(const cmd::ArgumentList& args)
void insertPatchRowsAtEnd()
{
UndoableCommand undo("patchInsertRowsAtEnd");
// true = insert, false = rows, false = at end
GlobalSelectionSystem().foreachPatch([&] (IPatch& patch) { patch.insertRemove(true, false, false); });
}

void insertPatchRowsAtBeginning(const cmd::ArgumentList& args)
void insertPatchRowsAtBeginning()
{
UndoableCommand undo("patchInsertRowsAtBeginning");
// true = insert, false = rows, true = at beginning
Expand Down
8 changes: 4 additions & 4 deletions radiantcore/selection/algorithm/Patch.h
Expand Up @@ -18,10 +18,10 @@ void transposePatch(const cmd::ArgumentList& args);

void capPatch(const cmd::ArgumentList& args);

void insertPatchColumnsAtEnd(const cmd::ArgumentList& args);
void insertPatchColumnsAtBeginning(const cmd::ArgumentList& args);
void insertPatchRowsAtEnd(const cmd::ArgumentList& args);
void insertPatchRowsAtBeginning(const cmd::ArgumentList& args);
void insertPatchColumnsAtEnd();
void insertPatchColumnsAtBeginning();
void insertPatchRowsAtEnd();
void insertPatchRowsAtBeginning();

void deletePatchColumnsFromBeginning(const cmd::ArgumentList& args);
void deletePatchColumnsFromEnd(const cmd::ArgumentList& args);
Expand Down

0 comments on commit 7382095

Please sign in to comment.