void DeclarativeTabModel::addTab(const QString& url, const QString &title) {
    if (!LinkValidator::navigable(QUrl(url))) {
        return;
    }
    int tabId = DBManager::instance()->createTab();
    int linkId = DBManager::instance()->createLink(tabId, url, title);

    Tab tab(tabId, Link(linkId, url, "", title), 0, 0);
#ifdef DEBUG_LOGS
    qDebug() << "new tab data:" << &tab;
#endif
    if (m_activeTab.isValid()) {
        beginInsertRows(QModelIndex(), 0, 0);
        m_tabs.insert(0, m_activeTab);
        endInsertRows();
    }

    updateActiveTab(tab);
    emit countChanged();
    emit tabAdded(tabId);

    m_nextTabId = ++tabId;
    emit nextTabIdChanged();
}
Beispiel #2
0
void Generate::run()
{
	showParams();
	NS_CORE Singletons::getInstance()->getIOFileManager()->cleanFiles();
	auto N = NS_CORE Singletons::getInstance()->getInitialData()._numberOfPlanetaryGears;

	//	Заполняем вектор всех возможных связей, пропускаем связи между элементами одного ряда и реверсивные связи.
	m_allLinks.clear();
	for ( size_t i = 1; i < N; i++ )
	{
		for ( const auto& mElem1 : s_elements )
		{
			for ( size_t j = i + 1; j <= N; j++ )
			{
				for ( const auto& mElem2 : s_elements )
				{
					m_allLinks.push_back( NS_CORE Link( NS_CORE Element( mElem1, NS_CORE GearSetNumber( i ) ), NS_CORE Element( mElem2, NS_CORE GearSetNumber( j ) ) ) );
				}
			}
		}
	}

	generateInOut();
}
Beispiel #3
0
void Relink()
{
    Link(GL_FALSE);
}
Beispiel #4
0
int AttachGalley(OBJECT hd, OBJECT *inners, OBJECT *suspend_pt)
{ OBJECT hd_index;		/* the index of hd in the enclosing galley   */
  OBJECT hd_inners;		/* inner galleys of hd, if unsized           */
  OBJECT dest;			/* the target @Galley hd empties into        */
  OBJECT dest_index;		/* the index of dest                         */
  OBJECT target;		/* the target indefinite containing dest     */
  OBJECT target_index;		/* the index of target                       */
  OBJECT target_galley;		/* the body of target, made into a galley    */
  OBJECT tg_inners;		/* inner galleys of target_galley            */
  BOOLEAN need_precedes = FALSE;/* true if destination lies before galley    */
  OBJECT recs;			/* list of recursive definite objects        */
  OBJECT link, y = nilobj;	/* for scanning through the components of hd */
  CONSTRAINT c;			/* temporary variable holding a constraint   */
  OBJECT env, n1, tmp, zlink, z, sym;	/* placeholders and temporaries	     */
  BOOLEAN was_sized;		/* true if sized(hd) initially               */
  int dim;			/* the galley direction                      */
  FULL_LENGTH perp_back, perp_fwd;
  OBJECT why, junk;

  debug2(DGA, D, "[ AttachGalley(Galley %s into %s)",
	SymName(actual(hd)), SymName(whereto(hd)));
  ifdebug(DGA, DD, DebugGalley(hd, nilobj, 4));
  assert( Up(hd) != hd, "AttachGalley: no index!" );
  Parent(hd_index, Up(hd));
  assert( type(hd_index) == UNATTACHED, "AttachGalley: not UNATTACHED!" );
  hd_inners = tg_inners = nilobj;
  was_sized = sized(hd);
  dim = gall_dir(hd);

  for(;;)
  {
    /*************************************************************************/
    /*                                                                       */
    /*  Search for a destination for hd.  If hd is unsized, search for       */
    /*  inner galleys preceding it first of all, then for receptive objects  */
    /*  following it, possibly in inner galleys.  If no luck, exit.          */
    /*  If hd is sized, search only for receptive objects in the current     */
    /*  galley below the current spot, and fail if cannot find any.          */
    /*                                                                       */
    /*************************************************************************/

    sym = whereto(hd);
    if( sized(hd) )
    {
      /* sized galley case: search on from current spot */
      target_index = SearchGalley(Up(hd_index), sym, TRUE, FALSE, TRUE, TRUE);
      if( target_index == nilobj )
      {	
	/* search failed to find any new target, so kill the galley */
	for( link = Down(hd); link != hd; link = NextDown(link) )
	{ Child(y, link);
	  if( type(y) == SPLIT )  Child(y, DownDim(y, dim));
	  if( is_definite(type(y)) )  break;
	}
	if( link != hd )
	  Error(19, 1, "galley %s deleted from here (no target)",
	    WARN, &fpos(y), SymName(actual(hd)));
	if( hd_inners != nilobj )  DisposeObject(hd_inners), hd_inners=nilobj;
	if( tg_inners != nilobj )  DisposeObject(tg_inners), tg_inners=nilobj;
	KillGalley(hd, FALSE);
	*inners = nilobj;
	debug0(DGA, D, "] AttachGalley returning ATTACH_KILLED");
	return ATTACH_KILLED;
      }
      else if( actual(actual(target_index)) == InputSym )
      {
	/* search found input object, so suspend on that */
	DeleteNode(hd_index);
	Link(target_index, hd);
	*inners = nilobj;
	debug0(DGA, D, "] AttachGalley returning ATTACH_INPUT");
	return ATTACH_INPUT;
      }

    }
    else /* unsized galley, either backwards or normal */
    {
      if( foll_or_prec(hd) == GALL_PREC )
      {	target_index= SearchGalley(Up(hd_index), sym, FALSE, TRUE,TRUE,FALSE);
	need_precedes = FALSE;
      }
      else
      {	target_index = SearchGalley(Up(hd_index), sym, FALSE,TRUE,FALSE,FALSE);
	need_precedes = (target_index != nilobj);
	if( target_index == nilobj )
	  target_index = SearchGalley(Up(hd_index), sym, TRUE,TRUE,TRUE,FALSE);
      }

      /* if no luck, exit without error */
      if( target_index == nilobj )
      {	*inners = nilobj;
	debug0(DGA, D, "] AttachGalley returning ATTACH_NOTARGET");
	return ATTACH_NOTARGET;
      }
    }
    assert( type(target_index) == RECEPTIVE, "AttachGalley: target_index!" );
    target = actual(target_index);
    assert( type(target) == CLOSURE, "AttachGalley: target!" );

    /* set target_galley to the expanded value of target */
    debug1(DYY, D, "[ EnterErrorBlock(FALSE) (expanding target %s)",
      SymName(actual(target)));
    EnterErrorBlock(FALSE);
    New(target_galley, HEAD);
    force_gall(target_galley) = FALSE;
    enclose_obj(target_galley) = limiter(target_galley) = nilobj;
    ClearHeaders(target_galley);
    opt_components(target_galley) = opt_constraints(target_galley) = nilobj;
    gall_dir(target_galley) = external_hor(target) ? COLM : ROWM;
    FposCopy(fpos(target_galley), fpos(target));
    actual(target_galley) = actual(target);
    whereto(target_galley) = ready_galls(target_galley) = nilobj;
    foll_or_prec(target_galley) = GALL_FOLL;
    must_expand(target_galley) = FALSE;
    sized(target_galley) = FALSE;

    /* get perpendicular constraint (none if horizontal galley) */
    if( dim == ROWM )
    {
      Constrained(target, &c, 1-dim, &junk);
      if( !constrained(c) )
        Error(19, 2, "receptive symbol %s has unconstrained width",
	  FATAL, &fpos(target), SymName(actual(target)));
      debug2(DSC, DD, "Constrained( %s, 1-dim ) = %s",
	EchoObject(target), EchoConstraint(&c));
      if( !FitsConstraint(0, 0, c) )
      { debug0(DGA, D, "  reject: target_galley horizontal constraint is -1");
	y = nilobj;
        goto REJECT;
      }
    }
    else /* actually unused */
      SetConstraint(c, MAX_FULL_LENGTH, MAX_FULL_LENGTH, MAX_FULL_LENGTH);

    debug1(DGA, DDD, "  expanding %s", EchoObject(target));
    tmp = CopyObject(target, no_fpos);
    Link(target_galley, tmp);
    env = DetachEnv(tmp);
    debug4(DGM, D, "  external_ver(%s) = %s, external_hor(%s) = %s",
      SymName(actual(target)), bool(external_ver(target)),
      SymName(actual(target)), bool(external_hor(target)));
    SizeGalley(target_galley, env,
	external_ver(target) || external_hor(target),
	threaded(target), non_blocking(target_index),
	trigger_externs(target_index), &save_style(target),
	&c, whereto(hd), &dest_index, &recs, &tg_inners,
	enclose_obj(hd) != nilobj ? CopyObject(enclose_obj(hd), no_fpos):nilobj);
    debug1(DGA, DD, "  SizeGalley tg_inners: %s", DebugInnersNames(tg_inners));
    if( recs != nilobj )  ExpandRecursives(recs);
    dest = actual(dest_index);
    if( underline(dest) == UNDER_UNDEF )  underline(dest) = UNDER_OFF;

    /* verify that hd satisfies any horizontal constraint on dest */
    if( dim == ROWM )
    {
      debug1(DGA, DDD, "  checking hor fit of hd in %s",SymName(actual(dest)));
      Constrained(dest, &c, 1-dim, &junk);
      debug3(DSC, DD, "Constrained( %s, %s ) = %s",
	EchoObject(dest), dimen(1-dim), EchoConstraint(&c));
      assert( constrained(c), "AttachGalley: dest unconstrained!" );
      if( !FitsConstraint(0, 0, c) )
      { debug0(DGA, D, "  reject: hd horizontal constraint is -1");
	y = nilobj;
        goto REJECT;
      }
    }

    /* manifest and size the galley if not done yet */
    if( !sized(hd) )
    {
      debug2(DYY, D, "[ EnterErrorBlock(TRUE) (sizing galley %s into %s)",
	SymName(actual(hd)), SymName(whereto(hd)));
      EnterErrorBlock(TRUE);
      n1 = nilobj;
      Child(y, Down(hd));
      env = DetachEnv(y);
      /*** threaded() only defined in ROWM case
      SizeGalley(hd, env, TRUE, threaded(dest), non_blocking(target_index),
	TRUE, &save_style(dest), &c, nilobj, &n1, &recs, &hd_inners);
      *** */
      SizeGalley(hd, env, TRUE, dim == ROWM ? threaded(dest) : FALSE,
	non_blocking(target_index), TRUE, &save_style(dest), &c, nilobj,
	&n1, &recs, &hd_inners, nilobj);
      debug1(DGA,DD,"  SizeGalley hd_inners: %s", DebugInnersNames(hd_inners));
      if( recs != nilobj )  ExpandRecursives(recs);
      if( need_precedes )		/* need an ordering constraint */
      {	OBJECT index1, index2;
        New(index1, PRECEDES);
	New(index2, FOLLOWS);
	blocked(index2) = FALSE;
	tmp = MakeWord(WORD, STR_EMPTY, no_fpos);
	Link(index1, tmp);  Link(index2, tmp);
	Link(Up(hd_index), index1);
	Link(Down(hd), index2);
	debug0(DGA, D, "  inserting PRECEDES and FOLLOWS");
      }
      LeaveErrorBlock(TRUE);
      debug0(DYY, D, "] LeaveErrorBlock(TRUE) (finished sizing galley)");
    }

    if( dim == ROWM )
    { if( !FitsConstraint(back(hd, 1-dim), fwd(hd, 1-dim), c) )
      { debug3(DGA, D, "  reject: hd %s,%s does not fit target_galley %s",
	  EchoLength(back(hd, 1-dim)), EchoLength(fwd(hd, 1-dim)),
	  EchoConstraint(&c));
        Error(19, 3, "too little horizontal space for galley %s at %s",
	  WARN, &fpos(hd), SymName(actual(hd)), SymName(actual(dest)));
        goto REJECT;
      }
    }

    /* check status of first component of hd */
    debug0(DGA, DDD, "  now ready to attach; hd =");
    ifdebug(DGA, DDD, DebugObject(hd));
    for( link = Down(hd);  link != hd;  link = NextDown(link) )
    {
      Child(y, link);
      debug1(DGA, DDD, "  examining %s", EchoIndex(y));
      if( type(y) == SPLIT )  Child(y, DownDim(y, dim));
      switch( type(y) )
      {

	case EXPAND_IND:
	case SCALE_IND:
	case COVER_IND:
	case GALL_PREC:
	case GALL_FOLL:
	case GALL_FOLL_OR_PREC:
	case GALL_TARG:
	case CROSS_PREC:
	case CROSS_FOLL:
	case CROSS_FOLL_OR_PREC:
	case CROSS_TARG:
	case PAGE_LABEL_IND:
	    
	  break;


	case PRECEDES:
	case UNATTACHED:
	    
	  if( was_sized )
	  { /* SizeGalley was not called, so hd_inners was not set by it */
	    if( hd_inners == nilobj )  New(hd_inners, ACAT);
	    Link(hd_inners, y);
	  }
	  break;


	case RECEPTIVE:

	  goto SUSPEND;


	case RECEIVING:
	    
	  goto SUSPEND;


	case FOLLOWS:
	    
	  Child(tmp, Down(y));
	  if( Up(tmp) == LastUp(tmp) )
	  { link = pred(link, CHILD);
	    debug0(DGA, DD, "  disposing FOLLOWS");
	    DisposeChild(NextDown(link));
	    break;
	  }
	  Parent(tmp, Up(tmp));
	  assert(type(tmp) == PRECEDES, "Attach: PRECEDES!");
	  switch( CheckComponentOrder(tmp, target_index) )
	  {
	    case CLEAR:		DeleteNode(tmp);
				link = pred(link, CHILD);
				DisposeChild(NextDown(link));
				break;

	    case PROMOTE:	break;

	    case BLOCK:		debug0(DGA, DD, "CheckContraint: BLOCK");
				goto SUSPEND;

	    case CLOSE:		debug0(DGA, D, "  reject: CheckContraint");
				goto REJECT;
	  }
	  break;


	case GAP_OBJ:

	  underline(y) = underline(dest);
	  if( !join(gap(y)) )  seen_nojoin(hd) = TRUE;
	  break;


	case BEGIN_HEADER:
	case END_HEADER:
	case SET_HEADER:
	case CLEAR_HEADER:

	  /* do nothing until actually promoted out of here */
	  underline(y) = underline(dest);
	  break;


	case CLOSURE:
	case CROSS:
	case FORCE_CROSS:
	case NULL_CLOS:
	case PAGE_LABEL:

	  underline(y) = underline(dest);
	  break;


	case WORD:
	case QWORD:
	case ONE_COL:
	case ONE_ROW:
	case WIDE:
	case HIGH:
	case HSHIFT:
	case VSHIFT:
	case HMIRROR:
	case VMIRROR:
	case HSCALE:
	case VSCALE:
	case HCOVER:
	case VCOVER:
	case HCONTRACT:
	case VCONTRACT:
	case HLIMITED:
	case VLIMITED:
	case HEXPAND:
	case VEXPAND:
	case START_HVSPAN:
	case START_HSPAN:
	case START_VSPAN:
	case HSPAN:
	case VSPAN:
	case ROTATE:
	case BACKGROUND:
	case SCALE:
	case KERN_SHRINK:
	case INCGRAPHIC:
	case SINCGRAPHIC:
	case PLAIN_GRAPHIC:
	case GRAPHIC:
	case LINK_SOURCE:
	case LINK_DEST:
	case LINK_DEST_NULL:
	case LINK_URL:
	case ACAT:
	case HCAT:
	case VCAT:
	case ROW_THR:
	case COL_THR:
	    

	  underline(y) = underline(dest);
	  if( dim == ROWM )
	  {
	    /* make sure y is not joined to a target below (vertical only) */
	    for( zlink = NextDown(link); zlink != hd; zlink = NextDown(zlink) )
	    { Child(z, zlink);
	      switch( type(z) )
	      {
	        case RECEPTIVE:
		
		  if( non_blocking(z) )
		  { zlink = PrevDown(zlink);
		    DeleteNode(z);
		  }
		  else
		  { y = z;
		    goto SUSPEND;
		  }
		  break;


	        case RECEIVING:
		
		  if( non_blocking(z) )
		  { zlink = PrevDown(zlink);
		    while( Down(z) != z )
		    { Child(tmp, Down(y));
		      if( opt_components(tmp) != nilobj )
		      { DisposeObject(opt_components(tmp));
		        opt_components(tmp) = nilobj;
		        debug3(DOG, D, "AttachGalley(%s) de-optimizing %s %s",
			  SymName(actual(hd)), SymName(actual(tmp)), "(join)");
		      }
		      DetachGalley(tmp);
		      KillGalley(tmp, FALSE);
		    }
		    DeleteNode(z);
		  }
		  else
		  { y = z;
		    goto SUSPEND;
		  }
		  break;


	        case GAP_OBJ:
		
		  if( !join(gap(z)) )  zlink = PrevDown(hd);
		  break;


	        default:	break;
	      }
	    }

	    /* if HCAT, try vertical hyphenation (vertical galleys only) */
	    if( type(y) == HCAT )  VerticalHyphenate(y);
	  }


	  /* check availability of parallel space for the first component */
	  why = nilobj;
	  Constrained(dest, &c, dim, &why);
	  debug3(DGF, DD, "  dest parallel Constrained(%s, %s) = %s",
	    EchoObject(dest), dimen(dim), EchoConstraint(&c));
	  if( !FitsConstraint(back(y, dim), fwd(y, dim), c) )
	  { BOOLEAN scaled;

	    /* if forcing galley doesn't fit, try scaling first component */
	    scaled = FALSE;
	    if( force_gall(hd) && size(y, dim) > 0 )
	    { int scale_factor;
	      scale_factor = ScaleToConstraint(back(y,dim), fwd(y,dim), &c);
	      if( scale_factor > 0.5 * SF )
	      {	char num1[20], num2[20];
		sprintf(num1, "%.1fc", (float) size(y, dim) / CM);
		sprintf(num2, "%.1fc", (float) bfc(c) / CM);
		if( dim == ROWM )
		  Error(19, 4, "%s object too high for %s space; %s inserted",
		    WARN, &fpos(y), num1, num2, KW_SCALE);
		else
		  Error(19, 5, "%s object too wide for %s space; %s inserted",
		    WARN, &fpos(y), num1, num2, KW_SCALE);
		y = InterposeScale(y, scale_factor, dim);
		scaled = TRUE;
	      }
	    }

	    /* otherwise we must reject, and warn the user */
	    if( !scaled )
	    { char num1[20], num2[20];
	      debug3(DGA, D, "  reject: vsize %s,%s in %s; y=",
		EchoLength(back(y, dim)), EchoLength(fwd(y, dim)),
		EchoConstraint(&c));
	      ifdebug(DGA, D, DebugObject(y));
	      if( size(y, dim) > 0 )
	      { sprintf(num1, "%.1fc", (float) size(y, dim) / CM);
	        sprintf(num2, "%.1fc", (float) bfc(c) / CM);
	        if( dim == ROWM )
		  Error(19, 12, "%s object too high for %s space; will try elsewhere",
		    WARN, &fpos(y), num1, num2);
	        else
		  Error(19, 13, "%s object too wide for %s space; will try elsewhere",
		    WARN, &fpos(y), num1, num2);
	      }
	      goto REJECT;
	    }

	  }

	  /* check availability of perpendicular space for first component */
	  if( dim == ROWM )
	  { perp_back = back(hd, 1-dim);  perp_fwd = fwd(hd, 1-dim);
	  }
	  else
	  { perp_back = back(y, 1-dim);  perp_fwd = fwd(y, 1-dim);
	  }
	  Constrained(dest, &c, 1-dim, &junk);
	  debug3(DGF, DD, "  dest perpendicular Constrained(%s, %s) = %s",
	    EchoObject(dest), dimen(1-dim), EchoConstraint(&c));
	  if( !FitsConstraint(perp_back, perp_fwd, c) )
	  { BOOLEAN scaled;

	    /* if forcing galley doesn't fit, try scaling first component */
	    scaled = FALSE;
	    if( force_gall(hd) && perp_back + perp_fwd > 0 )
	    { int scale_factor;
	      scale_factor = ScaleToConstraint(perp_back, perp_fwd, &c);
	      if( scale_factor > 0.5 * SF )
	      {	char num1[20], num2[20];
		sprintf(num1, "%.1fc", (float) (perp_back + perp_fwd) / CM);
		sprintf(num2, "%.1fc", (float) bfc(c) / CM);
		if( 1-dim == ROWM )
		  Error(19, 6, "%s object too high for %s space; %s inserted",
		    WARN, &fpos(y), num1, num2, KW_SCALE);
		else
		  Error(19, 7, "%s object too wide for %s space; %s inserted",
		    WARN, &fpos(y), num1, num2, KW_SCALE);
		y = InterposeScale(y, scale_factor, 1-dim);
		scaled = TRUE;
	      }
	    }

	    /* otherwise we must reject, and warn the user */
	    if( !scaled )
	    {
	      debug3(DGA, D, "  reject: vsize %s,%s in %s; y=",
		EchoLength(perp_back), EchoLength(perp_fwd),
		EchoConstraint(&c));
	      ifdebug(DGA, D, DebugObject(y));
	      goto REJECT;
	    }

	  }

	  /* dest seems OK, so perform its size adjustments */
	  debug0(DSA, D, "calling AdjustSize from AttachGalley (a)");
	  AdjustSize(dest, back(y, dim), fwd(y, dim), dim);
	  debug0(DSA, D, "calling AdjustSize from AttachGalley (b)");
	  AdjustSize(dest, perp_back, perp_fwd, 1-dim);


	  /* now check parallel space for target_galley in target */
	  Constrained(target, &c, dim, &why);
	  debug3(DGF, DD, "  target parallel Constrained(%s, %s) = %s",
	    EchoObject(target), dimen(dim), EchoConstraint(&c));
	  Child(z, LastDown(target_galley));  /* works in all cases? */
	  assert( !is_index(type(z)), "AttachGalley: is_index(z)!" );
	  assert( back(z, dim)>=0 && fwd(z, dim)>=0, "AttachGalley: z size!" );
	  if( !FitsConstraint(back(z, dim), fwd(z, dim), c) )
	  { BOOLEAN scaled;

	    debug2(DGA, D, "  why     = %d %s", (int) why, EchoObject(why));
	    debug2(DGA, D, "  limiter = %d %s", (int) limiter(hd),
	      EchoObject(limiter(hd)));

	    /* if forcing galley doesn't fit, try scaling z */
	    scaled = FALSE;
	    if( force_gall(hd) && size(z, dim) > 0 && limiter(hd) != why )
	    { int scale_factor;
	      scale_factor = ScaleToConstraint(back(z,dim), fwd(z,dim), &c);
	      if( scale_factor > 0.5 * SF )
	      {	char num1[20], num2[20];
		sprintf(num1, "%.1fc", (float) size(z, dim) / CM);
		sprintf(num2, "%.1fc", (float) bfc(c) / CM);
		if( dim == ROWM )
		  Error(19, 8, "%s object too high for %s space; %s inserted",
		    WARN, &fpos(y), num1, num2, KW_SCALE);
		else
		  Error(19, 9, "%s object too wide for %s space; %s inserted",
		    WARN, &fpos(y), num1, num2, KW_SCALE);
		z = InterposeWideOrHigh(z, dim);
		z = InterposeScale(z, scale_factor, dim);
		scaled = TRUE;
	      }
	    }

	    if( !scaled )
	    { char num1[20], num2[20];
	      limiter(hd) = why;
	      debug3(DGA, D, "  set limiter(%s) = %d %s", SymName(actual(hd)),
		(int) limiter(hd), EchoObject(limiter(hd)));
	      debug3(DGA, D, "  reject: size was %s,%s in %s; y =",
		EchoLength(back(z, dim)), EchoLength(fwd(z, dim)),
		EchoConstraint(&c));
	      ifdebug(DGA, D, DebugObject(y));
	      if( size(z, dim) > 0 )
	      { sprintf(num1, "%.1fc", (float) size(z, dim) / CM);
	        sprintf(num2, "%.1fc", (float) bfc(c) / CM);
	        if( dim == ROWM )
		  Error(19, 14, "%s object too high for %s space; will try elsewhere",
		    WARN, &fpos(y), num1, num2);
	        else
		  Error(19, 15, "%s object too wide for %s space; will try elsewhere",
		    WARN, &fpos(y), num1, num2);
	      }
	      goto REJECT;
	    }
	  }
	  limiter(hd) = why;
	  debug3(DGA, D, "  set limiter(%s) = %d %s", SymName(actual(hd)),
	    (int) limiter(hd), EchoObject(limiter(hd)));

	  /* now check perpendicular space for target_galley in target */
	  Constrained(target, &c, 1-dim, &junk);
	  debug3(DGF, DD, "  target perpendicular Constrained(%s, %s) = %s",
	    EchoObject(target), dimen(1-dim), EchoConstraint(&c));
	  Child(z, LastDown(target_galley));  /* works in all cases? */
	  assert( !is_index(type(z)), "AttachGalley: is_index(z)!" );
	  assert( back(z, 1-dim)>=0 && fwd(z, 1-dim)>=0,
	    "AttachGalley: z size (perpendicular)!" );
	  if( !FitsConstraint(back(z, 1-dim), fwd(z, 1-dim), c) )
	  { BOOLEAN scaled;

	    /* if forcing galley doesn't fit, try scaling z */
	    scaled = FALSE;
	    if( force_gall(hd) && size(z, 1-dim) > 0 )
	    { int scale_factor;
	      scale_factor = ScaleToConstraint(back(z,1-dim), fwd(z,1-dim), &c);
	      if( scale_factor > 0.5 * SF )
	      {	char num1[20], num2[20];
		sprintf(num1, "%.1fc", (float) size(z, 1-dim) / CM);
		sprintf(num2, "%.1fc", (float) bfc(c) / CM);
		if( 1-dim == ROWM )
		  Error(19, 10, "%s object too high for %s space; %s inserted",
		    WARN, &fpos(y), num1, num2, KW_SCALE);
		else
		  Error(19, 11, "%s object too wide for %s space; %s inserted",
		    WARN, &fpos(y), num1, num2, KW_SCALE);
		z = InterposeWideOrHigh(z, 1-dim);
		z = InterposeScale(z, scale_factor, 1-dim);
		scaled = TRUE;
	      }
	    }

	    if( !scaled )
	    {
	      debug3(DGA, D, "  reject: size was %s,%s in %s; y =",
		EchoLength(back(z, 1-dim)), EchoLength(fwd(z, 1-dim)),
		EchoConstraint(&c));
	      ifdebug(DGA, D, DebugObject(y));
	      goto REJECT;
	    }
	  }

	  /* target seems OK, so adjust sizes and accept */
	  if( external_hor(target) )
	  {
	    /* don't adjust any sizes, none to adjust */
	    debug0(DSA, D, "not calling AdjustSize from AttachGalley (c)");
	  }
	  else if( external_ver(target) )
	  {
	    /* adjust perp size only, to galley size */
	    debug0(DSA, D, "calling AdjustSize from AttachGalley (d)");
	    AdjustSize(target, back(target_galley, 1-dim),
	      fwd(target_galley, 1-dim), 1-dim);
	  }
	  else
	  {
	    /* adjust both directions, using z (last component) */
	    Child(z, LastDown(target_galley));
	    debug0(DSA, D, "AttachGalley AdjustSize using z =");
	    ifdebug(DSA, D, DebugObject(z));
	    debug0(DSA, D, "calling AdjustSize from AttachGalley (e)");
	    AdjustSize(target, back(z, dim), fwd(z, dim), dim);
	    debug0(DSA, D, "calling AdjustSize from AttachGalley (f)");
	    AdjustSize(target, back(z, 1-dim), fwd(z, 1-dim), 1-dim);
	  }

	  goto ACCEPT;


	default:
	    
	  assert1(FALSE, "AttachGalley:", Image(type(y)));
	  break;

      } /* end switch */
    } /* end for */

    /* null galley: promote whole galley without expanding the target */
    debug0(DGA, D, "  null galley");
    if( tg_inners != nilobj )  DisposeObject(tg_inners), tg_inners = nilobj;
    DisposeObject(target_galley);
    LeaveErrorBlock(FALSE);
    debug0(DYY, D, "] LeaveErrorBlock(FALSE) (null galley)");

    /* kill off any null objects within the galley, then transfer it */
    /* don't use Promote() since it does extra unwanted things here  */
    for( link = Down(hd);  link != hd;  link = NextDown(link) )
    { Child(y, link);
      switch( type(y) )
      {

	case GAP_OBJ:
	case CLOSURE:
	case CROSS:
	case FORCE_CROSS:
	case NULL_CLOS:
	case PAGE_LABEL:
	
	  link = PrevDown(link);
	  debug1(DGA, D, "  null galley, disposing %s", Image(type(y)));
	  DisposeChild(NextDown(link));
	  break;

	
	default:
	
	  break;
      }
    }
    TransferLinks(NextDown(hd), hd, Up(target_index));

    /* attach hd temporarily to target_index */
    MoveLink(Up(hd), target_index, PARENT);
    assert( type(hd_index) == UNATTACHED, "AttachGalley: type(hd_index)!" );
    DeleteNode(hd_index);

    /* return; only hd_inners needs to be flushed now */
    *inners = hd_inners;
    debug0(DGA, D, "] AttachGalley returning ATTACH_NULL");
    return ATTACH_NULL;


    REJECT:
	
      /* reject first component */
      /* debug1(DGA, D, "  reject %s", EchoObject(y)); */
      debug0(DGA, D, "  reject first component");
      LeaveErrorBlock(TRUE);
      debug0(DYY, D, "] LeaveErrorBlock(TRUE) (REJECT)");
      if( tg_inners != nilobj )  DisposeObject(tg_inners), tg_inners = nilobj;
      DisposeObject(target_galley);
      if( foll_or_prec(hd) == GALL_PREC && !sized(hd) )
      {
	/* move to just before the failed target */
	MoveLink(Up(hd_index), Up(target_index), PARENT);
      }
      else
      {
	/* move to just after the failed target */
	MoveLink(Up(hd_index), NextDown(Up(target_index)), PARENT);
      }
      continue;


    SUSPEND:
	
      /* suspend at first component */
      debug1(DGA, D, "  suspend %s", EchoIndex(y));
      blocked(y) = TRUE;
      LeaveErrorBlock(FALSE);
      debug0(DYY, D, "] LeaveErrorBlock(FALSE) (SUSPEND)");
      if( tg_inners != nilobj )  DisposeObject(tg_inners), tg_inners = nilobj;
      DisposeObject(target_galley);
      MoveLink(Up(hd_index), Up(target_index), PARENT);
      if( was_sized )
      { /* nothing new to flush if suspending and already sized */
	if( hd_inners != nilobj )  DisposeObject(hd_inners), hd_inners=nilobj;
	*inners = nilobj;
      }
      else
      { /* flush newly discovered inners if not sized before */
	*inners = hd_inners;
      }
      debug0(DGA, D, "] AttachGalley returning ATTACH_SUSPEND");
      *suspend_pt = y;
      return ATTACH_SUSPEND;


    ACCEPT:
	
      /* accept first component; now committed to the attach */
      debug3(DGA, D, "  accept %s %s %s", Image(type(y)), EchoObject(y),
	EchoFilePos(&fpos(y)));
      LeaveErrorBlock(TRUE);
      debug0(DYY, D, "] LeaveErrorBlock(TRUE) (ACCEPT)");

      /* attach hd to dest */
      MoveLink(Up(hd), dest_index, PARENT);
      assert( type(hd_index) == UNATTACHED, "AttachGalley: type(hd_index)!" );
      DeleteNode(hd_index);

      /* move first component of hd into dest */
      /* nb Interpose must be done after all AdjustSize calls */
      if( dim == ROWM && !external_ver(dest) )
	Interpose(dest, VCAT, hd, y);
      else if( dim == COLM && !external_hor(dest) )
      { Interpose(dest, ACAT, y, y);
	Parent(junk, Up(dest));
	assert( type(junk) == ACAT, "AttachGalley: type(junk) != ACAT!" );
	StyleCopy(save_style(junk), save_style(dest));
	adjust_cat(junk) = padjust(save_style(junk));
      }
      debug1(DGS, D, "calling Promote(hd, %s) from AttachGalley/ACCEPT",
	link == hd ? "hd" : "NextDown(link)");
      Promote(hd, link == hd ? hd : NextDown(link), dest_index, TRUE);

      /* move target_galley into target */
      /* nb Interpose must be done after all AdjustSize calls */
      if( !(external_ver(target) || external_hor(target)) )
      {	Child(z, LastDown(target_galley));
	Interpose(target, VCAT, z, z);
      }
      debug0(DGS, D, "calling Promote(target_galley) from AttachGalley/ACCEPT");
      Promote(target_galley, target_galley, target_index, TRUE);
      DeleteNode(target_galley);
      assert(Down(target_index)==target_index, "AttachGalley: target_ind");
      if( blocked(target_index) )  blocked(dest_index) = TRUE;
      DeleteNode(target_index);

      /* return; both tg_inners and hd_inners need to be flushed now;        */
      /* if was_sized, hd_inners contains the inners of the first component; */
      /* otherwise it contains the inners of all components, from SizeGalley */
      if( tg_inners == nilobj ) *inners = hd_inners;
      else if( hd_inners == nilobj ) *inners = tg_inners;
      else
      {	TransferLinks(Down(hd_inners), hd_inners, tg_inners);
	DeleteNode(hd_inners);
	*inners = tg_inners;
      }
      debug0(DGA, D, "] AttachGalley returning ATTACH_ACCEPT");
      ifdebug(DGA, D,
	if( dim == COLM && !external_hor(dest) )
	{ OBJECT z;
	  Parent(z, Up(dest));
	  debug2(DGA, D, "  COLM dest_encl on exit = %s %s",
	    Image(type(z)), EchoObject(z));
	}
      )
      return ATTACH_ACCEPT;

  } /* end for */
Beispiel #5
0
void		Node::addLink(Node &link, double scale, Road *road)
{
	_links.push_back(Link(link, this->distance(link, scale), road));
}
Beispiel #6
0
void RedditModel::FetchMoreFinished(QNetworkReply* reply) {
  is_fetching_more_ = false;

  if (reply->error() != QNetworkReply::NoError) {
    qLog(Warning) << "Error fetching links" << reply->url();
    no_more_links_ = true;
    return;
  }

  // Parse the JSON response
  QJson::Parser parser;
  QVariantMap data = parser.parse(reply).toMap();
  if (!data.contains("data") || !data["data"].toMap().contains("children")) {
    qLog(Warning) << "Error parsing link response" << reply->url();
    no_more_links_ = true;
    return;
  }

  QVariantList links = data["data"].toMap()["children"].toList();

  if (links.isEmpty()) {
    no_more_links_ = true;
    return;
  }

  QList<Link> new_links;
  int row = links_.count();
  foreach (const QVariant& link_variant, links) {
    QVariantMap link_data = link_variant.toMap();
    if (!link_data.contains("data"))
      continue;

    link_data = link_data["data"].toMap();

    Image image;
    image.InitFromJson(link_data);

    // Update the last seen name - this must be done before skipping anything
    // for the case that we skip all the images in this set.
    last_seen_name_ = image.reddit_name();

    // Skip self posts
    if (!show_self_posts_ && link_data["is_self"].toBool())
      continue;

    // Check if this image has been viewed before
    if (app_->image_backend()->FindImage(image, &image)) {
      if (image.is_viewed() && !show_viewed_images_)
        continue;
    }

    // Adjust the URL to get just the image if we can.
    image.set_reddit_url(ResolveUrl(image.reddit_url()));

    // Create a Link object
    new_links << Link(image);

    // Start fetching the thumbnail
    if (!image.reddit_thumbnail_url().scheme().isEmpty()) {
      qLog(Debug) << "Fetching thumbnail" << image.reddit_thumbnail_url();

      QNetworkReply* reply = network_->get(QNetworkRequest(image.reddit_thumbnail_url()));
      NewClosure(reply, SIGNAL(finished()),
                 this, SLOT(ThumbnailFinished(QNetworkReply*,int)),
                 reply, row);
    }
Beispiel #7
0
void EntityManager::InitEntity( boost::shared_ptr<CCopyEntity> pNewCopyEntPtr,
							 CCopyEntity *pParent,
							 BaseEntity *pBaseEntity,
							 CActorDesc* pPhysActorDesc )
{
	CCopyEntity* pNewCopyEnt = pNewCopyEntPtr.get();

	// Mark the entity as in use
	pNewCopyEnt->inuse = true;

	pNewCopyEnt->m_pSelf = pNewCopyEntPtr;

	pNewCopyEnt->pBaseEntity = pBaseEntity;
	BaseEntity& rBaseEntity = (*pBaseEntity);

	pNewCopyEnt->m_pStage = m_pStage;

	// set id and increment the counter
	pNewCopyEnt->m_ID = m_EntityIDConter++;

	// z-sort is disabled by default initialization
	// Entities that have translucent polygons have to turn on their copy entities'
	// 'BETYPE_USE_ZSORT' in InitCopyEntity()
	if( pNewCopyEnt->m_TypeID == CCopyEntityTypeID::ALPHA_ENTITY )
	{
		// For alpha entity, always use the  z-sorting
		pNewCopyEnt->RaiseEntityFlags( BETYPE_USE_ZSORT );
	}
	else
	{
		// Otherwise, disable z-sorting by default
		pNewCopyEnt->ClearEntityFlags( BETYPE_USE_ZSORT );
	}

	// set the glare type
	if( rBaseEntity.m_EntityFlag & BETYPE_GLARESOURCE )
	{
		pNewCopyEnt->RaiseEntityFlags( BETYPE_GLARESOURCE );
	}
	else if( rBaseEntity.m_EntityFlag & BETYPE_GLAREHINDER )
	{
		pNewCopyEnt->RaiseEntityFlags( BETYPE_GLAREHINDER );
	}

	// update world aabb
	pNewCopyEnt->world_aabb.TransformCoord( pNewCopyEnt->local_aabb, pNewCopyEnt->GetWorldPosition() );


	// link the new copy-entity to the top of 'm_pEntityInUse'
	if( m_pEntityInUse )
		pNewCopyEnt->SetNext( m_pEntityInUse );
	else
		pNewCopyEnt->SetNextToNull(); // first entity in the link list

	m_pEntityInUse = pNewCopyEntPtr;


	// set the created time of the entity
	pNewCopyEnt->m_CreatedTime = m_pStage->GetElapsedTime();

	// set parent entity
	pNewCopyEnt->m_pParent = pParent;
	if( pNewCopyEnt->m_pParent )
	{
		// 'pNewCopyEnt' is being created as a child of another copy entity
		pNewCopyEnt->m_pParent->AddChild( pNewCopyEnt->m_pSelf );	// establish link from the parent to this entity
	}

//	LOG_PRINT( "linking a copy entity of " + rBaseEntity.GetNameString() + " to the tree" );

	// link the new copy-entity to the entity-tree
	Link( pNewCopyEnt );

	// update light information
	if( pNewCopyEnt->Lighting() )
	{
		pNewCopyEnt->ClearLights();
//		UpdateLightInfo( pNewCopyEnt );

		pNewCopyEnt->sState |= CESTATE_LIGHT_INFORMATION_INVALID;
	}

	// create object for physics simulation
	if( pNewCopyEnt->GetEntityFlags() & BETYPE_RIGIDBODY )
	{
		CActor *pPhysActor = NULL;
		if( pPhysActorDesc )
		{
			pPhysActorDesc->WorldPose = pNewCopyEnt->GetWorldPose();// * pNewCopyEnt->GetActorLocalPose();
			pPhysActorDesc->BodyDesc.LinearVelocity = pNewCopyEnt->Velocity();

			// each entity has its own actor desc
			pPhysActor = m_pStage->GetPhysicsScene()->CreateActor( *pPhysActorDesc );
		}
		else if( pBaseEntity->GetPhysicsActorDesc().IsValid() )
		{
			// actor desc is defined by entity attributes
			CActorDesc actor_desc = pBaseEntity->GetPhysicsActorDesc();
			actor_desc.WorldPose = pNewCopyEnt->GetWorldPose();
			actor_desc.BodyDesc.LinearVelocity = pNewCopyEnt->Velocity();
//			pNewCopyEnt->pPhysicsActor = m_pStage->GetPhysicsScene()->CreateActor( actor_desc );
			pPhysActor = m_pStage->GetPhysicsScene()->CreateActor( actor_desc );
		}

		if( pPhysActor )
		{
			pNewCopyEnt->m_vecpPhysicsActor.resize( 1 );
			pNewCopyEnt->m_vecpPhysicsActor[0] = pPhysActor;
			pPhysActor->m_pFrameworkData = pNewCopyEnt;
		}
	}

	// When all the basic properties are copied, InitCopyEntity() is called to 
	// do additional initialization specific to each base entity.
	rBaseEntity.InitCopyEntity( pNewCopyEnt );
}
Beispiel #8
0
bool Parser::linkFromNode(const XMLNode& linkNode, Link& linkInfo)
{
  if (!linkNode.isElementNode() or (linkNode.getNameAsString() != "link"))
    return false;

  //link should not have any child nodes
  if (linkNode.hasChild())
    return false;

  const auto attributes = linkNode.getAttributes();
  if (attributes.empty())
  {
    std::cout << "Link element should have at least one attribute!" << std::endl;
    return false;
  } //if not enough attributes

  //initialize element with empty values
  linkInfo = Link();
  for (const auto& a : attributes)
  {
    const std::string attrName = a.first;
    if (attrName == "href")
    {
      if (!linkInfo.href().empty())
      {
        std::cout << "Link element already has a href value!" << std::endl;
        return false;
      } //if href was already specified
      linkInfo.setHref(a.second);
    } //if href
    else if (attrName == "rel")
    {
      if (!linkInfo.rel().empty())
      {
        std::cout << "Link element already has a rel attribute!" << std::endl;
        return false;
      } //if rel was already specified
      linkInfo.setRel(a.second);
    } //if rel
    else if (attrName == "type")
    {
      if (!linkInfo.type().empty())
      {
        std::cout << "Link element already has a type attribute!" << std::endl;
        return false;
      } //if type was already specified
      linkInfo.setType(a.second);
    } //if type
    else if (attrName == "hreflang")
    {
      if (!linkInfo.hreflang().empty())
      {
        std::cout << "Link element already has a hreflang attribute!" << std::endl;
        return false;
      } //if hreflang was already specified
      linkInfo.setHreflang(a.second);
    } //if hreflang
    else if (attrName == "title")
    {
      if (!linkInfo.title().empty())
      {
        std::cout << "Link element already has a title attribute!" << std::endl;
        return false;
      } //if title was already specified
      linkInfo.setTitle(a.second);
    } //if title
    else if (attrName == "length")
    {
      if (linkInfo.length() > 0)
      {
        std::cout << "Link element already has a length attribute!" << std::endl;
        return false;
      } //if length was already specified
      uint64_t tempUnsigned = 0;
      if (!stringToUnsignedInt<uint64_t>(a.second, tempUnsigned))
      {
        std::cout << "Length attribute of link element must have an integer value!" << std::endl;
        return false;
      }
      if (tempUnsigned == 0)
      {
        std::cout << "Length attribute of link element must not be zero!" << std::endl;
        return false;
      }
      linkInfo.setLength(tempUnsigned);
    } //if length
    else
    {
      std::cout << "Error: found unknown attribute " << a.first
                << " in <link> element of Atom 1.0 feed!" << std::endl;
      return false;
    }
  } //for
  //structure should not be empty
  return (!linkInfo.empty());
}
Beispiel #9
0
	RippleTexProg(GLuint ripple_tex_size)
	 : tex_1(prog(), "Tex1")
	 , tex_2(prog(), "Tex2")
	 , new_drop(prog(), "NewDrop")
	{
		AttachShader(VertexShader(
			ObjectDesc("Ripple texture vertex shader"),
			StrLit(
				"#version 330\n"
				"void main(void)"
				"{"
				"	gl_Position = vec4(0.0, 0.0, 0.0, 1.0);"
				"}"
			)
		));

		AttachShader(GeometryShader(
			ObjectDesc("Ripple texture geometry shader"),
			StrLit(
				"#version 330\n"
				"layout (points) in;"
				"layout (triangle_strip, max_vertices = 4) out;"

				"uniform int TexSize;"

				"out vec2 geomTexCoord;"

				"void make_vertex(vec2 pos, vec2 tc)"
				"{"
				"	gl_Position = vec4(pos, 0.0, 1.0);"
				"	geomTexCoord = tc;"
				"	EmitVertex();"
				"}"

				"void main(void)"
				"{"
				"	float rts = TexSize;"
				"	make_vertex(vec2(-1.0,-1.0), vec2(  0,   0));"
				"	make_vertex(vec2(-1.0, 1.0), vec2(  0, rts));"
				"	make_vertex(vec2( 1.0,-1.0), vec2(rts,   0));"
				"	make_vertex(vec2( 1.0, 1.0), vec2(rts, rts));"
				"	EndPrimitive();"
				"}"
			)
		));

		AttachShader(FragmentShader(
			ObjectDesc("Ripple texture fragment shader"),
			StrLit(
				"#version 330\n"

				"uniform ivec2 NewDrop;"
				"uniform sampler2D Tex1, Tex2;"
				"uniform int TexSize;"

				"in vec2 geomTexCoord;"

				"layout (location = 0) out vec4 fragBump;"
				"layout (location = 1) out float fragHeight;"

				"ivec2 wrap_tc(ivec2 tc)"
				"{"
				"	if(tc.x < 0) tc.x = TexSize-1;"
				"	if(tc.x >= TexSize) tc.x = 0;"
				"	if(tc.y < 0) tc.y = TexSize-1;"
				"	if(tc.y >= TexSize) tc.y = 0;"
				"	return tc;"
				"}"

				"float height_at(sampler2D tex, ivec2 tc, float factor)"
				"{"
				"	return texelFetch(tex, wrap_tc(tc), 0).r * factor;"
				"}"

				"void main(void)"
				"{"
				"	ivec2 TC = ivec2(geomTexCoord);"

				"	float  ch = height_at(Tex2, TC, 1.0);"
				"	float xp1 = height_at(Tex2, TC+ivec2( 1, 0), 0.25);"
				"	float xm1 = height_at(Tex2, TC+ivec2(-1, 0), 0.25);"
				"	float yp1 = height_at(Tex2, TC+ivec2( 0, 1), 0.25);"
				"	float ym1 = height_at(Tex2, TC+ivec2( 0,-1), 0.25);"

				"	fragHeight = xp1 + xm1 + yp1 + ym1;"
				"	fragHeight += height_at(Tex2, TC+ivec2( 1,-1), 0.25);"
				"	fragHeight += height_at(Tex2, TC+ivec2( 1, 1), 0.25);"
				"	fragHeight += height_at(Tex2, TC+ivec2(-1,-1), 0.25);"
				"	fragHeight += height_at(Tex2, TC+ivec2(-1, 1), 0.25);"
				"	fragHeight -= height_at(Tex1, TC, 1.0);"
				"	vec2 d = NewDrop - TC;"
				"	fragHeight += length(d)<8?1.0:0.0;"
				"	vec3 fragNormal = vec3("
				"		(xm1 - ch) + (ch - xp1),"
				"		(ym1 - ch) + (ch - yp1),"
				"		0.1"
				"	);"
				"	fragBump = vec4("
				"		normalize(fragNormal),"
				"		fragHeight"
				"	);"
				"}"
			)
		));

		Link();
		ProgramUniform<GLint>(prog(), "TexSize").Set(ripple_tex_size);
	}
Beispiel #10
0
	WaterProg(void)
	 : projection_matrix(prog(), "ProjectionMatrix")
	 , camera_matrix(prog(), "CameraMatrix")
	 , camera_position(prog(), "CameraPosition")
	 , light_position(prog(), "LightPosition")
	 , ripple_tex(prog(), "RippleTex")
	 , env_tex(prog(), "EnvTex")
	{
		AttachShader(VertexShader(
			ObjectDesc("Water vertex shader"),
			StrLit(
				"#version 330\n"

				"uniform mat4 ProjectionMatrix, CameraMatrix;"
				"uniform vec3 LightPosition, CameraPosition;"
				"mat4 Matrix = ProjectionMatrix*CameraMatrix;"

				"in vec3 Position;"
				"in vec3 Normal;"
				"in vec3 Tangent;"
				"in vec2 TexCoord;"

				"out vec3 vertNormal, vertTangent, vertBitangent;"
				"out vec3 vertLightDir, vertViewDir;"
				"out vec2 vertTexCoord;"

				"void main(void)"
				"{"
				"	gl_Position = Matrix * vec4(Position, 1.0);"
				"	vertNormal = Normal;"
				"	vertTangent = Tangent;"
				"	vertBitangent = cross(Normal, Tangent);"
				"	vertLightDir = LightPosition - Position;"
				"	vertViewDir = CameraPosition - Position;"
				"	vertTexCoord = TexCoord * 16.0;"
				"}"
			)
		));

		AttachShader(FragmentShader(
			ObjectDesc("Water fragment shader"),
			StrLit(
				"#version 330\n"

				"uniform sampler2D RippleTex;"
				"uniform samplerCube EnvTex;"

				"in vec3 vertNormal, vertTangent, vertBitangent;"
				"in vec3 vertLightDir, vertViewDir;"
				"in vec2 vertTexCoord;"

				"layout (location = 0) out vec4 fragColor;"

				"const vec3 LightColor = vec3(1.0, 1.0, 0.95);"
				"const vec3 BgColor = vec3(0.4, 0.4, 0.4);"

				"void main(void)"
				"{"
				"	vec4 texBump = texture(RippleTex, vertTexCoord);"
				"	vec3 fragNormal = normalize("
				"		texBump.x * vertTangent+"
				"		texBump.y * vertBitangent+"
				"		texBump.z * vertNormal"
				"	);"

				"	vec3 fragLightDir = normalize(vertLightDir);"
				"	vec3 fragLightRefl = reflect(-fragLightDir, fragNormal);"

				"	vec3 fragViewDir = normalize(vertViewDir);"
				"	vec3 fragViewRefl = reflect(-fragViewDir, fragNormal);"
				"	vec3 fragViewRefr = refract("
				"		-normalize(fragViewDir+vec3(0.0, 1.0, 0.0)),"
				"		fragNormal,"
				"		1.2"
				"	);"

				"	float Diffuse = max(dot(fragNormal, fragLightDir), 0.0);"
				"	float Specular = clamp(pow(dot(fragViewDir, fragLightRefl)+0.1, 64.0), 0.0, 2.0);"
				"	float Transparency = max(dot(fragNormal, fragViewDir)+0.3, 0.0);"

				"	float Visibility = min(16.0 / dot(vertViewDir, vertViewDir), 1.0);"

				"	vec3 SkyColor = texture(EnvTex, fragViewRefl).rgb;"
				"	vec3 GroundColor = texture(EnvTex, fragViewRefr).rgb;"

				"	vec3 WaterColor = "
				"		mix("
				"			0.7*SkyColor,"
				"			0.8*GroundColor*LightColor*Diffuse,"
				"			Transparency"
				"		)+"
				"		0.2*LightColor*Diffuse+"
				"		0.05*LightColor*Specular;"

				"	fragColor = vec4("
				"		mix(BgColor, WaterColor, Visibility),"
				"		1.0"
				"	);"
				"}"
			)
		));
		Link();
	}
Beispiel #11
0
inline void
LinkMove (short int ply, short int f,
          register short int t,
          short int flag,
          short int xside)

/*
 * Add a move to the tree.  Assign a bonus to order the moves as follows: 1.
 * Principle variation 2. Capture of last moved piece 3. Other captures
 * (major pieces first) 4. Killer moves 5.
 */

{
    register short s = 0;
#if defined HISTORY
    register short z;
#endif
    register unsigned short mv;
    register struct leaf *node;

    node = &Tree[*TrP];
    mv = (f << 8) | t;
#ifdef KILLT
    s += killt[mv | sidebit];
#endif
#ifdef HISTORY
    z = mv;
    if (xside == white) z |= 0x4000;
    s += history[z];
#endif
    if (color[t] != neutral)
    {
        /* TOsquare is the square the last piece moved moved to */
        s +=  value[board[t]] - board[f] + ((t == TOsquare) ? 500 : 0);
    }
    if (board[f] == pawn)
        if (row (t) == 0 || row (t) == 7)
        {
            flag |= promote;
            s += 800;
#if !defined OLDXBOARD  && !defined GNU3 && !defined CHESSTOOL
            Link (f, t, flag | queen, s - 20000);
            s -= 200;
            Link (f, t, flag | knight, s - 20000);
            s -= 50;
            Link (f, t, flag | rook, s - 20000);
            flag |= bishop;
            s -= 50;
#else
            flag |= queen;
#endif
        }
        else if (row (t) == 1 || row (t) == 6)
        {
            flag |= pwnthrt;
            s += 600;
        }
        else if ((row(t) == ((color[f] == white)?5:2)) && (ply > MINDEPTH) && (ply < Sdepth+3))
        {
            if ((mtl[white] - pmtl[white] + mtl[black] - pmtl[black]) < PTVALUE)
            {
                flag |= pwnthrt;
                s += 400;
            }
        }
    Link (f, t, flag, s - 20000);
}
Beispiel #12
0
void
CaptureList (register short int side, short int ply)

/*
 * Fill the array Tree[] with all available cature and promote moves for side
 * to play. Array TrPnt[ply] contains the index into Tree[] of the first move
 * at a ply.
 */

{
    register short u, sq, xside;
    register struct leaf *node;
    register unsigned char *ppos, *pdir;
    short i, piece, *PL, r7;

    xside = side ^ 1;
    TrP = &TrPnt[ply + 1];
    *TrP = TrPnt[ply];
    node = &Tree[*TrP];
    r7 = rank7[side];
    PL = PieceList[side];
#ifdef KILLT
    sidebit = ((side == white) ? 0 : 0x80);
    killt[SwagHt | sidebit] += 5000;
    killt[Swag0 | sidebit] += 2000;
    killt[Swag1 | sidebit] += 60;
    killt[Swag2 | sidebit] += 50;
    killt[Swag3 | sidebit] += 40;
    killt[Swag4 | sidebit] += 30;
#endif

    for (i = 0; i <= PieceCnt[side]; i++)
    {
        sq = PL[i];
        piece = board[sq];
        if (sweep[piece])
        {
            ppos = nextpos[piece][sq];
            pdir = nextdir[piece][sq];
            u = ppos[sq];
            do
            {
                if (color[u] == neutral)
                    u = ppos[u];
                else
                {
                    if (color[u] == xside)
                        Link (sq, u, capture, value[board[u]] + svalue[board[u]] - piece);
                    u = pdir[u];
                }
            } while (u != sq);
        }
        else
        {
            pdir = nextdir[ptype[side][piece]][sq];
            if (piece == pawn && row (sq) == r7)
            {
                u = pdir[sq];
                if (color[u] == xside)
                    Link (sq, u, capture | promote | queen, valueQ);
                u = pdir[u];
                if (color[u] == xside)
                {
                    Link (sq, u, capture | promote | queen, valueQ);
#if !defined OLDXBOARD  && !defined GNU3 && !defined CHESSTOOL
                    Link (sq, u, capture | promote | knight, valueN);
                    Link (sq, u, capture | promote | rook, valueR);
                    Link (sq, u, capture | promote | bishop, valueB);
#endif
                }
                ppos = nextpos[ptype[side][piece]][sq];
                u = ppos[sq];	/* also generate non capture promote */
                if (color[u] == neutral)
                {
                    Link (sq, u, promote | queen, valueQ);
#if !defined OLDXBOARD  && !defined GNU3 && !defined CHESSTOOL
                    Link (sq, u, promote | knight, valueN);
                    Link (sq, u, promote | rook, valueR);
                    Link (sq, u, promote | bishop, valueB);
#endif
                }
            }
            else
            {
                u = pdir[sq];
                do
                {
                    if (color[u] == xside)
                        Link (sq, u, capture, value[board[u]] + svalue[board[u]] - piece);
                    u = pdir[u];
                } while (u != sq);
            }
        }
    }
#ifdef KILLT
    sidebit = ((side == white) ? 0 : 0x80);
    killt[SwagHt | sidebit] -= 5000;
    killt[Swag0 | sidebit] -= 2000;
    killt[Swag1 | sidebit] -= 60;
    killt[Swag2 | sidebit] -= 50;
    killt[Swag3 | sidebit] -= 40;
    killt[Swag4 | sidebit] -= 30;
#endif
    SwagHt = 0;			/* SwagHt is only used once */
}
Beispiel #13
0
void
DisjointSet::Union(size_t x, size_t y)
{
	Link(FindSet(x), FindSet(y));
}
bool OGLIndexedDraw::Init(int windowWidth, int windowHeight)
{
    bool res = gs::Stage::Init(windowWidth, windowHeight);
    
    if (res) {
        res &= InitGUI();
        
		/******************************* Shaders ********************************/
		
        auto vertexShader = std::make_unique<gs::Shader>(GL_VERTEX_SHADER);
        auto fragmentShader = std::make_unique<gs::Shader>(GL_FRAGMENT_SHADER);
        auto program = std::make_shared<gs::Program>();
        
        vertexShader->SetSource("heightmap.vert");
        res &= vertexShader->Compile();
        fragmentShader->SetSource("heightmap.frag");
        res &= fragmentShader->Compile();
        
        program->Attach(vertexShader->get());
        program->Attach(fragmentShader->get());
		res &= program->Link();
        program->Use();
        
        programs.push_back(program);
        
        glm::mat4 MVP = projection * glm::lookAt(glm::vec3(0, 40, -30), glm::vec3(0), glm::vec3(0, 1, 0));
        GLint mvpLocation = glGetUniformLocation(program->get(), "MVP");
		glUniformMatrix4fv(mvpLocation, 1, GL_FALSE, glm::value_ptr(MVP));	

		hDivLocation = glGetUniformLocation(program->get(), "heightDivider");
        
		/******************************* Geometry ********************************/
        auto vao = std::make_unique<gs::VertexArray>();
        vao->BindVAO();
        vaos.push_back(std::move(vao));

		auto vbo = std::make_unique<gs::VertexBuffer>(GL_ARRAY_BUFFER);
		vbo->BindVBO();
		vbos.push_back(std::move(vbo));

		heights = { 4.0f, 2.0f, 3.0f, 1.0f,
					3.0f, 5.0f, 8.0f, 2.0f,
					7.0f, 10.0f, 12.0f, 6.0f,
					4.0f, 6.0f, 8.0f, 3.0f };

		const float halfX = WORLD_SIZE_X * 0.5f;
		const float halfZ = WORLD_SIZE_Z * 0.5f;

		for (size_t i = 0; i < HM_SIZE_Z; i++) {
			for (size_t j = 0; j < HM_SIZE_X; j++)
			{
				short currentLineOffset = (short)j * HM_SIZE_Z;

				float xPos = j / (float)(HM_SIZE_X - 1) * WORLD_SIZE_X - halfX;
				float yPos = heights[i + currentLineOffset];
				float zPos = i / (float)(HM_SIZE_Z - 1) * WORLD_SIZE_Z - halfZ;
				vertices[i + currentLineOffset] = glm::vec3(xPos, yPos, zPos);
			}
		}
		glBufferData(GL_ARRAY_BUFFER, sizeof(glm::vec3) * vertices.size(), vertices.data(), GL_STATIC_DRAW);

		/******************************* Indices ********************************/
		auto ibo = std::make_unique<gs::VertexBuffer>(GL_ELEMENT_ARRAY_BUFFER);
		ibo->BindVBO();
		vbos.push_back(std::move(ibo));

		const GLushort restartIndex = HM_SIZE_X * HM_SIZE_Z;
		indices = { 0, 4, 1, 5, 2, 6, 3, 7, restartIndex,
					4, 8, 5, 9, 6, 10, 7, 11, restartIndex,
					8, 12, 9, 13, 10, 14, 11, 15};
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLushort) * indices.size(), indices.data(), GL_STATIC_DRAW);

		glEnableVertexAttribArray(0);
		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr);

		glEnable(GL_PRIMITIVE_RESTART);
		glEnable(GL_DEPTH_TEST);
		glPrimitiveRestartIndex(restartIndex);
    }
    return res;
}
	void Touch (IBaseEntity *Other, SBSPPlane *plane, SBSPSurface *surf)
	{
		if (surf && (surf->Flags & SURF_TEXINFO_SKY))
		{
			Free ();
			return;
		}

		if (plane->Normal)
		{
			if (PointContents (State.GetOrigin().MultiplyAngles (-10.0f, plane->Normal)) & (CONTENTS_SLIME|CONTENTS_LAVA))
			{
				Explode ();
				return;
			}
		}

		bool DoneStick = true;

		if (Other->EntityFlags & EF_HURTABLE)
		{
			if (Other != Firer)
				Explode ();
			return;
		}
		else if (Other != World)
		{
			bool StickOK = false;
			//Here we need to check to see if we can stop on this entity.
			//Note that plane can be NULL

			//PMM - code stolen from g_phys (ClipVelocity)
			if (!plane->Normal) // this happens if you hit a point object, maybe other cases
			{
				Explode ();
				return;
			}

			if ((Other->EntityFlags & EF_PHYSICS) && (entity_cast<IPhysicsEntity>(Other)->PhysicsType == PHYSICS_PUSH) && (plane->Normal.Z > 0.7f))
				StickOK = true;

			float backoff = (Velocity | plane->Normal) * 1.5f;
			vec3f out;

			for (int i = 0; i < 3; i++)
			{
				float change = plane->Normal[i]*backoff;
				out[i] = Velocity[i] - change;
				if (out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON)
					out[i] = 0;
			}

			if (out[2] > 60)
				return;

			DoneStick = false;

			// if we're here, we're going to stop on an entity
			if (!StickOK) // no-stick.  teflon time
			{
				if (plane->Normal.Z > 0.7)
				{
					Explode();
					return;
				}
				return;
			}
		}
		else if (Other->State.GetModelIndex() != 1)
			return;

		if (PointContents (State.GetOrigin()) & (CONTENTS_LAVA|CONTENTS_SLIME))
		{
			Explode ();
			return;
		}

		vec3f dir = plane->Normal.ToAngles();

		CProxField *ProxField = QNewEntityOf CProxField;

		ProxField->State.GetOrigin() = State.GetOrigin();
		ProxField->GetMins().Set (-PROX_BOUND_SIZE);
		ProxField->GetMaxs().Set (PROX_BOUND_SIZE);
		ProxField->GetSolid() = SOLID_TRIGGER;
		ProxField->SetOwner(this);
		ProxField->ClassName = "prox_field";
		ProxField->Prox = this;
		ProxField->Link ();

		Velocity.Clear ();
		AngularVelocity.Clear ();

		// rotate to vertical
		dir.X += 90;
		State.GetAngles() = dir;
		CanTakeDamage = true;
		PhysicsType = (DoneStick) ? PHYSICS_NONE : PHYSICS_BOUNCE;		// either bounce or none, depending on whether we stuck to something
		Field = ProxField;
		Health = PROX_HEALTH;
		NextThink = Level.Frame + 1;
		ThinkType = PROXTHINK_OPEN;
		Touchable = false;
		GetSolid() = SOLID_BBOX;

		Link ();
	}
Beispiel #16
0
	void GLRestore() override {
		vshader->Compile(vshader->GetSource().c_str());
		fshader->Compile(fshader->GetSource().c_str());
		Link();
	}
Beispiel #17
0
void CDBLoger::Write(const char *pszMsg, const size_t iLens)
{
    bool bError = false;
    int64_t iPlayerID = *((int64_t *)pszMsg);
    short sType = *((short *)(pszMsg + sizeof(iPlayerID)));
    const char *pszBuffer = pszMsg + sizeof(sType) + sizeof(iPlayerID);
    size_t iBufLens = iLens - (sizeof(sType) + sizeof(iPlayerID));

    //▒ь├ч╝В▓ж
    std::string strNewTable = getTableNam();
    if (strNewTable != m_strTable)
    {
        if (createTable(strNewTable))
        {
            if (NULL != m_pStatement)
            {
                m_pStatement->finalize();
                m_pStatement = NULL;
            }

            m_strTable = strNewTable;
        }
    }

    //о┤лл
    try
    {
        if (NULL == m_pStatement)
        {
            m_pStatement = m_objLinker.compileStatement(Q_FormatStr("insert into %s(playerid,logtype, logtime, info) values (?,?,?,?);",
                m_strTable.c_str()).c_str());
        }

        m_pStatement->bindInt64(0, iPlayerID);
        m_pStatement->bindInt(1, sType);
        m_pStatement->bindInt64(2, time(NULL));
        m_pStatement->bindBlob(3, (const unsigned char *)pszBuffer, iBufLens);

        (void)m_pStatement->execDML();
    }
    catch(CQException &e)
    {
        Q_Printf("open mysql link error. code %d, messgae %s", 
            e.getErrorCode(), e.getErrorMsg());

        bError = true;
    }

    if (!bError)
    {
        return;
    }
    if (Check())
    {
        return;
    }

    if (NULL != m_pStatement)
    {
        m_pStatement->finalize();
        m_pStatement = NULL;
    }

    m_objLinker.close();
    (void)Link();
}
Beispiel #18
0
CNumFmt::CNumFmt(const CNumFmt& origin):
    base( origin ), m_numfmts( origin.m_numfmts )
{
Link();
}
Beispiel #19
0
bool EntityManager::MakeEntityTree(BSPTree* pSrcBSPTree)
{
//	Reset();

	vector<EntityNode> entity_tree;

	// allocate some memory in advance
	// not doing this may cause error in Release build
	entity_tree.reserve( 10000 );

	// create the new entity tree on the temporary node buffer entity_tree
	// - Do not copy the tree to m_paEntityTree until all the entities are unlinked
	MakeEntityNode_r(0, pSrcBSPTree, &entity_tree);

	if(entity_tree.size() == 0)
		return false;	// entity tree costruction failed

	entity_tree[0].sParent = -1;	// the root node has no parent

	// unlink all the entities from the current entity tree
	if( m_pEntityInUse )
	{
		for( CCopyEntity* pEntity = m_pEntityInUse.get();
			 pEntity != NULL;
			 pEntity = pEntity->m_pNextRawPtr )
		{
			pEntity->Unlink();
		}
	}

	// Do this AFTER all the entities are unlinked from the entity nodes
	SafeDeleteArray( m_paEntityTree );

	// copy the new tree
	m_NumEntityNodes = (int)entity_tree.size();
	m_paEntityTree = new EntityNode [ m_NumEntityNodes ];
	for(int i=0; i<m_NumEntityNodes; i++)
		m_paEntityTree[i] = entity_tree[i];

	entity_tree.clear();

	// set stage and entity set
	for(int i=0; i<m_NumEntityNodes; i++)
	{
		m_paEntityTree[i].m_pStage     = m_pStage;
		m_paEntityTree[i].m_pEntitySet = this;
	}


	// update entity tree of the render manager
	m_pRenderManager->UpdateEntityTree( m_paEntityTree, m_NumEntityNodes );

	WriteEntityTreeToFile( "debug/entity_tree - recreated the tree.txt" );

	// re-link all the entities to the new tree nodes
	if( m_pEntityInUse )
	{
		for( CCopyEntity* pEntity = m_pEntityInUse.get();
			 pEntity != NULL;
			 pEntity = pEntity->m_pNextRawPtr )
		{
			// added: 11:34 PM 5/25/2008
			// Do not re-link an entity if it has already been marked as 'not in use'
			// - Failure to do this leads to an invalid link in the entity tree node
			//   - Caused infinite loops in EntityNode::CheckPosition_r()
			if( !IsValidEntity( pEntity ) )
				continue;

			Link( pEntity );
		}
	}

	WriteEntityTreeToFile( "debug/entity_tree - re-linked entities to the tree.txt" );

	// re-link all the light entities to the new tree nodes
//	m_pLightEntityManager->RelinkLightEntities();

	return true;
}
Beispiel #20
0
CNumFmt::CNumFmt(ITNumFmtsFromTNumFmt& numfmts, const base& it):
    base( it ), m_numfmts( &numfmts )
{
Link();
}
Beispiel #21
0
void LinkControl ( int iChildControlID, int iParentControlID, int iParentIndex )
{
	Link ( iChildControlID, iParentControlID, iParentIndex );
}
Beispiel #22
0
bool CUserPageBuilder::Build(CWholePage* pWholePage)
{
	// introducing the players - these will point to the XML objects required
	// to construct a user page
	CPageUI			Interface(m_InputContext);
	CUser*			pViewer = NULL;
	CUser			Owner(m_InputContext);
	CGuideEntry		Masthead(m_InputContext);
	CForum			PageForum(m_InputContext);
	CForum			Journal(m_InputContext);
	CPostList		RecentPosts(m_InputContext);
	CArticleList	RecentArticles(m_InputContext);
	CArticleList	RecentApprovals(m_InputContext);
	CCommentsList	RecentComments(m_InputContext);
	CArticleSubscriptionList	SubscribedUsersArticles(m_InputContext);
	
	CTDVString	sSecretKey;
	int			iSecretKey = 0;
	int			iUserID = 0;		// the user ID in the URL
	bool		bRegistering = false;
	bool		bSuccess = true;	// our success flag

	// get the user ID from the URL => zero if not present
	// TODO: something appropriate if no ID provided	
	iUserID = m_InputContext.GetParamInt("UserID");
	// now get the secret key if there is one
	// we may need to process it so get it as a string
	if (m_InputContext.GetParamString("Key", sSecretKey))
	{
		// if the secret key start with "3D" we must strip this off
		// - it is caused by a mime encoding problem, 3D is the ascii hex for =
		if (sSecretKey.Find("3D") == 0)
		{
			sSecretKey =  sSecretKey.Mid(2);
		}
		iSecretKey = atoi(sSecretKey);
		if (iSecretKey > 0)
		{
			// if there is a secret key then it is a registration attempt
			bRegistering = true;
		}
	}
	// now give appropriate page depending on whether this is a registration or not
	if (bRegistering)
	{
//		CStoredProcedure* pSP = m_InputContext.CreateStoredProcedureObject();
		CTDVString sPageContent = "";
		CTDVString sPageSubject = "";
//		CTDVString sCookie;

		// check we got our SP okay
//		if (pSP == NULL)
//		{
//			bSuccess = false;
//		}
		// if so then call the activate user method, which should return us a nice
		// warm cookie if all goes well
//		if (bSuccess)
//		{
//			bSuccess = pSP->ActivateUser(iUserID, iSecretKey, &sCookie);
			// make sure cookie is not empty
//			if (sCookie.IsEmpty())
//			{
//				bSuccess = false;
//			}
//		}
		// if okay then build page with the cookie in and a message to the user
		if (bSuccess)
		{
			// we have a cookie and we are prepared to use it
			// TODO: what about the MEMORY tag?
			// TODO: put this in stylesheet? Deal with delayed refresh?
//			CTDVString sCookieXML = "<SETCOOKIE><COOKIE>" + sCookie + "</COOKIE></SETCOOKIE>";

//			sPageSubject = "Registration in process ...";
//			sPageContent << "<GUIDE><BODY>";
//			sPageContent << "<P>Thank you for registering as an official Researcher for The Hitch Hiker's ";
//			sPageContent << "Guide to the Galaxy: we do hope you enjoy contributing to the Guide.</P>";
//			sPageContent << "<P>Please wait while you are transferred to <LINK BIO=\"U" << iUserID << "\">";
//			sPageContent << "your Personal Home Page</LINK> ... or click the link if nothing happens.</P>";
//			sPageContent << "</BODY></GUIDE>";
//			pWholePage = CreateSimplePage(sPageSubject, sPageContent);
//			if (pWholePage == NULL)
//			{
//				bSuccess = false;
//			}

			if (bSuccess)
			{
				bSuccess = InitPage(pWholePage, "USERPAGE",false);
			}
			// put the cookie xml inside the H2G2 tag
//			bSuccess = pWholePage->AddInside("H2G2", sCookieXML);

//			CTDVString sUserXML = "";
//			sUserXML << "<REGISTERING-USER>";
//			sUserXML << "<USER>";
//			sUserXML << "<USERNAME></USERNAME>";
//			sUserXML << "<USERID>" << iUserID << "</USERID>";
//			sUserXML << "</USER>";
//			sUserXML << "</REGISTERING-USER>";
//			bSuccess = pWholePage->AddInside("H2G2", sUserXML);
//			bSuccess = bSuccess && pWholePage->SetPageType("REGISTER-CONFIRMATION");

		CTDVString sRedirect;
		sRedirect << "ShowTerms" << iUserID;
		sRedirect << "?key=" << sSecretKey;
		pWholePage->Redirect(sRedirect);
		}
		else
		{
			sPageSubject = "Sorry ...";
			sPageContent << "<GUIDE><BODY>";
			sPageContent << "<P>The URL you've given is wrong. Please re-check your email, or <LINK HREF=\"/Register\">click here to re-enter your email address</LINK>.</P>";
			sPageContent << "</BODY></GUIDE>";
			bSuccess = CreateSimplePage(pWholePage, sPageSubject, sPageContent);
		}
		// make sure we delete the SP if any
//		delete pSP;
//		pSP = NULL;
	}
	else
	{
		// get or create all the appropriate xml objects
		pViewer		= m_InputContext.GetCurrentUser();
		bool bGotMasthead = false; 
		bool bGotPageForum = false; 
		bool bGotJournal = false; 
		bool bGotRecentPosts = false; 
		bool bGotRecentArticles = false; 
		bool bGotRecentApprovals = false; 
		bool bGotRecentComments = false; 
		bool bGotSubscribedToUsersRecentArticles = false; 

		bool bGotOwner		= CreatePageOwner(iUserID, Owner);

		CreatePageTemplate(pWholePage);
		if (m_InputContext.IncludeUsersGuideEntryInPersonalSpace() || (m_InputContext.GetParamInt("i_uge") == 1) ||
			m_InputContext.IncludeUsersGuideEntryForumInPersonalSpace() || (m_InputContext.GetParamInt("i_ugef") == 1))
		{
			bGotMasthead = CreatePageArticle(iUserID, Owner, Masthead);

			if (m_InputContext.IncludeUsersGuideEntryForumInPersonalSpace() || (m_InputContext.GetParamInt("i_ugef") == 1))
			{
				// GuideEntry forum can not be returned if GuideEntry is not being returned.
				bGotPageForum = CreatePageForum(pViewer, Masthead, PageForum);
			}
		}

		bool bGotInterface = CreateUserInterface(pViewer, Owner, Masthead, Interface);
		
		// Only display other information if the page has a valid masthead
		if (bGotMasthead)
		{
			if (m_InputContext.IncludeJournalInPersonalSpace() || (m_InputContext.GetParamInt("i_j") == 1))
			{
				bGotJournal = CreateJournal(Owner, pViewer, Journal);
			}

			if (m_InputContext.IncludeRecentPostsInPersonalSpace() || (m_InputContext.GetParamInt("i_rp") == 1))
			{
				bGotRecentPosts = CreateRecentPosts(Owner, pViewer, RecentPosts);
			}

			if (m_InputContext.IncludeRecentCommentsInPersonalSpace() || (m_InputContext.GetParamInt("i_rc") == 1))
			{
				bGotRecentComments = CreateRecentComments(Owner, pViewer, RecentComments);
			}

			if (m_InputContext.IncludeRecentGuideEntriesInPersonalSpace() || (m_InputContext.GetParamInt("i_rge") == 1))
			{
				bGotRecentArticles = CreateRecentArticles(Owner, RecentArticles);
				bGotRecentApprovals = CreateRecentApprovedArticles(Owner, RecentApprovals);
			}

			if (m_InputContext.IncludeUploadsInPersonalSpace() || (m_InputContext.GetParamInt("i_u") == 1))
			{
				CTDVString sUploadsXML;
				CUpload Upload(m_InputContext);
				Upload.GetUploadsForUser(iUserID,sUploadsXML);
				pWholePage->AddInside("H2G2",sUploadsXML);
			}

			if (m_InputContext.IncludeRecentArticlesOfSubscribedToUsersInPersonalSpace() || (m_InputContext.GetParamInt("i_rasu") == 1))
			{
				bGotSubscribedToUsersRecentArticles = CreateSubscribedToUsersRecentArticles(Owner, m_InputContext.GetSiteID(), SubscribedUsersArticles); 
			}
		}

		// See if the user wants to swap to this site and change their masthead and journal (if it exists)
/*
	This feature is now redundant. There's no concept of a homesite.
		if (m_InputContext.ParamExists("homesite"))
		{
			if (pViewer == NULL)
			{
				// error: Not registered - ignore request
			}
			else if (!bGotOwner)
			{
				// error - no actual owner, ignore request
			}
			else if (pViewer->GetIsEditor())
			{
				int iCurrentSiteID = m_InputContext.GetSiteID();
				int iThisSite = iCurrentSiteID;
				if (bGotMasthead)
				{
					iCurrentSiteID = Masthead.GetSiteID();
				}
				if ( iThisSite != iCurrentSiteID && m_InputContext.CanUserMoveToSite(iCurrentSiteID, iThisSite))
				{
					CStoredProcedure SP;
					m_InputContext.InitialiseStoredProcedureObject(&SP);
					if (bGotMasthead)
					{
						SP.MoveArticleToSite(Masthead.GetH2G2ID(), m_InputContext.GetSiteID());
						//delete pMasthead;
						Masthead.Destroy();
						bGotMasthead = CreatePageArticle(iUserID, Owner, Masthead);
					}
					int iJournal;
					Owner.GetJournal(&iJournal);
					if (iJournal > 0)
					{
						SP.MoveForumToSite(iJournal, m_InputContext.GetSiteID());
					}

					int iPrivateForum;
					if (Owner.GetPrivateForum(&iPrivateForum))
					{
						SP.MoveForumToSite(iPrivateForum, m_InputContext.GetSiteID());
					}
					pWholePage->AddInside("H2G2", "<SITEMOVED RESULT='success'/>");
				}
			}
		}
*/
		// check that all the *required* objects have been created successfully
		// note that pViewer can be NULL if an unregistered viewer
		// pOwner can be NULL if we are serving a default page because this user ID
		// does not exist
		// bGotJournal can be false if the user doesn't exist, or has no journal
		// bGotRecentPosts can be false if the user doesn't exist
		// pRecentArticles can be NULL if the user doesn't exist
		// pRecentApprovals can be NULL if the user doesn't exist
		// bGotPageForum can be false if there is no masthead, or if it has no forum yet
		// pMasthead could be NULL if the user has not created one yet
		if (pWholePage->IsEmpty() || bGotInterface == false)
		{
			bSuccess = false;
		}
		// now add all the various subcomponents into the whole page xml
		// add owner of page
		if (bSuccess)
		{
			// if we have a page owner then put their details in, otherwise make
			// up a pretend user from the ID we were given
			if (bGotOwner)
			{
				bSuccess = pWholePage->AddInside("PAGE-OWNER", &Owner);
			}
			else
			{
				CTDVString sPretendUserXML = "";
				sPretendUserXML << "<USER><USERID>" << iUserID << "</USERID>";
				sPretendUserXML << "<USERNAME>Researcher " << iUserID << "</USERNAME></USER>";
				bSuccess = pWholePage->AddInside("PAGE-OWNER", sPretendUserXML);
			}
		}
		// there should always be an interface but check anyway
		if (bSuccess && bGotInterface)
		{
			bSuccess = pWholePage->AddInside("H2G2", &Interface);
		}
		if (bSuccess && m_InputContext.ParamExists("clip"))
		{
			CTDVString sSubject;
			if (bGotOwner)
			{
				Owner.GetUsername(sSubject);
			}
			else
			{
				sSubject << "U" << iUserID;
			}

			bool bPrivate = m_InputContext.GetParamInt("private") > 0;
			CLink Link(m_InputContext);
			if ( Link.ClipPageToUserPage("userpage", iUserID, sSubject, NULL, pViewer, bPrivate) )
				pWholePage->AddInside("H2G2", &Link);
		}
		// if masthead NULL stylesheet should do the default response
		if (bSuccess && bGotMasthead && (m_InputContext.IncludeUsersGuideEntryInPersonalSpace() || (m_InputContext.GetParamInt("i_uge") == 1)))
		{
			bSuccess = pWholePage->AddInside("H2G2", &Masthead);
		}
		// add page forum if there is one => this is the forum associated with
		// the guide enty that is the masthead for this user
		if (bSuccess && bGotPageForum && (m_InputContext.IncludeUsersGuideEntryForumInPersonalSpace() || (m_InputContext.GetParamInt("i_ugef") == 1)))
		{
			bSuccess = pWholePage->AddInside("H2G2", &PageForum);
		}
		// add journal if it exists
		if (bSuccess && bGotJournal)
		{
			bSuccess = pWholePage->AddInside("JOURNAL", &Journal);
		}
		// add recent posts if they exist, this may add an empty
		// POST-LIST tag if the user exists but has never posted
		if (bSuccess && bGotRecentPosts)
		{
			bSuccess = pWholePage->AddInside("RECENT-POSTS", &RecentPosts);
		}
		// add recent articles if they exist, this may add an empty
		// ARTICLES-LIST tag if the user exists but has never written a guide entry
		if (bSuccess && bGotRecentArticles)
		{
			bSuccess = pWholePage->AddInside("RECENT-ENTRIES", &RecentArticles);
			// add the user XML for the owner too
			if (bGotOwner)
			{
				bSuccess = bSuccess && pWholePage->AddInside("RECENT-ENTRIES", &Owner);
			}
		}
		// add recent articles if they exist, this may add an empty
		// ARTICLES-LIST tag if the user exists but has never had an entry approved
		if (bSuccess && bGotRecentApprovals)
		{
			bSuccess = pWholePage->AddInside("RECENT-APPROVALS", &RecentApprovals);
			// add the user XML for the owner too
			if (bGotOwner)
			{
				bSuccess = bSuccess && pWholePage->AddInside("RECENT-APPROVALS", &Owner);
			}
		}
		// add recent comments if they exist, this may add an empty
		// COMMENTS-LIST tag if the user exists but has never posted
		if (bSuccess && bGotRecentComments)
		{
			bSuccess = pWholePage->AddInside("RECENT-COMMENTS", &RecentComments);
		}

		if (bSuccess && bGotSubscribedToUsersRecentArticles)
		{
			bSuccess = pWholePage->AddInside("RECENT-SUBSCRIBEDARTICLES", &SubscribedUsersArticles);
		}

		CTDVString sSiteXML;
		m_InputContext.GetSiteListAsXML(&sSiteXML);
		bSuccess = bSuccess && pWholePage->AddInside("H2G2", sSiteXML);

		if (bGotMasthead && (m_InputContext.IncludeWatchInfoInPersonalSpace() || (m_InputContext.GetParamInt("i_wi") == 1)))
		{
			CWatchList WatchList(m_InputContext);
			bSuccess = bSuccess && WatchList.Initialise(iUserID);
			bSuccess = bSuccess && pWholePage->AddInside("H2G2",&WatchList);
			int iSiteID = m_InputContext.GetSiteID();
			bSuccess = bSuccess && WatchList.WatchingUsers(iUserID, iSiteID);
			bSuccess = bSuccess && pWholePage->AddInside("H2G2",&WatchList);
		}

		CWhosOnlineObject Online(m_InputContext);
		bSuccess = bSuccess && Online.Initialise(NULL, 1, true);
		bSuccess = bSuccess && pWholePage->AddInside("H2G2", &Online);

		if (bGotMasthead && (m_InputContext.IncludeClubsInPersonalSpace() || (m_InputContext.GetParamInt("i_c") == 1)))
		{
			if (pViewer != NULL && pViewer->GetUserID() == iUserID) 
			{
				CClub Club(m_InputContext);
				Club.GetUserActionList(iUserID, 0, 20);
				pWholePage->AddInside("H2G2", &Club);
			}

			// Now add all the clubs the user belongs to
			CCurrentClubs Clubs(m_InputContext);
			if (bSuccess && Clubs.CreateList(iUserID,true))
			{
				bSuccess = pWholePage->AddInside("H2G2",&Clubs);
			}
		}
		
		if (bGotMasthead && bSuccess && (m_InputContext.IncludePrivateForumsInPersonalSpace() || (m_InputContext.GetParamInt("i_pf") == 1)))
		{
			pWholePage->AddInside("H2G2", "<PRIVATEFORUM/>");
			CForum Forum(m_InputContext);
			int iPrivateForum = 0;
			if (bGotOwner)
			{
				Owner.GetPrivateForum(&iPrivateForum);
			}
			Forum.GetThreadList(pViewer, iPrivateForum, 10,0);
			pWholePage->AddInside("PRIVATEFORUM", &Forum);

			// Now check to see if the user has alerts set for their private forum
			if (bGotOwner)
			{
				CEmailAlertList Alert(m_InputContext);
				Alert.GetUserEMailAlertSubscriptionForForumAndThreads(iUserID,iPrivateForum);
				pWholePage->AddInside("PRIVATEFORUM", &Alert);
			}
		}

		if (bGotMasthead && bSuccess && (m_InputContext.IncludeLinksInPersonalSpace() || (m_InputContext.GetParamInt("i_l") == 1)))
		{
			CTDVString sLinkGroup;
			m_InputContext.GetParamString("linkgroup", sLinkGroup);
			if (bGotOwner && pViewer != NULL && Owner.GetUserID() == pViewer->GetUserID()) 
			{
				ManageClippedLinks(pWholePage);
			}
			if (bGotOwner)
			{
				CLink Link(m_InputContext);
				bool bShowPrivate = (pViewer != NULL && Owner.GetUserID() == pViewer->GetUserID());
				Link.GetUserLinks(Owner.GetUserID(), sLinkGroup, bShowPrivate);
				pWholePage->AddInside("H2G2", &Link);
				Link.GetUserLinkGroups(Owner.GetUserID());
				pWholePage->AddInside("H2G2", &Link);
			}
		}

		if (bGotMasthead && m_InputContext.IncludeTaggedNodesInPersonalSpace() || (m_InputContext.GetParamInt("i_tn") == 1))
		{
			//Get the Users Crumtrail - all the nodes + ancestors the user is tagged to .
			CCategory CCat(m_InputContext);
			if ( bSuccess && CCat.GetUserCrumbTrail(Owner.GetUserID()) )
			{
				bSuccess = pWholePage->AddInside("H2G2",&CCat);
			}
		}

		if (bSuccess && bGotMasthead)
		{
			CTDVString sPostCodeXML;
			CTDVString sNoticeXML;
			if (m_InputContext.IncludeNoticeboardInPersonalSpace() || (m_InputContext.GetParamInt("i_n") == 1) ||
				m_InputContext.IncludePostcoderInPersonalSpace() || (m_InputContext.GetParamInt("i_p") == 1))
			{
				if (pViewer != NULL)
				{
					// Insert the notice board information!
					CTDVString sPostCodeToFind;
					if(pViewer->GetPostcode(sPostCodeToFind))
					{
						int iSiteID = m_InputContext.GetSiteID();
						CNotice Notice(m_InputContext);
						if (!Notice.GetLocalNoticeBoardForPostCode(sPostCodeToFind,iSiteID,sNoticeXML,sPostCodeXML))
						{
							sNoticeXML << "<NOTICEBOARD><ERROR>FailedToFindLocalNoticeBoard</ERROR></NOTICEBOARD>";
						}
					}
					else
					{
						//if the user has not entered a postcode then flag an Notice Board error
						sNoticeXML << "<NOTICEBOARD><ERROR>UserNotEnteredPostCode</ERROR></NOTICEBOARD>";
					}
				}
				else
				{
					sNoticeXML << "<NOTICEBOARD><ERROR>UserNotLoggedIn</ERROR></NOTICEBOARD>";
				}

				if (m_InputContext.IncludeNoticeboardInPersonalSpace() || (m_InputContext.GetParamInt("i_n") == 1))
				{
					bSuccess = pWholePage->AddInside("H2G2",sNoticeXML);
				}
			}

			if (m_InputContext.IncludePostcoderInPersonalSpace() || (m_InputContext.GetParamInt("i_p") == 1))
			{
				// Insert the postcoder if it's not empty
				if (bSuccess && !sPostCodeXML.IsEmpty())
				{
					bSuccess = bSuccess && pWholePage->AddInside("H2G2",sPostCodeXML);
				}
			}
		}

		if (m_InputContext.IncludeSiteOptionsInPersonalSpace() || (m_InputContext.GetParamInt("i_so") == 1))
		{
			// Return SiteOption SystemMessageOn if set. 
			if (bSuccess && m_InputContext.IsSystemMessagesOn(m_InputContext.GetSiteID()))
			{
				CTDVString sSiteOptionSystemMessageXML = "<SITEOPTION><NAME>UseSystemMessages</NAME><VALUE>1</VALUE></SITEOPTION>"; 

				bSuccess = bSuccess && pWholePage->AddInside("H2G2",sSiteOptionSystemMessageXML);
			}
		}
		
/*
		Mark Howitt 11/8/05 - Removing the civic data from the user page as it is nolonger used by any sites.
							  The only place civic data is used now is on the postcoder page.

		//include civic data
		if (bSuccess)
		{
			if ( m_InputContext.GetSiteID( ) == 16 )
			{
				CTDVString sActualPostCode;				
				bool bFoundLocalInfo = false;
				// First check to see if there is a postcode in the URL
				if (m_InputContext.ParamExists("postcode"))
				{
					// Get the postcode and use this to display the noticeboard
					if (m_InputContext.GetParamString("postcode", sActualPostCode))
					{
						//dont do any validations
						bFoundLocalInfo = true;				
					}
				}

				//next if no postcode variable is included in URL
				//or if the specified postcode value is invalid 
				//or if the specified postcode value has no entries on the db				
				if (!bFoundLocalInfo)
				{
					// No postcode given, try to get the viewing users postcode if we have one.
					if (pViewer)
					{
						if (pViewer->GetPostcode(sActualPostCode))
						{
							if ( sActualPostCode.IsEmpty( ) == false)
							{
								//dont do any validations
								bFoundLocalInfo = true;
							}
						}							
					}
					else
					{
						//try session cookie, if any 
						CTDVString sPostCodeToFind;
						CPostcoder postcoder(m_InputContext);
						CTDVString sActualPostCode = postcoder.GetPostcodeFromCookie();
						if ( !sActualPostCode.IsEmpty() )
						{
							//dont do any validations
							bFoundLocalInfo = true;
						}
					}
				}

				if ( bFoundLocalInfo )
				{
					if (!sActualPostCode.IsEmpty())
					{
						bool bHitPostcode = false;
						CPostcoder cPostcoder(m_InputContext);
						cPostcoder.MakePlaceRequest(sActualPostCode, bHitPostcode);
						if (bHitPostcode)
						{
							CTDVString sXML = "<CIVICDATA POSTCODE='";
							sXML << sActualPostCode << "'/>";
							pWholePage->AddInside("H2G2", sXML);
							bSuccess = pWholePage->AddInside("CIVICDATA",&cPostcoder);
						}
					}
				}
			}
		}
*/
	}

	return bSuccess;
}
Beispiel #23
0
void CPathTrack::Activate( void )
{
	if ( !FStringNull( pev->targetname ) )		// Link to next, and back-link
		Link();
}
Beispiel #24
0
BOOL Octree::Insert(INT32 r, INT32 g, INT32 b)
{
	//CheckIntegrity();
	
	OctreeElement * pEl = GetElement(r, g, b);
	if (!pEl) return FALSE;

	// Insert any necessary intermediates
	while (pEl->Depth !=8)
	{
		OctreeElement * pNewEl = new OctreeElement;
		if (!pNewEl) return FALSE;
		pNewEl->Depth=pEl->Depth+1;
		INT32 halfwidth=(1<<(8 - pEl->Depth))>>1;
		INT32 R=pEl->R+halfwidth;
		INT32 G=pEl->G+halfwidth;
		INT32 B=pEl->B+halfwidth;

		pNewEl->R=(r>=R)?R:(pEl->R);
		pNewEl->G=(g>=G)?G:(pEl->G);
		pNewEl->B=(b>=B)?B:(pEl->B);

		INT32 child=((r>=R)?1:0)+((g>=G)?2:0)+((b>=B)?4:0);
		ERROR2IF(pEl->pChildren[child], FALSE, "Blurk! Octree element already has a child");
		pEl->pChildren[child]=pNewEl;
		pNewEl->pParent=pEl;

		Unlink(pEl);
		pEl->NumChildren++;
		Link(pEl);

		pEl=pNewEl;
		Link(pEl);
	
		//CheckIntegrity();
	}

	if (!pEl->Pixels) CurrentLeaves++;
	pEl->Pixels++;

	while (CurrentLeaves>MaxLeaves)
	{
		pEl=NULL;

		// Seatch deepest in the tree first ...
		for (INT32 d=8; (d>=0) && !pEl; d--)
		{
			// ... for an element with no children ...
			OctreeElement * plEl=ListHead[d][0];
			while (plEl && !pEl)
			{
				// ... which has a parent ...
				pEl=plEl->pParent;
				// ... whose children have no children themselves
				for (INT32 c=0; (c<8) && pEl; c++) if (pEl->pChildren[c] && pEl->pChildren[c]->NumChildren) pEl=NULL;
				plEl=plEl->pListNext;
			}
		}

		if (pEl)
		{
			Unlink(pEl);
			if (!pEl->Pixels) CurrentLeaves++;
			for (INT32 c=0; c<8; c++) if (pEl->pChildren[c])
			{
				pEl->Pixels+=pEl->pChildren[c]->Pixels;
				
				Unlink (pEl->pChildren[c]);
				pEl->NumChildren--;
				ERROR3IF(pEl->pChildren[c]->NumChildren, "OK, why have I been given an octree element with children?");
				delete pEl->pChildren[c];
				pEl->pChildren[c]=NULL;
				CurrentLeaves--;
			}
			Link(pEl);
			//CheckIntegrity();
		} else
		{
			ERROR3("Can't find a candidate for combining octree");
			break;
		}
	}
	
	return TRUE;
}
void Union(Parent *x, Parent *y)
  {
  Link(FindSet(x), FindSet(y));
  }
Beispiel #26
0
/* Union(S,x,y): faz a uniao das raizes das arvores de x e de y*/
void Union(tdisjointset *S, int x, int y) {
	/* Pseudo-code */
	//Link(Find_Set(x),Find_Set(y))
	Link(&S,Find_Set(&S, x),Find_Set(&S,y));
}
Beispiel #27
0
// This function does any needed initialization on the rendering
// context. 
void SetupRC()
{
    GLint success;
    const GLchar *vsStringPtr[1];
    const GLchar *fsStringPtr[1];

    GLchar vsString[] = 
        "void main(void)\n"
        "{\n"
        "    // This is our Hello World vertex shader\n"
        "    // notice how comments are preceded by '//'\n"
        "\n"
        "    // normal MVP transform\n"
        "    vec4 clipCoord = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
        "    gl_Position = clipCoord;\n"
        "\n"
        "    // Copy the primary color\n"
        "    gl_FrontColor = gl_Color;\n"
        "\n"
        "    // Calculate NDC\n"
        "    vec4 ndc = vec4(clipCoord.xyz, 0) / clipCoord.w;\n"
        "\n"
        "    // Map from [-1,1] to [0,1] before outputting\n"
        "    gl_FrontSecondaryColor = (ndc * 0.5) + 0.5;\n"
        "}\n";

    GLchar fsString[] = 
        "uniform float flickerFactor;\n"
        "\n"
        "void main(void)\n"
        "{\n"
        "    // Mix primary and secondary colors, 50/50\n"
        "    vec4 temp = mix(gl_Color, vec4(vec3(gl_SecondaryColor), 1.0), 0.5);\n"
        "\n"
        "    // Multiply by flicker factor\n"
        "    gl_FragColor = temp * flickerFactor;\n"
        "}\n";

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor4f(1.0f, 0.0f, 0.0f, 1.0f);

    // Make sure required functionality is available!
    if (!GLEE_VERSION_2_0 && (!GLEE_ARB_vertex_shader || 
                              !GLEE_ARB_fragment_shader || 
                              !GLEE_ARB_shader_objects || 
                              !GLEE_ARB_shading_language_100))
    {
        //gltPrintf(GLUT_BITMAP_9_BY_15, 0, 3, "GLSL extensions not available!");
        glutSwapBuffers();
        Sleep(2000);
        exit(0);
    }

    if (!GLEE_VERSION_1_4 && !GLEE_EXT_secondary_color)
    {
        //gltPrintf(GLUT_BITMAP_9_BY_15, 0, 3, "Neither OpenGL 1.4 nor GL_EXT_secondary_color");
        //gltPrintf(GLUT_BITMAP_9_BY_15, 1, 3, " extension is available!");
        glutSwapBuffers();
        Sleep(2000);
        exit(0);
    }

    // Black background
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
    glSecondaryColor3f(1.0f, 1.0f, 1.0f);

    // Hidden surface removal
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);

    glShadeModel(GL_SMOOTH);

    // Create shader objects and specify shader text
    vShader = glCreateShader(GL_VERTEX_SHADER);
    fShader = glCreateShader(GL_FRAGMENT_SHADER);
    vsStringPtr[0] = vsString;
    glShaderSource(vShader, 1, vsStringPtr, NULL);
    fsStringPtr[0] = fsString;
    glShaderSource(fShader, 1, fsStringPtr, NULL);

    // Compile shaders and check for any errors
    glCompileShader(vShader);
    glGetShaderiv(vShader, GL_COMPILE_STATUS, &success);
    if (!success)
    {
        GLchar infoLog[MAX_INFO_LOG_SIZE];
        glGetShaderInfoLog(vShader, MAX_INFO_LOG_SIZE, NULL, infoLog);
        //gltPrintf(GLUT_BITMAP_9_BY_15, 0, 0, "Error in vertex shader compilation!  Info log:");
        //gltPrintf(GLUT_BITMAP_HELVETICA_10, 2, 0, "%s", infoLog);
        glutSwapBuffers();
        Sleep(5000);
        exit(0);
    }
    glCompileShader(fShader);
    glGetShaderiv(fShader, GL_COMPILE_STATUS, &success);
    if (!success)
    {
        GLchar infoLog[MAX_INFO_LOG_SIZE];
        glGetShaderInfoLog(fShader, MAX_INFO_LOG_SIZE, NULL, infoLog);
        //gltPrintf(GLUT_BITMAP_9_BY_15, 0, 0, "Error in fragment shader compilation!  Info log:");
        //gltPrintf(GLUT_BITMAP_HELVETICA_10, 2, 0, "%s", infoLog);
        glutSwapBuffers();
        Sleep(5000);
        exit(0);
    }

    // Create program object, attach shaders, then link
    progObj = glCreateProgram();
    if (useVertexShader)
        glAttachShader(progObj, vShader);
    if (useFragmentShader)
        glAttachShader(progObj, fShader);

    Link(GL_TRUE);
}
Beispiel #28
0
void Union(int x,int y)
{
    Link(FindSet(x),FindSet(y));
}
Beispiel #29
0
void IsEltCentral::takeControl( )
{
  Trichotomy theAnswer = dontknow;
  Chars explanation;
  if ( ! displayInFE() || freeARCs() > 0 )
    if (nilpotentWP->state() == ComputationManager::TERMINATED){
      explanation = ": this follows from an inspection of a basis." ;
      theAnswer = nilpotentWP->isTrivial();
    }
  if (nilpotentWPInQuotients->state() == ComputationManager::TERMINATED)
    if (nilpotentWPInQuotients->isTrivial()==no){
      int retClass;
      theAnswer = nilpotentWPInQuotients->isTrivial(retClass);
      //@njz
      //      ostrstream msgTmp;
      std::ostrstream msgTmp;
      //
      msgTmp << ": because it's not central in lower central quotient of class " 
	     << retClass << ends;
      explanation = msgTmp.str();
    }
  if (theAnswer != dontknow){
      LogMessage msg( *this, theWord );
      msg << Name( theWord ) << " is ";
      if ( theAnswer == no ) msg << "not ";
      msg << "central in " << Name( Parent( theWord ) ) << explanation;
      msg.send();
      adminTerminate();     
      return;    
  }
  if ( ( theAnswer = theChecker.isTrivial() ) != dontknow ) {
    
    LogMessage msg( *this, theWord );
    msg << Name( theWord ) << " is ";
    if ( theAnswer == no ) msg << "not ";
    msg << "central in " << Name( Parent( theWord ) );
    
    Chars explanation = theChecker.getExplanation();
    if( explanation.length() > 0 )
      msg << " : " << explanation;
    
    msg << ".";
    msg.send();

    if( theChecker.haveDetails() ) {
      LogMessage msgLink( *this, theWord );
      msgLink << Link( Chars("Click here to see details of centrality problem "
			     "for ")
		       + Text(Name(theWord)) + 
		       Text("."),
		       "WordProblemDetails", 
		       theChecker.getDecompositionFileName()
		       );
      msgLink.send();
    }
    
    
    adminTerminate();
  } 
  else if ( ( theAnswer = genetic->areTrivial() ) != dontknow ) {
    
    Chars explanation = "according to the genetic algorithm";
    LogMessage msg( *this, theWord );
    msg << Name( theWord ) << " is central";
    msg << " : " << explanation << ".";
    msg.send();
    adminTerminate();
  }
 
  else if ( ( theAnswer = genetic->areTrivial() ) != dontknow ) {
    
    Chars explanation = "according to the genetic algorithm";
    LogMessage msg( *this, theWord );
    msg << Name( theWord ) << " is central";
    msg << " : " << explanation << ".";
    msg.send();
    adminTerminate();
  }
  else
    usedOneARC();
}
Beispiel #30
0
static int db_write_object(FILE * f, dbref i, int db_format, int flags)
{
	ATTR *a;
	char *got, *as;
	dbref aowner;
	int ca, aflags, save, j;
	BOOLEXP *tempbool;

	if(!(flags & V_ATRNAME))
		putstring(f, Name(i));
	putref(f, Location(i));
	if(flags & V_ZONE)
		putref(f, Zone(i));
	putref(f, Contents(i));
	putref(f, Exits(i));
	if(flags & V_LINK)
		putref(f, Link(i));
	putref(f, Next(i));
	if(!(flags & V_ATRKEY)) {
		got = atr_get(i, A_LOCK, &aowner, &aflags);
		tempbool = parse_boolexp(GOD, got, 1);
		free_lbuf(got);
		putboolexp(f, tempbool);
		if(tempbool)
			free_bool(tempbool);
	}
	putref(f, Owner(i));
	if(flags & V_PARENT)
		putref(f, Parent(i));
	if(!(flags & V_ATRMONEY))
		putref(f, Pennies(i));
	putref(f, Flags(i));
	if(flags & V_XFLAGS)
		putref(f, Flags2(i));
	if(flags & V_3FLAGS)
		putref(f, Flags3(i));
	if(flags & V_POWERS) {
		putref(f, Powers(i));
		putref(f, Powers2(i));
	}
	/*
	 * write the attribute list 
	 */

	if((!(flags & V_GDBM)) || (mudstate.panicking == 1)) {
		for(ca = atr_head(i, &as); ca; ca = atr_next(&as)) {
			save = 0;
			a = atr_num(ca);
			if(a)
				j = a->number;
			else
				j = -1;

			if(j > 0) {
				switch (j) {
				case A_NAME:
					if(flags & V_ATRNAME)
						save = 1;
					break;
				case A_LOCK:
					if(flags & V_ATRKEY)
						save = 1;
					break;
				case A_LIST:
				case A_MONEY:
					break;
				default:
					save = 1;
				}
			}
			if(save) {
				got = atr_get_raw(i, j);
				fprintf(f, ">%d\n", j);
				putstring(f, got);
			}
		}
		fprintf(f, "<\n");
	}
	return 0;
}