2007-07-05 06:32:46 +02:00
|
|
|
// Copyright (c) 2007, Rodrigo Braz Monteiro
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
2007-07-05 06:32:46 +02:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file visual_tool_vector_clip.cpp
|
|
|
|
/// @brief Vector clipping visual typesetting tool
|
|
|
|
/// @ingroup visual_ts
|
2007-07-05 06:32:46 +02:00
|
|
|
|
2010-05-16 08:39:11 +02:00
|
|
|
#ifndef AGI_PRE
|
|
|
|
#include <wx/toolbar.h>
|
|
|
|
#endif
|
2007-07-05 06:32:46 +02:00
|
|
|
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2007-07-05 06:32:46 +02:00
|
|
|
#include "ass_dialogue.h"
|
2009-07-24 02:08:25 +02:00
|
|
|
#include "libresrc/libresrc.h"
|
2009-09-10 03:41:34 +02:00
|
|
|
#include "video_display.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "visual_tool_vector_clip.h"
|
2007-07-05 06:32:46 +02:00
|
|
|
|
2007-07-05 08:13:22 +02:00
|
|
|
///////
|
|
|
|
// IDs
|
|
|
|
enum {
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-07-07 07:51:18 +02:00
|
|
|
BUTTON_DRAG = VISUAL_SUB_TOOL_START,
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-07-05 08:13:22 +02:00
|
|
|
BUTTON_LINE,
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-07-05 08:13:22 +02:00
|
|
|
BUTTON_BICUBIC,
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-07-07 09:27:28 +02:00
|
|
|
BUTTON_CONVERT,
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-07-05 08:13:22 +02:00
|
|
|
BUTTON_INSERT,
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-07-05 08:13:22 +02:00
|
|
|
BUTTON_REMOVE,
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-07-07 07:51:18 +02:00
|
|
|
BUTTON_FREEHAND,
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-07-07 07:51:18 +02:00
|
|
|
BUTTON_FREEHAND_SMOOTH,
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2007-07-07 07:51:18 +02:00
|
|
|
BUTTON_LAST // Leave this at the end and don't use it
|
2007-07-05 08:13:22 +02:00
|
|
|
};
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Constructor
|
|
|
|
/// @param parent
|
|
|
|
/// @param _toolBar
|
2010-05-16 08:39:11 +02:00
|
|
|
VisualToolVectorClip::VisualToolVectorClip(VideoDisplay *parent, VideoState const& video, wxToolBar * toolBar)
|
2010-05-20 10:55:58 +02:00
|
|
|
: VisualTool<VisualToolVectorClipDraggableFeature>(parent, video)
|
|
|
|
, spline(*parent)
|
2010-06-03 22:32:10 +02:00
|
|
|
, toolBar(toolBar)
|
2007-07-05 06:32:46 +02:00
|
|
|
{
|
|
|
|
DoRefresh();
|
2007-07-07 07:51:18 +02:00
|
|
|
mode = 0;
|
2007-07-05 08:13:22 +02:00
|
|
|
|
|
|
|
// Create toolbar
|
2009-07-25 06:49:59 +02:00
|
|
|
toolBar->AddTool(BUTTON_DRAG,_("Drag"),GETIMAGE(visual_vector_clip_drag_24),_("Drag control points."),wxITEM_CHECK);
|
|
|
|
toolBar->AddTool(BUTTON_LINE,_("Line"),GETIMAGE(visual_vector_clip_line_24),_("Appends a line."),wxITEM_CHECK);
|
|
|
|
toolBar->AddTool(BUTTON_BICUBIC,_("Bicubic"),GETIMAGE(visual_vector_clip_bicubic_24),_("Appends a bezier bicubic curve."),wxITEM_CHECK);
|
2007-07-07 05:21:52 +02:00
|
|
|
toolBar->AddSeparator();
|
2009-07-25 06:49:59 +02:00
|
|
|
toolBar->AddTool(BUTTON_CONVERT,_("Convert"),GETIMAGE(visual_vector_clip_convert_24),_("Converts a segment between line and bicubic."),wxITEM_CHECK);
|
|
|
|
toolBar->AddTool(BUTTON_INSERT,_("Insert"),GETIMAGE(visual_vector_clip_insert_24),_("Inserts a control point."),wxITEM_CHECK);
|
|
|
|
toolBar->AddTool(BUTTON_REMOVE,_("Remove"),GETIMAGE(visual_vector_clip_remove_24),_("Removes a control point."),wxITEM_CHECK);
|
2007-07-07 05:21:52 +02:00
|
|
|
toolBar->AddSeparator();
|
2009-07-25 06:49:59 +02:00
|
|
|
toolBar->AddTool(BUTTON_FREEHAND,_("Freehand"),GETIMAGE(visual_vector_clip_freehand_24),_("Draws a freehand shape."),wxITEM_CHECK);
|
|
|
|
toolBar->AddTool(BUTTON_FREEHAND_SMOOTH,_("Freehand smooth"),GETIMAGE(visual_vector_clip_freehand_smooth_24),_("Draws a smoothed freehand shape."),wxITEM_CHECK);
|
2007-07-07 07:51:18 +02:00
|
|
|
toolBar->ToggleTool(BUTTON_DRAG,true);
|
2007-07-07 05:21:52 +02:00
|
|
|
toolBar->Realize();
|
|
|
|
toolBar->Show(true);
|
2008-01-14 00:53:43 +01:00
|
|
|
|
|
|
|
// Set default mode
|
|
|
|
PopulateFeatureList();
|
|
|
|
if (features.size() == 0) SetMode(1);
|
2007-07-05 06:32:46 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Sub-tool pressed
|
|
|
|
/// @param event
|
2007-07-07 07:51:18 +02:00
|
|
|
void VisualToolVectorClip::OnSubTool(wxCommandEvent &event) {
|
|
|
|
SetMode(event.GetId() - BUTTON_DRAG);
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Set mode
|
|
|
|
/// @param _mode
|
2007-07-07 07:51:18 +02:00
|
|
|
void VisualToolVectorClip::SetMode(int _mode) {
|
2007-07-08 09:22:09 +02:00
|
|
|
// Make sure clicked is checked and everything else isn't. (Yes, this is radio behavior, but the separators won't let me use it)
|
|
|
|
for (int i=BUTTON_DRAG;i<BUTTON_LAST;i++) {
|
|
|
|
toolBar->ToggleTool(i,i == _mode + BUTTON_DRAG);
|
|
|
|
}
|
2007-07-07 07:51:18 +02:00
|
|
|
mode = _mode;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Draw
|
2007-07-05 06:32:46 +02:00
|
|
|
void VisualToolVectorClip::Draw() {
|
2010-06-07 09:24:43 +02:00
|
|
|
if (spline.curves.empty()) return;
|
|
|
|
|
2007-07-05 06:32:46 +02:00
|
|
|
// Get line
|
|
|
|
AssDialogue *line = GetActiveDialogueLine();
|
|
|
|
if (!line) return;
|
|
|
|
|
|
|
|
// Parse vector
|
2010-06-07 09:24:43 +02:00
|
|
|
std::vector<float> points;
|
2007-07-08 09:22:09 +02:00
|
|
|
std::vector<int> pointCurve;
|
|
|
|
spline.GetPointList(points,pointCurve);
|
2010-06-07 09:24:43 +02:00
|
|
|
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
glVertexPointer(2, GL_FLOAT, 0, &points[0]);
|
2007-07-05 06:32:46 +02:00
|
|
|
|
2010-06-06 00:40:16 +02:00
|
|
|
// The following is nonzero winding-number PIP based on stencils
|
|
|
|
|
|
|
|
// Draw to stencil only
|
2007-07-05 06:32:46 +02:00
|
|
|
glEnable(GL_STENCIL_TEST);
|
2010-06-06 00:40:16 +02:00
|
|
|
glColorMask(0, 0, 0, 0);
|
|
|
|
|
|
|
|
// GL_INCR_WRAP was added in 1.4, so instead set the entire stencil to 128
|
|
|
|
// and wobble from there
|
|
|
|
glStencilFunc(GL_NEVER, 128, 0xFF);
|
|
|
|
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
|
|
|
|
DrawRectangle(0,0,video.w,video.h);
|
|
|
|
|
|
|
|
// Increment the winding number for each forward facing triangle
|
|
|
|
glStencilOp(GL_INCR, GL_INCR, GL_INCR);
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
glCullFace(GL_BACK);
|
2010-06-07 09:24:43 +02:00
|
|
|
glDrawArrays(GL_TRIANGLE_FAN, 0, points.size() / 2);
|
2010-06-06 00:40:16 +02:00
|
|
|
|
|
|
|
// Decrement the winding number for each backfacing triangle
|
|
|
|
glStencilOp(GL_DECR, GL_DECR, GL_DECR);
|
|
|
|
glCullFace(GL_FRONT);
|
2010-06-07 09:24:43 +02:00
|
|
|
glDrawArrays(GL_TRIANGLE_FAN, 0, points.size() / 2);
|
2010-06-06 00:40:16 +02:00
|
|
|
glDisable(GL_CULL_FACE);
|
2007-07-05 06:32:46 +02:00
|
|
|
|
2010-06-06 00:40:16 +02:00
|
|
|
// Draw the actual rectangle
|
2007-07-05 06:32:46 +02:00
|
|
|
glColorMask(1,1,1,1);
|
2007-07-05 06:56:56 +02:00
|
|
|
SetLineColour(colour[3],0.0f);
|
2007-07-05 06:32:46 +02:00
|
|
|
SetFillColour(wxColour(0,0,0),0.5f);
|
2010-06-06 00:40:16 +02:00
|
|
|
|
|
|
|
// VSFilter draws when the winding number is nonzero, so we want to draw the
|
|
|
|
// mask when the winding number is zero (where 128 is zero due to the lack of
|
|
|
|
// wrapping combined with unsigned numbers)
|
|
|
|
glStencilFunc(inverse ? GL_NOTEQUAL : GL_EQUAL, 128, 0xFF);
|
2010-05-16 08:39:11 +02:00
|
|
|
DrawRectangle(0,0,video.w,video.h);
|
2007-07-05 06:32:46 +02:00
|
|
|
glDisable(GL_STENCIL_TEST);
|
|
|
|
|
2007-07-08 09:22:09 +02:00
|
|
|
// Get current position information for modes 3 and 4
|
|
|
|
Vector2D pt;
|
|
|
|
int highCurve = -1;
|
|
|
|
if (mode == 3 || mode == 4) {
|
|
|
|
float t;
|
2010-05-16 08:39:11 +02:00
|
|
|
spline.GetClosestParametricPoint(Vector2D(video.x,video.y),highCurve,t,pt);
|
2007-07-08 09:22:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw lines
|
|
|
|
SetFillColour(colour[3],0.0f);
|
|
|
|
SetLineColour(colour[3],1.0f,2);
|
2010-06-07 09:24:43 +02:00
|
|
|
SetModeLine();
|
|
|
|
glDrawArrays(GL_LINE_STRIP, 0, points.size() / 2);
|
|
|
|
|
|
|
|
// Draw highlighted line
|
|
|
|
if (!curFeature && points.size() > 1 && highCurve > -1) {
|
|
|
|
std::pair<std::vector<int>::iterator, std::vector<int>::iterator> high = std::equal_range(pointCurve.begin(), pointCurve.end(), highCurve);
|
|
|
|
if (high.first != high.second) {
|
|
|
|
SetLineColour(colour[2], 1.f, 2);
|
|
|
|
int first = std::distance(pointCurve.begin(), high.first);
|
|
|
|
int count = std::distance(high.first, high.second);
|
|
|
|
if (first > 0) first -= 1;
|
|
|
|
glDrawArrays(GL_LINE_STRIP, first, count);
|
2007-07-08 09:22:09 +02:00
|
|
|
}
|
|
|
|
}
|
2007-07-05 06:32:46 +02:00
|
|
|
|
2010-06-07 09:24:43 +02:00
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
|
|
|
|
2007-07-05 06:32:46 +02:00
|
|
|
// Draw lines connecting the bicubic features
|
|
|
|
SetLineColour(colour[3],0.9f,1);
|
|
|
|
for (std::list<SplineCurve>::iterator cur=spline.curves.begin();cur!=spline.curves.end();cur++) {
|
|
|
|
if (cur->type == CURVE_BICUBIC) {
|
2007-07-05 16:15:28 +02:00
|
|
|
DrawDashedLine(cur->p1.x,cur->p1.y,cur->p2.x,cur->p2.y,6);
|
|
|
|
DrawDashedLine(cur->p3.x,cur->p3.y,cur->p4.x,cur->p4.y,6);
|
2007-07-05 06:32:46 +02:00
|
|
|
}
|
|
|
|
}
|
2007-07-07 08:41:14 +02:00
|
|
|
|
2007-07-08 09:22:09 +02:00
|
|
|
// Draw features
|
|
|
|
DrawAllFeatures();
|
|
|
|
|
2007-07-07 08:41:14 +02:00
|
|
|
// Draw preview of inserted line
|
|
|
|
if (mode == 1 || mode == 2) {
|
2010-06-04 05:08:10 +02:00
|
|
|
if (spline.curves.size() && video.x > INT_MIN && video.y > INT_MIN) {
|
2010-05-01 03:45:16 +02:00
|
|
|
SplineCurve *c0 = &spline.curves.front();
|
|
|
|
SplineCurve *c1 = &spline.curves.back();
|
2010-05-16 08:39:11 +02:00
|
|
|
DrawDashedLine(video.x,video.y,c0->p1.x,c0->p1.y,6);
|
|
|
|
DrawDashedLine(video.x,video.y,c1->GetEndPoint().x,c1->GetEndPoint().y,6);
|
2007-07-07 08:41:14 +02:00
|
|
|
}
|
|
|
|
}
|
2007-07-07 10:53:11 +02:00
|
|
|
|
|
|
|
// Draw preview of insert point
|
2007-07-08 09:22:09 +02:00
|
|
|
if (mode == 4) DrawCircle(pt.x,pt.y,4);
|
2007-07-05 06:32:46 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Populate feature list
|
2007-07-05 06:32:46 +02:00
|
|
|
void VisualToolVectorClip::PopulateFeatureList() {
|
2010-05-26 09:17:39 +02:00
|
|
|
ClearSelection(false);
|
2007-07-05 06:32:46 +02:00
|
|
|
features.clear();
|
2010-05-26 09:17:39 +02:00
|
|
|
// This is perhaps a bit conservative as there can be up to 3N+1 features
|
|
|
|
features.reserve(spline.curves.size());
|
2010-05-20 10:55:52 +02:00
|
|
|
VisualToolVectorClipDraggableFeature feat;
|
2007-07-05 06:32:46 +02:00
|
|
|
|
|
|
|
// Go through each curve
|
|
|
|
bool isFirst = true;
|
|
|
|
int i = 0;
|
2010-05-26 09:17:39 +02:00
|
|
|
int j = 0;
|
2007-07-05 06:32:46 +02:00
|
|
|
for (std::list<SplineCurve>::iterator cur=spline.curves.begin();cur!=spline.curves.end();cur++,i++) {
|
|
|
|
// First point
|
|
|
|
if (isFirst) {
|
|
|
|
isFirst = false;
|
2008-03-13 19:55:09 +01:00
|
|
|
feat.x = (int)cur->p1.x;
|
|
|
|
feat.y = (int)cur->p1.y;
|
2007-07-05 06:32:46 +02:00
|
|
|
feat.type = DRAG_SMALL_CIRCLE;
|
2010-05-20 10:55:52 +02:00
|
|
|
feat.index = i;
|
|
|
|
feat.point = 0;
|
2007-07-05 06:32:46 +02:00
|
|
|
features.push_back(feat);
|
2010-05-26 09:17:39 +02:00
|
|
|
AddSelection(j++);
|
2007-07-05 06:32:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cur->type == CURVE_LINE) {
|
2008-03-13 19:55:09 +01:00
|
|
|
feat.x = (int)cur->p2.x;
|
|
|
|
feat.y = (int)cur->p2.y;
|
2007-07-05 06:32:46 +02:00
|
|
|
feat.type = DRAG_SMALL_CIRCLE;
|
2010-05-20 10:55:52 +02:00
|
|
|
feat.index = i;
|
|
|
|
feat.point = 1;
|
2007-07-05 06:32:46 +02:00
|
|
|
features.push_back(feat);
|
2010-05-26 09:17:39 +02:00
|
|
|
AddSelection(j++);
|
2007-07-05 06:32:46 +02:00
|
|
|
}
|
|
|
|
|
2010-05-26 09:17:39 +02:00
|
|
|
else if (cur->type == CURVE_BICUBIC) {
|
2007-07-05 06:32:46 +02:00
|
|
|
// Control points
|
2008-03-13 19:55:09 +01:00
|
|
|
feat.x = (int)cur->p2.x;
|
|
|
|
feat.y = (int)cur->p2.y;
|
2010-05-20 10:55:52 +02:00
|
|
|
feat.index = i;
|
|
|
|
feat.point = 1;
|
2007-07-05 06:32:46 +02:00
|
|
|
feat.type = DRAG_SMALL_SQUARE;
|
|
|
|
features.push_back(feat);
|
2008-03-13 19:55:09 +01:00
|
|
|
feat.x = (int)cur->p3.x;
|
|
|
|
feat.y = (int)cur->p3.y;
|
2010-05-20 10:55:52 +02:00
|
|
|
feat.point = 2;
|
2007-07-05 06:32:46 +02:00
|
|
|
features.push_back(feat);
|
|
|
|
|
|
|
|
// End point
|
2008-03-13 19:55:09 +01:00
|
|
|
feat.x = (int)cur->p4.x;
|
|
|
|
feat.y = (int)cur->p4.y;
|
2007-07-05 06:32:46 +02:00
|
|
|
feat.type = DRAG_SMALL_CIRCLE;
|
2010-05-20 10:55:52 +02:00
|
|
|
feat.point = 3;
|
2007-07-05 06:32:46 +02:00
|
|
|
features.push_back(feat);
|
2010-05-26 09:17:39 +02:00
|
|
|
|
|
|
|
AddSelection(j++);
|
|
|
|
AddSelection(j++);
|
|
|
|
AddSelection(j++);
|
2007-07-05 06:32:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Update
|
|
|
|
/// @param feature
|
2010-05-20 10:55:58 +02:00
|
|
|
void VisualToolVectorClip::UpdateDrag(VisualToolVectorClipDraggableFeature* feature) {
|
|
|
|
spline.MovePoint(feature->index,feature->point,wxPoint(feature->x,feature->y));
|
2007-07-05 06:32:46 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Commit
|
|
|
|
/// @param feature
|
2010-05-20 10:55:58 +02:00
|
|
|
void VisualToolVectorClip::CommitDrag(VisualToolVectorClipDraggableFeature* feature) {
|
2010-05-20 10:55:29 +02:00
|
|
|
SetOverride(GetActiveDialogueLine(), inverse ? L"\\iclip" : L"\\clip", L"(" + spline.EncodeToASS() + L")");
|
2007-07-05 06:32:46 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Clicked a feature
|
|
|
|
/// @param feature
|
|
|
|
/// @return
|
2010-05-20 10:55:58 +02:00
|
|
|
bool VisualToolVectorClip::InitializeDrag(VisualToolVectorClipDraggableFeature* feature) {
|
2007-07-07 09:27:28 +02:00
|
|
|
// Delete a control point
|
|
|
|
if (mode == 5) {
|
|
|
|
int i = 0;
|
|
|
|
for (std::list<SplineCurve>::iterator cur=spline.curves.begin();cur!=spline.curves.end();i++,cur++) {
|
2010-05-20 10:55:58 +02:00
|
|
|
if (i == feature->index) {
|
2007-07-07 09:27:28 +02:00
|
|
|
// Update next
|
2010-05-20 10:55:58 +02:00
|
|
|
if (i != 0 || feature->point != 0) {
|
2007-07-07 09:27:28 +02:00
|
|
|
std::list<SplineCurve>::iterator next = cur;
|
|
|
|
next++;
|
|
|
|
if (next != spline.curves.end()) next->p1 = cur->p1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Erase and save changes
|
|
|
|
spline.curves.erase(cur);
|
2010-05-20 10:55:29 +02:00
|
|
|
CommitDrag(feature);
|
2010-05-26 09:17:39 +02:00
|
|
|
PopulateFeatureList();
|
2010-05-20 10:55:58 +02:00
|
|
|
curFeature = NULL;
|
2007-07-07 09:27:28 +02:00
|
|
|
Commit(true);
|
2010-05-20 10:55:35 +02:00
|
|
|
return false;
|
2007-07-07 09:27:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-20 10:55:35 +02:00
|
|
|
return true;
|
2007-07-07 07:51:18 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Initialize hold
|
|
|
|
/// @return
|
2010-05-20 10:55:35 +02:00
|
|
|
bool VisualToolVectorClip::InitializeHold() {
|
2007-07-07 08:41:14 +02:00
|
|
|
// Insert line/bicubic
|
|
|
|
if (mode == 1 || mode == 2) {
|
|
|
|
SplineCurve curve;
|
|
|
|
|
|
|
|
// Set start position
|
|
|
|
if (spline.curves.size()) {
|
|
|
|
curve.p1 = spline.curves.back().GetEndPoint();
|
|
|
|
if (mode == 1) curve.type = CURVE_LINE;
|
|
|
|
else curve.type = CURVE_BICUBIC;
|
|
|
|
|
|
|
|
// Remove point if that's all there is
|
|
|
|
if (spline.curves.size()==1 && spline.curves.front().type == CURVE_POINT) spline.curves.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// First point
|
|
|
|
else {
|
2010-05-16 08:39:11 +02:00
|
|
|
curve.p1 = Vector2D(video.x,video.y);
|
2007-07-07 08:41:14 +02:00
|
|
|
curve.type = CURVE_POINT;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert
|
|
|
|
spline.AppendCurve(curve);
|
2010-05-20 10:55:35 +02:00
|
|
|
UpdateHold();
|
|
|
|
return true;
|
2007-07-07 08:41:14 +02:00
|
|
|
}
|
|
|
|
|
2007-07-07 23:13:20 +02:00
|
|
|
// Convert and insert
|
2010-05-20 10:55:35 +02:00
|
|
|
if (mode == 3 || mode == 4) {
|
2007-07-07 23:13:20 +02:00
|
|
|
// Get closest point
|
|
|
|
Vector2D pt;
|
|
|
|
int curve;
|
|
|
|
float t;
|
2010-05-16 08:39:11 +02:00
|
|
|
spline.GetClosestParametricPoint(Vector2D(video.x,video.y),curve,t,pt);
|
2007-07-07 23:13:20 +02:00
|
|
|
|
|
|
|
// Convert
|
|
|
|
if (mode == 3) {
|
2007-07-08 09:22:09 +02:00
|
|
|
SplineCurve *c1 = spline.GetCurve(curve);
|
|
|
|
if (!c1) {
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (c1->type == CURVE_LINE) {
|
|
|
|
c1->type = CURVE_BICUBIC;
|
|
|
|
c1->p4 = c1->p2;
|
|
|
|
c1->p2 = c1->p1 * 0.75 + c1->p4 * 0.25;
|
|
|
|
c1->p3 = c1->p1 * 0.25 + c1->p4 * 0.75;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (c1->type == CURVE_BICUBIC) {
|
|
|
|
c1->type = CURVE_LINE;
|
|
|
|
c1->p2 = c1->p4;
|
|
|
|
}
|
|
|
|
}
|
2007-07-07 23:13:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Insert
|
|
|
|
else {
|
2007-08-03 19:22:06 +02:00
|
|
|
// Check if there is at least one curve to split
|
2010-05-20 10:55:35 +02:00
|
|
|
if (spline.curves.size() == 0) return false;
|
2007-08-03 19:22:06 +02:00
|
|
|
|
2007-07-07 23:13:20 +02:00
|
|
|
// Split the curve
|
|
|
|
SplineCurve *c1 = spline.GetCurve(curve);
|
|
|
|
SplineCurve c2;
|
|
|
|
if (!c1) {
|
|
|
|
SplineCurve ct;
|
|
|
|
ct.type = CURVE_LINE;
|
|
|
|
ct.p1 = spline.curves.back().GetEndPoint();
|
|
|
|
ct.p2 = spline.curves.front().p1;
|
|
|
|
ct.p2 = ct.p1*(1-t) + ct.p2*t;
|
|
|
|
spline.AppendCurve(ct);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
c1->Split(*c1,c2,t);
|
|
|
|
spline.InsertCurve(c2,curve+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Commit
|
2010-05-20 10:55:29 +02:00
|
|
|
SetOverride(GetActiveDialogueLine(), inverse ? L"\\iclip" : L"\\clip", L"(" + spline.EncodeToASS() + L")");
|
2007-07-07 23:13:20 +02:00
|
|
|
Commit(true);
|
2010-05-20 10:55:35 +02:00
|
|
|
return false;
|
2007-07-07 23:13:20 +02:00
|
|
|
}
|
|
|
|
|
2007-07-07 08:41:14 +02:00
|
|
|
// Freehand
|
2010-05-20 10:55:35 +02:00
|
|
|
if (mode == 6 || mode == 7) {
|
2010-05-26 09:17:39 +02:00
|
|
|
ClearSelection(false);
|
2007-07-08 09:22:09 +02:00
|
|
|
features.clear();
|
2007-07-07 08:41:14 +02:00
|
|
|
spline.curves.clear();
|
2010-05-20 10:55:35 +02:00
|
|
|
lastX = INT_MIN;
|
|
|
|
lastY = INT_MIN;
|
|
|
|
return true;
|
2007-07-07 08:41:14 +02:00
|
|
|
}
|
2010-05-20 10:55:35 +02:00
|
|
|
return false;
|
2007-07-07 07:51:18 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Update hold
|
|
|
|
/// @return
|
2007-07-07 07:51:18 +02:00
|
|
|
void VisualToolVectorClip::UpdateHold() {
|
2007-07-07 08:41:14 +02:00
|
|
|
// Insert line
|
|
|
|
if (mode == 1) {
|
2010-05-16 08:39:11 +02:00
|
|
|
spline.curves.back().p2 = Vector2D(video.x,video.y);
|
2007-07-07 08:41:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Insert bicubic
|
|
|
|
if (mode == 2) {
|
|
|
|
SplineCurve &curve = spline.curves.back();
|
2010-05-16 08:39:11 +02:00
|
|
|
curve.p4 = Vector2D(video.x,video.y);
|
2007-07-07 08:41:14 +02:00
|
|
|
|
|
|
|
// Control points
|
|
|
|
if (spline.curves.size() > 1) {
|
|
|
|
std::list<SplineCurve>::reverse_iterator iter = spline.curves.rbegin();
|
|
|
|
iter++;
|
|
|
|
SplineCurve &c0 = *iter;
|
|
|
|
Vector2D prevVector;
|
|
|
|
float len = (curve.p4-curve.p1).Len();
|
|
|
|
if (c0.type == CURVE_LINE) prevVector = c0.p2-c0.p1;
|
|
|
|
else prevVector = c0.p4-c0.p3;
|
|
|
|
curve.p2 = prevVector.Unit() * (0.25f*len) + curve.p1;
|
|
|
|
}
|
|
|
|
else curve.p2 = curve.p1 * 0.75 + curve.p4 * 0.25;
|
|
|
|
curve.p3 = curve.p1 * 0.25 + curve.p4 * 0.75;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Freehand
|
|
|
|
if (mode == 6 || mode == 7) {
|
2010-05-20 10:55:35 +02:00
|
|
|
if (lastX != INT_MIN && lastY != INT_MIN) {
|
2007-07-07 08:41:14 +02:00
|
|
|
// See if distance is enough
|
2010-05-16 08:39:11 +02:00
|
|
|
Vector2D delta(lastX-video.x,lastY-video.y);
|
2007-07-07 08:41:14 +02:00
|
|
|
int len = (int)delta.Len();
|
|
|
|
if (mode == 6 && len < 30) return;
|
|
|
|
if (mode == 7 && len < 60) return;
|
|
|
|
|
|
|
|
// Generate curve and add it
|
|
|
|
SplineCurve curve;
|
|
|
|
curve.type = CURVE_LINE;
|
|
|
|
curve.p1 = Vector2D(lastX,lastY);
|
2010-05-16 08:39:11 +02:00
|
|
|
curve.p2 = Vector2D(video.x,video.y);
|
2007-07-07 08:41:14 +02:00
|
|
|
spline.AppendCurve(curve);
|
|
|
|
}
|
2010-05-16 08:39:11 +02:00
|
|
|
lastX = video.x;
|
|
|
|
lastY = video.y;
|
2007-07-07 07:51:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Commit hold
|
2007-07-07 07:51:18 +02:00
|
|
|
void VisualToolVectorClip::CommitHold() {
|
|
|
|
// Smooth spline
|
|
|
|
if (!holding && mode == 7) spline.Smooth();
|
|
|
|
|
|
|
|
// Save it
|
2008-09-10 18:13:54 +02:00
|
|
|
if (mode != 3 && mode != 4) {
|
2010-05-26 09:17:39 +02:00
|
|
|
SetOverride(curDiag, inverse ? L"\\iclip" : L"\\clip", L"(" + spline.EncodeToASS() + L")");
|
2008-09-10 18:13:54 +02:00
|
|
|
}
|
2007-07-08 09:22:09 +02:00
|
|
|
|
|
|
|
// End freedraw
|
2007-10-18 21:17:01 +02:00
|
|
|
if (!holding && (mode == 6 || mode == 7)) SetMode(0);
|
2010-05-26 09:17:39 +02:00
|
|
|
|
|
|
|
PopulateFeatureList();
|
2007-07-07 07:51:18 +02:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
/// @brief Refresh
|
2007-07-05 06:32:46 +02:00
|
|
|
void VisualToolVectorClip::DoRefresh() {
|
2010-05-20 10:55:08 +02:00
|
|
|
if (!dragging && !holding) {
|
2007-07-05 06:32:46 +02:00
|
|
|
// Get line
|
|
|
|
AssDialogue *line = GetActiveDialogueLine();
|
|
|
|
if (!line) return;
|
|
|
|
|
|
|
|
// Get clip vector
|
|
|
|
wxString vect;
|
|
|
|
int scale;
|
2008-09-10 18:13:54 +02:00
|
|
|
vect = GetLineVectorClip(line,scale,inverse);
|
2007-07-05 06:32:46 +02:00
|
|
|
spline.DecodeFromASS(vect);
|
|
|
|
PopulateFeatureList();
|
|
|
|
}
|
|
|
|
}
|
2009-07-29 07:43:02 +02:00
|
|
|
|