bool 
OrderedTaskPoint::scan_active(OrderedTaskPoint* atp) 
{
  // reset
  m_active_state = NOTFOUND_ACTIVE;

  if (atp == this) {
    m_active_state = CURRENT_ACTIVE;
  } else if (tp_previous 
             && ((get_previous()->getActiveState() 
                  == CURRENT_ACTIVE) 
                 || (get_previous()->getActiveState() 
                     == AFTER_ACTIVE))) {
    m_active_state = AFTER_ACTIVE;
  } else {
    m_active_state = BEFORE_ACTIVE;
  }

  if (tp_next) { 
    // propagate to remainder of task
    return get_next()->scan_active(atp);
  } else {
    return (m_active_state != BEFORE_ACTIVE) && (m_active_state != NOTFOUND_ACTIVE);
  }
}
Пример #2
0
void
AATPoint::set_target(const fixed range, const fixed radial,
                     const TaskProjection &proj)
{
  fixed oldrange = fixed_zero;
  fixed oldradial = fixed_zero;
  get_target_range_radial(oldrange, oldradial);

  const FlatPoint fprev = proj.fproject(get_previous()->get_location_remaining());
  const FlatPoint floc = proj.fproject(get_location());
  const FlatLine flb (fprev,floc);
  const FlatLine fradius (floc,proj.fproject(get_location_min()));
  const fixed bearing = fixed_minus_one * flb.angle().value_degrees();
  const fixed radius = fradius.d();

  fixed swapquadrants = fixed_zero;
  if (positive(range) != positive(oldrange))
    swapquadrants = fixed(180);
  const FlatPoint ftarget1 (fabs(range) * radius *
        cos((bearing + radial + swapquadrants)
            / fixed(360) * fixed_two_pi),
      fabs(range) * radius *
        sin( fixed_minus_one * (bearing + radial + swapquadrants)
            / fixed(360) * fixed_two_pi));

  const FlatPoint ftarget2 = floc + ftarget1;
  const GeoPoint targetG = proj.funproject(ftarget2);

  set_target(targetG, true);
}
Пример #3
0
fixed 
OrderedTaskPoint::double_leg_distance(const GeoPoint &ref) const
{
  assert(tp_previous);
  assert(tp_next);

  return ::DoubleDistance(get_previous()->GetLocationRemaining(), 
                          ref, get_next()->GetLocationRemaining());
}
Пример #4
0
bool
OrderedTaskPoint::scan_active(OrderedTaskPoint* atp)
{
  // reset
  m_active_state = NOTFOUND_ACTIVE;

  if (atp == this)
    m_active_state = CURRENT_ACTIVE;
  else if (tp_previous &&
           (get_previous()->getActiveState() == CURRENT_ACTIVE ||
               get_previous()->getActiveState() == AFTER_ACTIVE))
    m_active_state = AFTER_ACTIVE;
  else
    m_active_state = BEFORE_ACTIVE;

  if (tp_next)
    // propagate to remainder of task
    return get_next()->scan_active(atp);

  return m_active_state != BEFORE_ACTIVE &&
         m_active_state != NOTFOUND_ACTIVE;
}
Пример #5
0
void
AATPoint::update_deadzone(const TaskProjection &projection)
{
  // deadzone must be updated

  assert(get_next());
  assert(get_previous());
  
  // the deadzone is the convex hull formed from the sampled points
  // with the inclusion of all points on the boundary closer than
  // the max double distance to the sample polygon
  
  m_deadzone = SearchPointVector(get_sample_points().begin(),
                                 get_sample_points().end());

  // do nothing if no samples (could happen if not achieved properly)
  if (m_deadzone.empty())
    return;

  // previous and next targets
  const SearchPoint pnext(get_next()->get_location_remaining(),
                          projection);
  const SearchPoint pprevious(get_previous()->get_location_remaining(),
                              projection);

  // find max distance
  unsigned dmax = 0;
  for (SearchPointVector::const_iterator it = get_sample_points().begin();
       it != get_sample_points().end(); ++it) {
    unsigned dd = pnext.flat_distance(*it) + pprevious.flat_distance(*it);
    dmax = std::max(dd, dmax);
  }

  // now add boundary points closer than dmax
  const SearchPointVector& boundary = get_boundary_points();
  for (SearchPointVector::const_iterator it = boundary.begin();
       it != boundary.end(); ++it) {
    unsigned dd = pnext.flat_distance(*it) + pprevious.flat_distance(*it);
    if (dd< dmax)
      m_deadzone.push_back(*it);
  }

  // convert to convex polygon
  prune_interior(m_deadzone);
}
Пример #6
0
void
AATPoint::get_target_range_radial(fixed &range, fixed &radial) const
{
  const fixed oldrange = range;

  const GeoPoint fprev = get_previous()->get_location_remaining();
  const GeoPoint floc = get_location();
  const Angle radialraw = (floc.bearing(get_location_target()) -
      fprev.bearing(floc)).as_bearing();

  const fixed d = floc.distance(get_location_target());
  const fixed radius = floc.distance(get_location_min());
  const fixed rangeraw = min(fixed_one, d / radius);

  radial = radialraw.as_delta().value_degrees();
  const fixed rangesign = (fabs(radial) > fixed(90)) ?
      fixed_minus_one : fixed_one;
  range = rangeraw * rangesign;

  if ((oldrange == fixed_zero) && (range == fixed_zero))
    radial = fixed_zero;
}
Пример #7
0
/*  take an action for the passed note. Enter/edit/check the score following the mode and keyboard state. */
static gint
midiaction (gint notenum)
{
  gboolean new_measure = Denemo.project->movement->cursoroffend;
  DenemoProject *gui = Denemo.project;
  if (gui == NULL)
    return TRUE;
  if (gui->movement == NULL)
    return TRUE;
  DenemoStaff *curstaffstruct = (DenemoStaff *) gui->movement->currentstaff->data;
  enharmonic enote, prevenote;
  gboolean have_previous;
  //g_print("midiaction Adding mask %x, Chord mask %x\n", (Denemo.keyboard_state & ADDING_MASK) , (Denemo.keyboard_state & CHORD_MASK));
  notenum2enharmonic (notenum, &enote.mid_c_offset, &enote.enshift, &enote.octave);
  if (Denemo.project->movement->cursor_appending)
    have_previous = get_current (&prevenote);
  else
    have_previous = get_previous (&prevenote);

  if (!(Denemo.keyboard_state & CHECKING_MASK))
    stage_undo (gui->movement, ACTION_STAGE_END);     //undo is a queue so this is the end :)

  if ((gui->mode & INPUTEDIT) || (Denemo.keyboard_state & CHECKING_MASK))
    {
      static gboolean beep = FALSE;
      gboolean is_tied = FALSE;
      gint measure = gui->movement->currentmeasurenum;
      if (Denemo.project->movement->currentobject)
        {
          DenemoObject *curObj = Denemo.project->movement->currentobject->data;
          if (curObj->type == CHORD)
            {
              do
                {
                  curObj = Denemo.project->movement->currentobject->data;
                  chord *thechord = (chord *) curObj->object;
                  is_tied = (!Denemo.prefs.ignore_ties) && thechord->is_tied;

//#define check_midi_note(a,b,c,d) ((a->mid_c_offset==b)&&(a->enshift==c))?playnote(a,curstaffstruct->midi_channel):gdk_beep();
                  if ((Denemo.keyboard_state & CHECKING_MASK) && thechord->notes)
                    {
                      //later - find note nearest cursor and
                      note *thenote = (note *) thechord->notes->data;
//            check_midi_note(thenote, enote.mid_c_offset + 7 *(enote.octave), enote.enshift, enote.octave);
                      if ((!curObj->isinvisible) && (thenote->mid_c_offset == (enote.mid_c_offset + 7 * (enote.octave))) && (thenote->enshift == enote.enshift))
                        {
                          gint midi = dia_to_midinote (thenote->mid_c_offset) + thenote->enshift;
                          play_note (DEFAULT_BACKEND, 0 /*port */ , curstaffstruct->midi_channel, midi, 300 /*duration */ , 0);
                        }
                      else
                        {
                          gdk_beep ();
                          break;        //do not move on to next note
                        }
                    }
                  else
                    {

                      do_one_note (enote.mid_c_offset, enote.enshift, enote.octave);

                    }
                  if (Denemo.project->movement->cursor_appending)
                    break;
                    curObj = Denemo.project->movement->currentobject->data;
                    thechord = (chord *) curObj->object;
                    is_tied = (!Denemo.prefs.ignore_ties) && thechord->is_tied;
                }
              while ((!(Denemo.keyboard_state & ADDING_MASK)) && next_editable_note () && is_tied);
            }
          else //there is a current object that is not a chord
            {
              if (gui->movement->cursor_appending)
                {
                    do_one_note (enote.mid_c_offset, enote.enshift, enote.octave);
                    next_insert_or_editable_note();
                    //in some circumstance this fails to advance to the next editable note, the following checks for that.
                    if (Denemo.project->movement->currentobject)
                        {
                            curObj = Denemo.project->movement->currentobject->data;
                            if(!curObj->isinvisible)
                               next_editable_note ();
                        }
                }
              else
                gdk_beep ();
            }
          if (gui->mode & INPUTRHYTHM)
            {
              //g_print("measure was %d now %d with appending %d\n", measure, gui->movement->currentmeasurenum, gui->movement->cursor_appending);
              if (!beep && (measure != gui->movement->currentmeasurenum) && !gui->movement->cursor_appending)
                beep = TRUE;
              else if (beep)
                signal_measure_end (), beep = FALSE;
            }
        }
      else
        {                       // no current object
          do_one_note (enote.mid_c_offset, enote.enshift, enote.octave);
          next_insert_or_editable_note();//next_editable_note ();//if we have gone back from an empty measure we need this.
        }
    }
  else
    {                           // not INPUTEDIT
      action_note_into_score (enote.mid_c_offset, enote.enshift, enote.octave);
    }
  if (!(Denemo.keyboard_state & CHECKING_MASK))
    {
      stage_undo (gui->movement, ACTION_STAGE_START);
    }
  draw_score_area();     //just for advancing the cursor.
  if (!(Denemo.keyboard_state & CHECKING_MASK))
    {
      if (Denemo.prefs.immediateplayback)
        {
          gint channel = curstaffstruct->midi_channel;

          if (have_previous && check_interval (enote.mid_c_offset, enote.enshift, prevenote.mid_c_offset, prevenote.enshift))
            channel = Denemo.prefs.pitchspellingchannel;

          play_note (DEFAULT_BACKEND, 0 /*port */ , channel, notenum, 300 /*duration */ , 0);
          if(new_measure)
            signal_measure_end();
        }
    }

  return TRUE;
}
Пример #8
0
 gcc_pure
 bool valid() const {
   return get_previous() != NULL && get_next() != NULL;
 }
bool 
FinishPoint::entry_precondition() const
{
  return get_previous() != NULL && get_previous()->has_entered();
}
Пример #10
0
bool 
FinishPoint::EntryPrecondition() const
{
  return get_previous() != NULL && get_previous()->HasEntered();
}