Re: [Pythoncad-developer] Added command line support
CAD Application entire developed in Python
Status: Beta
Brought to you by:
matteoboscolo
From: Matteo B. <mat...@bo...> - 2010-04-08 06:44:16
|
Hi Gertwin, > What if the user switches document in the middle of a getCommand? > Is the command canceled? The command have a pointer to the pycadkernel(document) .. When the user interface ask for a command the document application give at the user interface the complete control at the command.. It's the command that give the apply to perform the end of the command The application provide this event to help the user interface to understand what the application is doing .. You can have more then one command pending for apply at the some time .. And the kernel dose not care .. self.startUpEvent=PyCadkernelEvent() self.beforeOpenDocumentEvent=PyCadkernelEvent() self.afterOpenDocumentEvent=PyCadkernelEvent() self.beforeCloseDocumentEvent=PyCadkernelEvent() self.afterCloseDocumentEvent=PyCadkernelEvent() self.activeteDocumentEvent=PyCadkernelEvent() If the user switch a document the activeteDocumentEvent event is fired .. so it's up to you to decide in witch way the user interface use this method. For my point of view have the command still active even if we switch the document it's quite complex to manage .. But you have a lot of flexibility .. What do you think ? Regards, Matteo > > > > 2010/4/7 Matteo Boscolo <mat...@bo...>: > > Hi Gertwin, > > > > The new application class have some more feature now .. > > > > setActiveDocument > > openDocument > > closeDocument > > getActiveDocuent > > getDocuments > > > > All this feature allows you to open more than one document at the some > > time .. > > > > The command given from the getCommand works on the active document .. > > > > I need to do more test to see if it works properly .... > > > > > > > > Regards, > > Matteo > > > > > >> > >> > >> 2010/4/3 Matteo Boscolo <mat...@bo...>: > >> > Hi Gertwin, > >> > > >> > > >> >> I agree, the function parser is part of the kernel, not the interface. > >> >> I will look at the test_kernel.py for the drawing command structure. > >> > Could you make it part of the pycadapplication ? > >> > > >> >> We must also define a way to get information from the user, picking > >> >> points, selection etc. > >> > My command is an iterable object each element can rise an exception and > >> > tells you witch kind of data the command need .. > >> > This is a piece of code that show you how it works > >> > > >> > cObject=self.__pyCadApplication.getCommand(cmd_Key) # Get The command > >> > for iv in cObject: > >> > try: > >> > raise iv(None) #raise the exception > >> > except ExcPoint: #catch the exception > >> > cObject[iv]=self.imputPoint() #do the job in this > >> > case ask to the user to imput a point from the io > >> > ... > >> > ... > >> > at the end.. > >> > else: > >> > cObject.applyCommand() #apply the command > >> > > >> > I need add the description method at the item exception .. > >> > so we can have the description from the given request... > >> > I let you know how it works as soon I have done the implementation.. > >> > > >> > Do you have any experience in localization with python ? > >> > > >> >> My idea was to do this all by the function parser. > >> > I think that your function parser can parse the input from the user > >> > (menus,textInput,keybord command..) > >> > and call my getcommand to know witch kind of input to ask to the user to > >> > perform the given command > >> > Example: > >> > the user write the Segment command from the input box: > >> > the getCommand return a Segment command > >> > the parser look at the input parameter and ask at the user to give that > >> > request data .. > >> > at the end the parser apply the command > >> > you can fire some event for asking think to the userInterface. > >> > > >> > The user interface will be attached at this event and perform the action > >> > required from the user and from the pycadapplication .. > >> > > >> >> If we define a set of states (pick point, select object, etc.), on > >> >> each mouse move the interface can check the state and react on this. > >> >> > >> >> I agree about the class diagram, we should interact with more people > >> >> on the team. > >> >> If you know some kind of tool to generate class diagrams, we can put > >> >> them on the new wiki. > >> > I'm Working on it .. I'm trying http://epydoc.sourceforge.net/ pakage and let you know.. > >> > > >> > Regards, > >> > Matteo > >> > > >> >> Regards, > >> >> Gertwin > >> >> > >> >> 2010/4/2 Matteo Boscolo <mat...@bo...>: > >> >> > Hi Gertwin, > >> >> > > >> >> > I sow your command line and it working well .. no bugs found .. > >> >> > Could we implement a Multi text viewer where pythoncad put the output > >> >> > If the command succeed say .. "o boy .. well done :-)" > >> >> >> The idea is that every module can register commands that it can handle. > >> >> > I like this idea, but I wold like that the interpret stay under kernel > >> >> > (pycadapplication) > >> >> > > >> >> > I had made some modification at the pythoncad structure .. > >> >> > > >> >> > now the main api file is not pycadkernel but pycadapplication ... > >> >> > > >> >> > I made this change to support the new command class .. > >> >> > This class have not the some functionality of your and is not intend to > >> >> > replace you class .. it's a generic api file in witch all the gui interface > >> >> > are interfaced .. > >> >> > > >> >> > This class will provide hight level functionality to perform drawing > >> >> > operation. > >> >> > for now I have implemented only the getCommand method .. > >> >> > this method give to you the command object so you can fill it with the > >> >> > needed value and perform the applyCommand method to apply the command.. > >> >> > > >> >> > The following line will sow to you an exsample. > >> >> > > >> >> > cObject=pyCadApplication.getCommand("segment") > >> >> > > >> >> > for iv in cObject: #<<-- Loop for all the needed value > >> >> > try: > >> >> > raise iv(None) #<<-- Raise the exception of the needed value > >> >> > except ExcPoint: #<<-- if it's a point came here > >> >> > cObject[iv]=self.imputPoint() #<<--This is my io text imput But > >> >> > could be a function that ask to the user to pick a point > >> >> > except ExcLenght: > >> >> > cObject[iv]=self.inputMsg("Insert A Distance/Radius") > >> >> > except ExcAngle: > >> >> > cObject[iv]=self.inputMsg("Insert An angle") > >> >> > except: > >> >> > print "Bad error !!" > >> >> > raise > >> >> > else: > >> >> > cObject.applyCommand() #<<-- applay the command if all the data are > >> >> > right. > >> >> > > >> >> > you can find a working test if you run the test_kernel.py > >> >> > > >> >> > I intend to provide all the drawing command with this method .. > >> >> > > >> >> > > >> >> > Let me know what you are thinking about it.. > >> >> > I think that your function Parser should be part of the pycadapplication and > >> >> > not part of the interface ..so let me know if you fill the some > >> >> > > >> >> > At this stage there is a lot of code written ..so for my point of view we > >> >> > have to make a class diagram and start to discuss at the new class structure > >> >> > ..so our work can be more profitable. > >> >> > > >> >> > > >> >> > Regards, > >> >> > Matteo > >> >> > > >> >> > On Wed, 2010-03-31 at 23:26 +0200, Gertwin Groen wrote: > >> >> > > >> >> > Hi Matteo, > >> >> > > >> >> > I have just pushed my latest version to git. > >> >> > It has preliminary support for a command line interface with a very > >> >> > very simple command interpreter. > >> >> > > >> >> > The idea is that every module can register commands that it can handle. > >> >> > Also I changed the menu structure, it also works by sending commands > >> >> > to the command interpreter. > >> >> > > >> >> > For now the program understands command like (case insensitive): > >> >> > OPEN > >> >> > REBUILD_IX > >> >> > QUIT > >> >> > REGEN > >> >> > REDRAW > >> >> > ZOOMA > >> >> > > >> >> > I think this is better than the R37 version because command line and > >> >> > menu was handled different. > >> >> > If you have some comments on this, please let me know. > >> >> > > >> >> > I did not test it much, so be prepared for bugs. > >> >> > > >> >> > Regards, > >> >> > Gertwin > >> >> > > >> >> > > >> >> > > >> >> > >> > > >> > > >> > > >> > > > > > > > |