Re: Restricting possible connections



On Wed, 23 Oct 2002, Mike Garnsey wrote:
I have been experimenting with doing something
like that, too.  Why?  I want to be able to have a set
of "idiot-proof" objects for a Dia user to lay out a
computer network diagram.  For example, the user
shouldnt be able to connect something like a PC object
directly to something like a microwave transmitter
object.  Or, a USB printer object shouldnt be
connectable to a 10BaseT repeater object.

I see.  I suppose idiot-proofness is good, as long as it doesn't restrict
what people want to do.

I had pretty good success with the following (crude!)
approach:
  1. hack diagram_update_connections_object()
     to force a redraw of the connected object

  2. for specific objects that you want restricted
     connection functionality, add code to the
     DrawFunc routine to analyze (and disconnect
     as appropriate) the objects that are 
     connected. 

Definitely not ideal (DrawFunc gets fired for a
variety of reasons), but it worked.

The right place to add a checking call would be in
layer_find_closest_connectionpoint() in app/diagramdata.c.  Problem is,
that loop goes over all objects in a layer, so we can't afford to spend a
lot of time there.  Well, we can keep it within the if, that'll cut out
most of it.  And instead of adding code to DrawFunc, a new object func
should be defined for it.

-Lars

-- 
Lars Clausen (http://shasta.cs.uiuc.edu/~lrclause)| Hårdgrim of Numenor
"I do not agree with a word that you say, but I   |----------------------------
will defend to the death your right to say it."   | Where are we going, and
    --Evelyn Beatrice Hall paraphrasing Voltaire  | what's with the handbasket?



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]