本文整理汇总了C++中DuckList::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ DuckList::begin方法的具体用法?C++ DuckList::begin怎么用?C++ DuckList::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DuckList
的用法示例。
在下文中一共展示了DuckList::begin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selected_ducks
void
DuckDrag_SmoothMove::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
{
const DuckList selected_ducks(duckmatic->get_selected_ducks());
DuckList::const_iterator iter;
synfig::Vector vect(duckmatic->snap_point_to_grid(vector)-drag_offset_+snap);
int i;
Time time(duckmatic->get_time());
// process vertex and position ducks first
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
{
// skip this duck if it is NOT a vertex or a position
if (((*iter)->get_type() != Duck::TYPE_VERTEX &&
(*iter)->get_type() != Duck::TYPE_POSITION))
continue;
Point p(positions[i]);
float dist(1.0f-(p-drag_offset_).mag()/get_radius());
if(dist<0)
dist=0;
last_[i]=vect*dist;
(*iter)->set_trans_point(p+last_[i], time);
}
// then process non vertex and non position ducks
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
{
// skip this duck if it IS a vertex or a position
if (!((*iter)->get_type() != Duck::TYPE_VERTEX &&
(*iter)->get_type() != Duck::TYPE_POSITION))
continue;
Point p(positions[i]);
float dist(1.0f-(p-drag_offset_).mag()/get_radius());
if(dist<0)
dist=0;
last_[i]=vect*dist;
(*iter)->set_trans_point(p+last_[i], time);
}
// then patch up the tangents for the vertices we've moved
duckmatic->update_ducks();
last_translate_=vect;
//snap=Vector(0,0);
}
示例2: selected_ducks
void
DuckDrag_Mirror::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
{
center=vector;
int i;
const DuckList selected_ducks(duckmatic->get_selected_ducks());
DuckList::const_iterator iter;
Time time(duckmatic->get_time());
// do the Vertex and Position ducks first
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
if ((*iter)->get_type() == Duck::TYPE_VERTEX ||
(*iter)->get_type() == Duck::TYPE_POSITION)
{
Vector p(positions[i]);
if (axis==AXIS_X) p[0] = -(p[0]-center[0]) + center[0];
else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + center[1];
(*iter)->set_trans_point(p);
}
// then do the other ducks
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
if ((*iter)->get_type() != Duck::TYPE_VERTEX &&
(*iter)->get_type() != Duck::TYPE_POSITION)
{
// we don't need to mirror radius ducks - they're one-dimensional
if ((*iter)->is_radius())
continue;
Vector p(positions[i]);
if (axis==AXIS_X) p[0] = -(p[0]-center[0]) + center[0];
else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + center[1];
(*iter)->set_trans_point(p);
}
}
示例3: selected_ducks
void
DuckDrag_Rotate::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& offset)
{
last_rotate=Vector(1,1);
const DuckList selected_ducks(duckmatic->get_selected_ducks());
DuckList::const_iterator iter;
/*
if(duckmatic->get_selected_ducks().size()<2)
{
bad_drag=true;
return;
}
*/
bad_drag=false;
drag_offset=duckmatic->find_duck(offset)->get_trans_point();
//snap=drag_offset-duckmatic->snap_point_to_grid(drag_offset);
//snap=offset-drag_offset;
snap=Vector(0,0);
// Calculate center
Point vmin(100000000,100000000);
Point vmax(-100000000,-100000000);
//std::set<etl::handle<Duck> >::iterator iter;
positions.clear();
int i;
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
{
Point p((*iter)->get_trans_point());
vmin[0]=min(vmin[0],p[0]);
vmin[1]=min(vmin[1],p[1]);
vmax[0]=max(vmax[0],p[0]);
vmax[1]=max(vmax[1],p[1]);
positions.push_back(p);
}
center=(vmin+vmax)*0.5;
if((vmin-vmax).mag()<=EPSILON)
move_only=true;
else
move_only=false;
synfig::Vector vect(offset-center);
original_angle=Angle::tan(vect[1],vect[0]);
original_mag=vect.mag();
}
示例4: selected_ducks
Smach::event_result
StateNormal_Context::event_multiple_ducks_clicked_handler(const Smach::event& x)
{
// synfig::info("STATE NORMAL: Received multiple duck click event");
//const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
std::list<synfigapp::ValueDesc> value_desc_list;
// Create a list of value_descs associated with selection
const DuckList selected_ducks(get_work_area()->get_selected_ducks());
DuckList::const_iterator iter;
for(iter=selected_ducks.begin();iter!=selected_ducks.end();++iter)
{
synfigapp::ValueDesc value_desc((*iter)->get_value_desc());
if(!value_desc.is_valid())
continue;
value_desc_list.push_back(value_desc);
}
Gtk::Menu *menu=manage(new Gtk::Menu());
menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
canvas_view_->get_instance()->make_param_menu(
menu,
canvas_view_->get_canvas(),
value_desc_list,
event.duck ? event.duck->get_value_desc() : synfigapp::ValueDesc()
);
menu->popup(3,gtk_get_current_event_time());
return Smach::RESULT_ACCEPT;
}
示例5: vect
void
DuckDrag_Rotate::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
{
if(bad_drag)
return;
//std::set<etl::handle<Duck> >::iterator iter;
synfig::Vector vect(duckmatic->snap_point_to_grid(vector)-center+snap);
const DuckList selected_ducks(duckmatic->get_selected_ducks());
DuckList::const_iterator iter;
if(move_only)
{
int i;
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
{
if((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION)continue;
Vector p(positions[i]);
p[0]+=vect[0];
p[1]+=vect[1];
(*iter)->set_trans_point(p);
}
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
{
if(!((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue;
Vector p(positions[i]);
p[0]+=vect[0];
p[1]+=vect[1];
(*iter)->set_trans_point(p);
}
return;
}
Angle::tan angle(vect[1],vect[0]);
angle=original_angle-angle;
Real mag(vect.mag()/original_mag);
Real sine(Angle::sin(angle).get());
Real cosine(Angle::cos(angle).get());
int i;
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
{
if((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION)continue;
Vector x(positions[i]-center),p;
p[0]=cosine*x[0]+sine*x[1];
p[1]=-sine*x[0]+cosine*x[1];
if(use_magnitude)p*=mag;
p+=center;
(*iter)->set_trans_point(p);
}
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
{
if(!((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue;
Vector x(positions[i]-center),p;
p[0]=cosine*x[0]+sine*x[1];
p[1]=-sine*x[0]+cosine*x[1];
if(use_magnitude)p*=mag;
p+=center;
(*iter)->set_trans_point(p);
}
last_rotate=vect;
//snap=Vector(0,0);
}
示例6: selected_ducks
void
DuckDrag_Scale::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
{
const DuckList selected_ducks(duckmatic->get_selected_ducks());
DuckList::const_iterator iter;
if(bad_drag)
return;
//std::set<etl::handle<Duck> >::iterator iter;
synfig::Vector vect(duckmatic->snap_point_to_grid(vector)-center);
last_scale=vect;
if(move_only)
{
int i;
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
{
if(((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue;
Vector p(positions[i]);
p[0]+=vect[0];
p[1]+=vect[1];
(*iter)->set_trans_point(p);
}
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
{
if(!((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue;
Vector p(positions[i]);
p[0]+=vect[0];
p[1]+=vect[1];
(*iter)->set_trans_point(p);
}
return;
}
if(!lock_aspect)
{
if(abs(drag_offset[0]-center[0])>EPSILON)
vect[0]/=drag_offset[0]-center[0];
else
vect[0]=1;
if(abs(drag_offset[1]-center[1])>EPSILON)
vect[1]/=drag_offset[1]-center[1];
else
vect[1]=1;
}
else
{
//vect[0]=vect[1]=vect.mag()*0.707106781;
Real amount(vect.mag()/(drag_offset-center).mag());
vect[0]=vect[1]=amount;
}
if(vect[0]<EPSILON && vect[0]>-EPSILON)
vect[0]=1;
if(vect[1]<EPSILON && vect[1]>-EPSILON)
vect[1]=1;
int i;
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
{
if(((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue;
Vector p(positions[i]-center);
p[0]*=vect[0];
p[1]*=vect[1];
p+=center;
(*iter)->set_trans_point(p);
}
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
{
if(!((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION))continue;
Vector p(positions[i]-center);
p[0]*=vect[0];
p[1]*=vect[1];
p+=center;
(*iter)->set_trans_point(p);
}
last_scale=vect;
//snap=Vector(0,0);
}
示例7: if
void
StateWidth_Context::AdjustWidth(handle<Duckmatic::Bezier> c, float t, Real mult, bool invert)
{
//Leave the function if there is no curve
if(!c)return;
Real amount1=0,amount2=0;
//decide how much to change each width
/*
t \in [0,1]
both pressure and multiply amount are in mult
(may want to change this to allow different types of falloff)
rsq is the squared distance from the point on the curve (also part of the falloff)
*/
//may want to provide a different falloff function...
if(t <= 0.2)
amount1 = mult;
else if(t >= 0.8)
amount2 = mult;
else
{
float u = (t-0.2)/0.6;
amount1 = (1-u)*mult;
amount2 = u*mult;
}
// change sign if we are decreasing widths
if(invert)
{
amount1 *= -1;
amount2 *= -1;
}
// ducks for the bezier vertexes
handle<Duck> p1 = c->p1;
handle<Duck> p2 = c->p2;
// ducks for the widths of the bezier vertexes
handle<Duck> w1,w2;
//find w1,w2
{
const DuckList dl = get_work_area()->get_duck_list();
DuckList::const_iterator i = dl.begin();
for(;i != dl.end(); ++i)
{
if((*i)->get_type() == Duck::TYPE_WIDTH)
{
if((*i)->get_origin_duck() == p1)
{
w1 = *i;
}
if((*i)->get_origin_duck() == p2)
{
w2 = *i;
}
}
}
}
// change the widths of the affected BLine of Outlines
if(amount1 != 0 && w1)
{
Real width = w1->get_point().mag();
width += amount1;
w1->set_point(Vector(width,0));
//log in the list of changes...
//to truly be changed after everything is said and done
changetable[w1] = width;
}
if(amount2 != 0 && w2)
{
Real width = w2->get_point().mag();
width += amount2;
w2->set_point(Vector(width,0));
//log in the list of changes...
//to truly be changed after everything is said and done
changetable[w2] = width;
}
///////
// Change the widths of the affected BLine of Advance Outlines
// Parents value nodes of the value node of the p1 and p2 ducks.
synfig::ValueNode::Handle p1pvn(p1->get_value_desc().get_parent_value_node());
synfig::ValueNode::Handle p2pvn(p2->get_value_desc().get_parent_value_node());
// if the bezier position ducks are linkable valuenode children
if(p1pvn && p2pvn && p1pvn==p2pvn)
{
// we guess that the parent value node is a bline value node
synfig::ValueNode::Handle bezier_bline=p1pvn;
// Positions of the points on the bline
Real p1_pos, bezier_size;
// index of the first point on the bezier
int p1_i;
// retrieve the number of blinepoints on the bline and the loop of the bline
int bline_size((*(bezier_bline))(get_canvas()->get_time()).get_list().size());
bool loop((*(bezier_bline))(get_canvas()->get_time()).get_loop());
p1_i = p1->get_value_desc().get_index();
// bezier size depends on loop status
bezier_size = 1.0/(loop?bline_size:(bline_size-1));
if(loop)
{
// if looped and the we are in the first bezier
if(p1_i == (bline_size -1))
p1_i = 0;
else
p1_i++;
//.........这里部分代码省略.........