Leaderboard
Popular Content
Showing content with the highest reputation on 06/20/24 in all areas
-
Serialize/Deserialize Enums with no RTTI
Uwe Raabe replied to Larry Hengen's topic in RTL and Delphi Object Pascal
I know, that probably won't solve your problem, but I usually get rid of these kind of enumerations in favor of proper ones supported by RTTI. The numerical values are handles by record helpers: type TReportTypeCode = (reportTypeCodeSTR, reportTypeCodeLCTR, reportTypeCodeCDR, reportTypeCodeLVCTR, reportTypeCodeEFTR); TReportTypeCodeHelper = record helper for TReportTypeCode private const cMapping: array[TReportTypeCode] of Integer = (102, 106, 113, 14, 145); function GetAsInteger: Integer; procedure SetAsInteger(const Value: Integer); public property AsInteger: Integer read GetAsInteger write SetAsInteger; end; function TReportTypeCodeHelper.GetAsInteger: Integer; begin Result := cMapping[Self]; end; procedure TReportTypeCodeHelper.SetAsInteger(const Value: Integer); begin for var idx := Low(Self) to High(Self) do begin if cMapping[idx] = Value then begin Self := idx; Exit; end; end; raise EInvalidOperation.Create('invalid Integer value for TReportTypeCode'); end; Now there is no more casting to and from Integers. -
Delphi Help Expert
-
The code is a real crap, I'm just trying the right way to get the thing working, but Python + DelphiVCL + VTK looks like it could go. from delphivcl import * from vtkmodules.vtkRenderingCore import vtkRenderWindow from vtkmodules.vtkRenderingUI import vtkGenericRenderWindowInteractor BASE_CLASS_NAME = WinControl class vclVTKRenderWindowInteractor(BASE_CLASS_NAME): def __init__(self, owner): BASE_CLASS_NAME.__init__(self, owner) self._RenderWindow = None self._Iren = None def __getattr__(self, attr): """Makes the object behave like a vtkGenericRenderWindowInteractor""" if attr == '__vtk__': return lambda t=self._Iren: t elif hasattr(self._Iren, attr): return getattr(self._Iren, attr) else: raise AttributeError(self.__class__.__name__ + " has no attribute named " + attr) def GetRenderWindow(self): if self._RenderWindow is None: hwnd = self.Handle self._RenderWindow = vtkRenderWindow() self._RenderWindow.SetWindowInfo(str(int(hwnd))) self._Iren = vtkGenericRenderWindowInteractor() self._Iren.SetRenderWindow(self._RenderWindow) return self._RenderWindow def Render(self): self.update() def vclVTKRenderWindowInteractorConeExample(): """A simple example that uses the vclVTKRenderWindowInteractor class.""" from vtkmodules.vtkFiltersSources import vtkConeSource from vtkmodules.vtkRenderingCore import vtkActor, vtkPolyDataMapper, vtkRenderer import vtkmodules.vtkRenderingOpenGL2 import vtkmodules.vtkInteractionStyle class MainView(Form): def __init__(self, owner): self.vtk_panel = vclVTKRenderWindowInteractor(self) self.vtk_panel.Parent = self self.vtk_panel.Align = 'alClient' self.vtk_panel.AlignWithMargins = True self.vtk_panel.BevelInner = 'bvNone' self.vtk_panel.BevelKind = 'bkFlat' self.vtk_panel.BevelOuter = 'bvNone' self.vtk_panel.Color = clCream self.vtk_panel.ParentBackground = False self.vtk_panel.Caption = 'Hello World!' # set main form events handlers self.OnClose = self.__on_form_close def __on_form_close(self, sender, action): if sender is None: return if sender == self: action.Value = caFree # initialize application Application.Initialize() Application.Title = "" # create and show view view = MainView(Application) try: def on_timer(Sender): coneActor.RotateX(10) coneActor.RotateY(5) coneActor.RotateY(2.5) widget.GetRenderWindow().Render() timer.interval = 100 view.Show() widget = view.vtk_panel ren = vtkRenderer() widget.GetRenderWindow().AddRenderer(ren) cone = vtkConeSource() cone.SetResolution(8) coneMapper = vtkPolyDataMapper() coneMapper.SetInputConnection(cone.GetOutputPort()) coneActor = vtkActor() coneActor.SetMapper(coneMapper) ren.AddActor(coneActor) widget._Iren.Initialize() # Initialize the interactor widget._Iren.Start() # Start the interactor timer = Timer(None) timer.Interval = 1000 timer.OnTimer = on_timer FreeConsole() Application.Run() finally: view.Destroy() if __name__ == '__main__': vclVTKRenderWindowInteractorConeExample()
-
Nicely avoids the problem of integrating with the IDE help system - by not integrating with the IDE help system 🙂 Also contains the only instance of a cocktail shaker bubble sort that I've seen used in practice. "Outdated help is better than no help" - apparently.
-
Threadvar "per object"
David Heffernan replied to chkaufmann's topic in Algorithms, Data Structures and Class Design
The naive answer to your question is that the object holds a dictionary whose key is the thread id. But it's far from clear that what you are planning will actually solve your problem. -
It's far more effective just to paste the function name into Google surely
-
How to debug a Not Responding program element
Anders Melander replied to Willicious's topic in Delphi IDE and APIs
Give madExcept a try again; It's much easier. -
Latest update: - Added miniaudio
-
LOL, I don't know how to comment on this, here it is a waste of time to go into individual cases of absurdity. We are in 2024, the explosion and development of good affordable pricing and even very good free open source applications, high costs can no longer be an excuse. as for JIRA I would not use it even for free(expect it's very expensive) there are much better commercial systems for issues tracking(also complex advanced and very stable) What is wrong with this company - looks to me like they do not respect their customers in my opinion. People take the time to report bugs to do descriptions, validations, create ready made examples and then something just gets lost like with this change. Or some quite serious ones hang unfixed around for several years(!). I no longer have faith in the current team in charge of management, it has to be completely new people with a fresh approach.
-
My YouTube Channel - The Silver Coder
Lars Fosdal replied to silvercoder79's topic in Tips / Blogs / Tutorials / Videos
@silvercoder79 Hi Tim! I think it is great that you share your experiences with our favorite language! There seems to be a small influx of new faces at the moment, so the better an education they can have, the better it is for the community! -
I have a project that I originally started for a presentation at the ADUG 2023 Symposium, which was on AI and ChatGPT. Since then I have continued to improve it and added more features to it. One of the goals of this project is to provide a library to Delphi Developers that enables them to easily use various AI models / engines that are currently available. Currently this is mostly done through calling various different REST API's that different companies provide, although another goal is to enable models to be used locally where practical. Features include: - Voice Recognition - Text to Speech - Image Generation - Face Detection - Large Language Models (LLM) like GPT. I have created various example programs that exercise the different API's as well. Today, OpenAI released some new features and API's. I have since added support for Dall-e-3 and the Text to Speech engine so far. To find out more have a look at https://github.com/geoffsmith82/Symposium2023