controlPointsChanged();
}
+void Patch::Smooth(EMatrixMajor mt)
+{
+ std::size_t w, h, width, height, row_stride, col_stride;
+ PatchControl* p1, * p2, * p3;
+
+ undoSave();
+
+ switch(mt)
+ {
+ case COL:
+ width = (m_width-1)>>1;
+ height = m_height;
+ col_stride = 1;
+ row_stride = m_width;
+ break;
+ case ROW:
+ width = (m_height-1)>>1;
+ height = m_width;
+ col_stride = m_width;
+ row_stride = 1;
+ break;
+ default:
+ ERROR_MESSAGE("neither row-major nor column-major");
+ return;
+ }
+
+ for(h=0;h<height;h++)
+ {
+ p1 = m_ctrl.data()+(h*row_stride)+col_stride;
+ for(w=0;w<width-1;w++)
+ {
+ p2 = p1+col_stride;
+ p3 = p2+col_stride;
+ p2->m_vertex = vector3_mid(p1->m_vertex, p3->m_vertex);
+ p1 = p3;
+ }
+ }
+
+ controlPointsChanged();
+}
+
void Patch::InsertRemove(bool bInsert, bool bColumn, bool bFirst)
{
undoSave();
Scene_forEachVisibleSelectedPatch(PatchRedisperse(major));
}
+class PatchSmooth
+{
+ EMatrixMajor m_major;
+public:
+ PatchSmooth(EMatrixMajor major) : m_major(major)
+ {
+ }
+ void operator()(Patch& patch) const
+ {
+ patch.Smooth(m_major);
+ }
+};
+
+void Scene_PatchSmooth_Selected(scene::Graph& graph, EMatrixMajor major)
+{
+ Scene_forEachVisibleSelectedPatch(PatchSmooth(major));
+}
+
class PatchTransposeMatrix
{
public:
{
UndoableCommand undo("patchRedisperseRows");
- Scene_PatchRedisperse_Selected(GlobalSceneGraph(), COL);
+ Scene_PatchRedisperse_Selected(GlobalSceneGraph(), ROW);
}
void Patch_RedisperseCols()
Scene_PatchRedisperse_Selected(GlobalSceneGraph(), COL);
}
+void Patch_SmoothRows()
+{
+ UndoableCommand undo("patchSmoothRows");
+
+ Scene_PatchSmooth_Selected(GlobalSceneGraph(), ROW);
+}
+
+void Patch_SmoothCols()
+{
+ UndoableCommand undo("patchSmoothColumns");
+
+ Scene_PatchSmooth_Selected(GlobalSceneGraph(), COL);
+}
+
void Patch_Transpose()
{
UndoableCommand undo("patchTranspose");
GlobalCommands_insert("InvertCurve", FreeCaller<Patch_Invert>(), Accelerator('I', (GdkModifierType)GDK_CONTROL_MASK));
GlobalCommands_insert("RedisperseRows", FreeCaller<Patch_RedisperseRows>(), Accelerator('E', (GdkModifierType)GDK_CONTROL_MASK));
GlobalCommands_insert("RedisperseCols", FreeCaller<Patch_RedisperseCols>(), Accelerator('E', (GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK)));
+ GlobalCommands_insert("SmoothRows", FreeCaller<Patch_SmoothRows>(), Accelerator('W', (GdkModifierType)GDK_CONTROL_MASK));
+ GlobalCommands_insert("SmoothCols", FreeCaller<Patch_SmoothCols>(), Accelerator('W', (GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK)));
GlobalCommands_insert("MatrixTranspose", FreeCaller<Patch_Transpose>(), Accelerator('M', (GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK)));
GlobalCommands_insert("CapCurrentCurve", FreeCaller<Patch_Cap>(), Accelerator('C', (GdkModifierType)GDK_SHIFT_MASK));
GlobalCommands_insert("CycleCapTexturePatch", FreeCaller<Patch_CycleProjection>(), Accelerator('N', (GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK)));
menu_tearoff (menu_3);
create_menu_item_with_mnemonic(menu_3, "Rows", "RedisperseRows");
create_menu_item_with_mnemonic(menu_3, "Columns", "RedisperseCols");
+ GtkMenu* menu_4 = create_sub_menu_with_mnemonic (menu_in_menu, "Smooth");
+ if (g_Layout_enableDetachableMenus.m_value)
+ menu_tearoff (menu_4);
+ create_menu_item_with_mnemonic(menu_4, "Rows", "SmoothRows");
+ create_menu_item_with_mnemonic(menu_4, "Columns", "SmoothCols");
create_menu_item_with_mnemonic(menu_in_menu, "Transpose", "MatrixTranspose");
}
menu_separator (menu);