Re: Restricting possible connections
Just to throw in my two pence Please allow the user to override any such restrictions. The users must be in control, although i am not suggesting you make it easy for people to do the "wrong thing" you just have to make sure it is possible for the situations when the user really does know better. The should be strong recommendations not really restrictions if you understand what i am getting at. Is this similar to locked/protected shapes in other vector programs? Please tell me how other programs achieve the results you are trying to achieve (or failing that please explain in more detail what exactly it is so that i can understand and provide useful compartive information). Sincerely Alan Horkan http://advogato.org/person/AlanHorkan/ On Wed, 23 Oct 2002, Mike Garnsey wrote: > Date: Wed, 23 Oct 2002 22:29:16 -0700 (PDT) > From: Mike Garnsey <[EMAIL PROTECTED]> > Reply-To: [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > Subject: Re: Restricting possible connections > ___ Dia-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/dia-list FAQ at http://www.lysator.liu.se/~alla/dia/faq.html Main page at http://www.lysator.liu.se/~alla/dia
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? ___ Dia-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/dia-list FAQ at http://www.lysator.liu.se/~alla/dia/faq.html Main page at http://www.lysator.liu.se/~alla/dia
Re: Restricting possible connections
On Thu, Oct 24, 2002 at 12:21:22PM -0500, Lars Clausen wrote: > On Thu, 24 Oct 2002, [EMAIL PROTECTED] wrote: > > 2. Of course, this must be an option to the user. Maybe a > >diagram specific or a global option? > > Hmmm... good question. Global options are easier to make and do away > with. I really don't know which is better. Let's go for a global option first, and make it more advanced if the need is there. Other idea: Allow user the connection always if a modifier key is used (Escape/ Meta/Alt/Control/Shift). > > 3. The method to check has to be a new object function. > >Something like: > > > >typedef gboolean (*AllowConnectFunc) (Object* obj_me, > > Object* obj_other, > > ... /* ? */ ); > > You may want to give the handle and connection point to the function. > Could be some objects will allow objects to connect in certain ways and not > in others. Absolutely true. typedef gboolean (*AllowConnectFunc) (Object* obj_me, Object* obj_other, Handle* handle, ConnectionPoint* conpoint); Cheers! ___ Dia-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/dia-list FAQ at http://www.lysator.liu.se/~alla/dia/faq.html Main page at http://www.lysator.liu.se/~alla/dia
Re: Restricting possible connections
On Thu, 24 Oct 2002, [EMAIL PROTECTED] wrote: > On Thu, Oct 24, 2002 at 09:23:48AM -0500, Lars Clausen wrote: >> 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. > > OK, I try to resume: > > 1. A restriction on possible connections seems to be a good >idea. Think of network diagrams, not to speak of >UML/Database/SDL/... code generation. > > 2. Of course, this must be an option to the user. Maybe a >diagram specific or a global option? Hmmm... good question. Global options are easier to make and do away with. I really don't know which is better. > 3. The method to check has to be a new object function. >Something like: > >typedef gboolean (*AllowConnectFunc) (Object* obj_me, > Object* obj_other, > ... /* ? */ ); You may want to give the handle and connection point to the function. Could be some objects will allow objects to connect in certain ways and not in others. > 4. This function will be called twice (once for the >connecting object, once for the connected one) from >layer_find_closest_connectionpoint(). I don't see >performance hits, if functions will be called after >the "if (disthttp://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? ___ Dia-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/dia-list FAQ at http://www.lysator.liu.se/~alla/dia/faq.html Main page at http://www.lysator.liu.se/~alla/dia
Re: Restricting possible connections
On Thu, Oct 24, 2002 at 09:23:48AM -0500, Lars Clausen wrote: > 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. OK, I try to resume: 1. A restriction on possible connections seems to be a good idea. Think of network diagrams, not to speak of UML/Database/SDL/... code generation. 2. Of course, this must be an option to the user. Maybe a diagram specific or a global option? 3. The method to check has to be a new object function. Something like: typedef gboolean (*AllowConnectFunc) (Object* obj_me, Object* obj_other, ... /* ? */ ); 4. This function will be called twice (once for the connecting object, once for the connected one) from layer_find_closest_connectionpoint(). I don't see performance hits, if functions will be called after the "if (disthttp://mail.gnome.org/mailman/listinfo/dia-list FAQ at http://www.lysator.liu.se/~alla/dia/faq.html Main page at http://www.lysator.liu.se/~alla/dia