Hey @Sean , is there a reason why I can't get CMake to find the brlcad libraries? I've been at this for a while now and can't get it to work.
cmake_minimum_required(VERSION 2.8) # Project name: V1(BRL-CAD-QTGUI) project(BRL-CAD-QTGUI) # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed set(CMAKE_AUTOMOC ON) # Find the QtWidgets library find_package(Qt5Widgets) # Find BRLCAD library find_library(brlcadlib brlcad) # include our .h files located in /include include_directories(include) # Find all source files located in /src file(GLOB SOURCES "src/*.cpp") # Tell CMake to create the executable # TIP: ${SOURCES> are all the .cpp files # TIP: Listing all include files is not necessary but # will enable a preview for your IDE add_executable(${PROJECT_NAME} ${SOURCES} include/window.h include/splashscreen.h ) # Tell CMake to use the QT 5 Widget module as an external library target_link_libraries(${PROJECT_NAME} Qt5::Widgets ${brlcadlib})
Errors :
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Hey @Sean , is there a reason why I can't get CMake to find the brlcad libraries? I've been at this for a while now and can't get it to work.
# Find BRLCAD library
find_library(brlcadlib brlcad)
You probably should use find_package(brlcad) ... I'm not sure about brlcadlib
@Mahdi check the CMakeFiles/CMakeError.log to see what's failing
you can also totally punt and just manually add BRL-CAD's include directories and libraries to the link line if you need to
I've tried the find_package method before and it ends up failing at:
Linking CXX executable BRL-CAD-QTGUI.exe [33%]
because it can't find -lbrlcad.
That would suck if I chose to expand on this project :\
Mahdi, can you link me to your task?
I'm currently having another task reviewed but I'm looking at BRL-CAD Alternative GUI 2: Hook in a BRL-CAD Library
The whole task is about finding out how to include an external library with CMake.
That's why I hesitate to tell you the answer. You have somehow to add an import library with CMake. Asking Google should be helpful, or the CMake manual.
BTW, there is more than one solution, even one with only minimal changes to the CMakeLists.txt.
ah, my bad @Mahdi that's why I wanted to know which task -- so yeah... figure it out ;)
Ah, fair enough ;)
If you get stuck I'll provide you with some more help, but first you should do some own investigations.
Hey @Daniel Rossberg , I've been looking around and I still can't figure out what I'm doing wrong. It's probably something really obvious and I'm just missing it. Could you perhaps point me in the right direction? Like, a clue or hint that wouldn't take away from the integrity of the task but would still allow me to progress. Currently I'm getting this error:
CMakeFiles\BRL-CAD-QTGUI.dir/objects.a(window.cpp.obj):window.cpp:(.text+0xba): undefined reference to `BRLCAD::ConstDatabase::ConstDatabase()'
Which is probably an issue with the linker.
target_link_libraries(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/libs/brlcad.lib)
Could I receive some guidance on how to go about completing this?
Hi @Mahdi I'm not sure how your project looks like. However, including the BRL-CAD library in target_link_libraries() is right. But, you should use it this way: target_link_libraries(${PROJECT_NAME} brlcad)
Then, there is another CMake command which allows you to specify the directory where it should search for the lib.
My project is sectioned like so:
Bin
- brlcad.dll
db
- *.g files
doc
- doc files
include
- brlcad
- *.h files
- QT *.h files
lib
- brlcad.lib
src
- *.cpp files
CMakeLists
I've tried using find_package, find_library, link_directories, etc...
link_directories(lib)
should do it, or?
I receive a series of "undefined reference" errors through that method.
Can you upload a zip file with your project to the task?
I sent it
And you are working with MS Visual Studio? And your compiler and the DLL have the "same number of bits"?
I'm using the MinGW Compiler with QT Creator. I've chosen the 32 bit version of the DLL as MinGW is 32 bit aswell
OK, that's the reason: The handling of C++ is different between Visual Studio and MinGW. They aren't binary compatible. The DLL works only with Visual Studio or other Microsoft compatible compilers.
Now, you could whether use Visual Studio (like you did with PrintTitle,) or build and use the brlcad C++ core interface (which is in principle the same as the brlcad.dll). See the "Build the libbrlcad.so" task. You may want to do this first.
What exactly does "core interface" mean? Is it just the source files that were used to create the .dll?
It's an C++ interface layer on top of the BRL-CAD core libraries. And yes, these are the source files which create the DLL, together with the usual BRL-CAD core libraries around librt.
The library with this interface layer can be created on every BRL-CAD OS (e.g. Windows, Linux, FreeBSD, MacOS). For MS Visual Studio there is a compiled compact library, the brlcad.dll. For other environments you have to build it by yourself.
Thanks, I've learned a lot today! Which path would you personally recommend? Should I transfer my work to visual studio or use the core interface?
Well, do you work with Windows? If I remember right, Visual Studio was the only compiler which was able to build BRL-CAD on Windows. Therefore, it could be hard (but maybe not impossible) to build the brlcad.dll with MingW. However, you could try it - it's only the one DLL but not the whole BRL-CAD.
On the other side, if you can build Qt programs with Visual Studio too...
The main incentive for using QT Creator was how light weight and specialized the IDE was but I suppose it won't be too hard to transition to Visual Studio. Also, I have a linux and ms workstation but I would prefer to keep gui related files on microsoft. I'll take a look at using Visual Studio :P
You could still use the Qt Creator for the layout, but then compile the program with Visual Studio.
That's actually what I was just working except I'm running in to even more issues. Have you ever been able to use the visual studio compiler with qt creator?
I build the Qt Creator with Visual Studio because I build my whole Qt with it, but I've never used the Creator. It's not my way of programming ;)
;) fair enough. How would I go about integrating my old CMake with visual studio? With QT Creator it allowed me to autorun it with a defined configuration -- can I do that with visual studio? I guess I'm just wondering how to port everything over as smoothly as possible.
Update: Everything is good now.
@Mahdi That's good to hear. I've just commented your work. There happened probable a mistake when you uploaded the source code.
To give you an idea where this could lead to: https://univemo.iabg.de/Download/BrlCadViewer30_setup.exe
But this isn't the only application we think of.
Do some tasks disappear after a certain number of completions?
Yes. Every task has a maximum number of instances. Are you looking for a special one?
I was just about to do the Splash Screen one since I wanted to implement it for the QT Projects. Unfortunately it was removed moments after my last task was completed.
Also, given the repetitive nature of some tasks, is there some mechanism which prevents a competitor from saving tasks from previous years and handing them in?
I increased the number of splash screen task instances. You could choose it now if you want.
Thanks!
Hey, so I'm on QT Task #4 and was wondering what kind of information we have to display after selecting an element? So far I've built the gui to view the database and nodes but as I'm not familiar with BRL-CAD I'm not quite sure what else it needs me to look for. Any tips?
@Daniel Rossberg Is there any documentation for the Core Interface?
@Mahdi You could look at https://brlcad.org/wiki/BRL-CAD%27s_core_C%2B%2B_interface
The source code is (e.g.) at https://sourceforge.net/p/brlcad/code/HEAD/tree/rt%5E3/trunk/include/brlcad/ and https://sourceforge.net/p/brlcad/code/HEAD/tree/rt%5E3/trunk/src/coreInterface/
Thank you!
Maybe you want to "Learn basic 3D modeling using BRL-CAD..." before continuing programming it?
Hm, that's probably a good idea. I'll put the project on hold for now.
Just out of curiosity: Why did some of the mentors, such as yourself, decide to work on BRL-CAD?
Just figured out CMake
is actually easier than make
.
I think CMake
is the best choice for large projects.
But make
is still better for small projects with just a few source files and headers.
Just out of curiosity: Why did some of the mentors, such as yourself, decide to work on BRL-CAD?
What a great question.
Without getting too philowaxical, I believe solid modeling CAD tools are in their infancy, mired in an entrenched overpricing, and the best way to revolutionize that industry is via Open Source. To me, BRL-CAD is not yet up to the task of implementing all the complexity required, but it's the best foundation, an amazing codebase, and a great community.
@Daniel Rossberg : If a Qt GUI will become part of a BRL-CAD distribution it will be linked to Qt 5. We won't build on an old/outdated version.
I did this Qt 4 because it was already installed on my system. I'll use a new version for other tasks.
Your main.cpp should compile with Qt 5 as well. I.e., you haven't missed something.
So I just have to update the CMake file.
@Daniel Rossberg Do you know of a good way to structure the keys & values of a map into a tree?
@Mahdi Do you mean something like QTreeView?
@Daniel Rossberg Are there plans for more QT tasks? I remember Sean saying there were going to be more as the Code-In progresses.
Yes.
@Mahdi Please don't use OpenGL. It has never worked for me, and wouldn't provide any benefit here.
@Daniel Rossberg Well, I know QString is part of Qt(All begins with a Q), CoreInterface know nothing about it (Why it should?). OpenFileDIalog returns the file's location as a QString. I have to parse it to load function which requires a char* , I had no idea how to do that,
I first used ByteArray
to solve this, So I had that comment to describe what I am doing, And then I discorverd c_str()
, It made it a lot easier
I deleted the ByteArray
code but kept the comment there. I didn't even knew CoreInterface is in C++, I just thought it was in C like BRL-CAD itself.
BTW It's a really fun task, At first it was very hard. But after working in it for a while, It became so easy. (Maybe because this is my first QT5 application).
pass not parse
@Naseef The translation of a QString (Unicode) to ab byte sequence can indeed be an issue. This is usually be done by selecting explicitly a conversion with one of the to~() methods. They return usually a buffer which manages the memory of the converted string. That's why you see often these QByteArray there. It's mainly a character array with methods which take care of its memory.
Therefore, filename.toLocal8Bit().data()
or filename.toUtf8().data()
could be what you want.
How I plan to proceed with the "BRL-CAD alternative GUI" etc. tasks:
One direction is to implement more visualization features in the Qt GUI. These could be zooming, moving, and rotating the view and selecting the elements to display from a tree. Before I make these tasks, I want to see however how you are doing the "BRL-CAD Alternative GUI 6: Draw a Ray-Trace". I want to adjust the tasks descriptions accordingly.
The other direction is the (Lua) scripting. Michal came up with the idea to have an interface similar to OpenSCAD: A scripting window where you can edit a text which describes the geometry and a viewing window where you can see the scripted geometry.
This scripting could be possibly done with the BRL-CAD ASCII file description, with the shortfall of the absence of the usual scripting elements (variables, operators, loops, ...), or TCL, which is a mighty programming language and not easy to deploy (if you want to do it right). That's why I want to do an experiment with Lua. This is a small scripting language, not so powerful as TCL, but possibly with exactly the features we need for this kind of project.
So, watch out for "Lua" tasks there. Integrating BRL-CAD in Lua requires a steep learning curve, but after implementing the first few functions you'll see that it becomes mostly copy-n-paste. I plan to divide the tasks there in two steps: Implementing a new feature and testing it. This gives you the possibility to rethink your implementations and fix bugs if there are one.
Any comments?
Why lua?
Okay, So after some googling, Lua looks like the perfect option. It's lightweight, fast, MIT licensed. So yeah, Why not?
To be honest, this isn't my first Lua binding project. That's why Lua was a natural option for me.
And, see it as an experiment: How far can we go during this GCi?
@Sean @Daniel Rossberg am I not supposed to use OpenGL with QT? I'm so confused about the task... I understand that I have to create a raytrace but there are many ways that could be achieved. I was told that I had to use OpenGL but then told not to... what exactly do I have to use?
For this task a simple 2D widged will do it. A ray-traced image is a simple 2D bitmap.
Would I fail if I used a 3D widget?
It wouldn't mean a fail but I wouldn't use it in the future because OpenGL causes to much trouble for me. It's simple an unnecessary overhead here.
I've dedicated so much time trying to learn it so that's a bit disappointing.
What did Sean mean by using the OpenGL widgets then?
Did I just misinterpret him?
I commented it here already on December 7th. I.e. this isn't new.
Sean loves OpenGL. Maybe he has a computer where it works.
hehe
wasn't clear to me which the task intended -- I apparently assumed incorrectly
ah...
lol there goes 3 days worth of code
@Mahdi Don't be sorry. Now, you may know more about OpenGL than I do. I've fixed some bugs in OpenGL code over the years but never wrote something from scratch.
My first contact with OpenGL was a rotating cube. It needed some seconds for every step in the rotation (Pentium 90, probable no support by the graphics driver). Now, my new computer has a recent Nvidia graphic card and OpenGL windows on Linux are broken. The driver is known to be not perfect. Similar on another Linux machine. If I activate the desktop effects there some texts are illegible.
And, I've more such stories ...
But nevertheless the task description of GUI 5 is unclear written. Maybe I should precise it to 2D drawing area.
BTW, using an acceleration structure would be very useful here, at least in the future: Draw to an image and flash this to the widged. This way there isn't another ray-trace necessary when the program window want's a refresh. But this isn't required for this task - maybe this is something for an own task.
Reviewing the extensions of 2D graphics with QT I stumbled upon a new module called QT3D which attempts to provide a high-level option for 3D graphics. I believe we could use this new technology to take advantage of the accelerated graphics of OpenGL without having to get our hands dirty by coding it. Do you think this might be an alternative to the 2D task? It might be a lot more maintainable as QT is moving towards QML and we may need to futureproof.
QT3D has frameworks for c++ and qml so that might be advantageous
If you have 3D data to display this could be a good abstraction layer which hides the OpenGL, Direct 3D, ... behind.
However, the goal is here to create a 2D image. I'm afraid that this won't become easier with QT3D.
aren't the QT tasks supposed to be about rendering 3D graphics? Similar to what Archer does?
Yes, but the rendered image is 2D. It's a picture.
Another situation would be with the wireframe representation. But I'm afraid that this would go to far for this GCi.
But if we render it in 3D and then calculate the pixel values to create a 2D representation with pixmap it would work, right?
I would love to tackle the challenge if you considered breaking it down into smaller tasks: like getting qt3d setup, simple image rendering, etc... and then eventually reaching more advanced low-level methods.
Ah, I think you don't know what "render" means.
Sorry I wasn't referring to it in a graphical context I just meant a general render
as in just displaying it visually
It's already broken in small parts. GUI 5 requires you to add a QtView (I have no Qt manual at hand to check this), which is trivial, and a function for coordinate transformation.
Oh I see I was just suggesting qt3d as a new task sequence
With the GUI 5 it's just a graphicsscene, graphicsview, and then simple conversion of coordinates. I was just thinking about it and thought the QT3D might make for some fun tasks so that's why I suggested it
Then, in GUI 6, you should create a ray-traced image in this widged. I.e. in GUI 5 you don't need to draw anything.
The result of the ray-tracing in GUI 6 should look similar to the result of rt in the frame buffer.
There's no drawing in GUI 5?
No, only the widged and a function. I tried to make the tasks small :wink:
Such that you can do a lot of them.
That's probably for the best :) Do you think you'll consider adding a QT3D task for GUI 7 or whatever?
I haven't planned it yet. I want to make more for the Lua binding.
3D would only make sense with the wireframe representation where I haven't prepared anything yet.
Thinking about it would require some time.
Hold up, if the task isn't to create a wire frame what coordinates am I converting? The bounding box? I think I keep over thinking this
Or is it the object coordinates
The image is like a projection of the 3D model. A 2D coordinate from the image plane corresponds to a 3D line in the model space. The directions of all these lines are the same.
To make it easier you can choose any fixed projection you like. It would be a future task to let the user choose one.
I sort of get how to display the coordinates as an image but what I don't get is how to actually obtain the model coordinates. Say someone decides to choose demonstrations/ant
How would you get the coordinates of the ant? I get how you can get the boundingbox and other attributes like region, color, etc but how do you get the individual coordinates forming the object?
Ah, nvm we have to get the coordinates from the hit/miss -- I see now.
ah...
not necessarily -- there are other tasks that are very explicitly qt-opengl so if you did work there, feel free to claim those tasks and get credit for the work. it should requires minimal effort on your part. I believe you can find the tasks if you search on qt or possibly opengl as keywords.
Ah, nvm we have to get the coordinates from the hit/miss -- I see now.
Not really. The goal is to create a ray-trace image. I.e., you have a 2D array which entries are called pixel and want to know the color of each of it. The colours of the pixels are determined by a kind of "what you see when you project the model viewing plane". The projection goes from your eye "through" the model on the projection plane. And for the moment, we can assume that all these projection rays are parallel.
Furthermore, GUI 5 doesn't tell you which projection you shall choose. It's your decision, so take an easy one as the projection on the (x-y) ground plane. Then, your rays are (0, 0, -1) and you only have to determine their start points.
BTW, QWidged is all you need from Qt to have something where you can draw at.
I just can't seem to get how you obtain any type of coordinate information from the Object class ;|
You don't need to.
Something like this?
Not really. First, I would recommend to use a parallel projection. It's easier to start with.
Then you need to understand how the image generation works. If we talk about a projection one could think of taking a point from the model and searching its image on the projection surface. Unfortunately, it doesn't work this way. Doing so e.g. it would be hard to ensure that every pixel of the drawing surface is covered once.
It works rather the other way round. You take a pixel from the drawing surface and ask: Which colour has it? I.e., searching for a function like Colour(x, y). (STOP! This is not the function GUI 5 ask for.) So, how do you get the colour of a pixel? The geometry is somehow floating above the projection surface, and from the projection you get a line starting from the pixel through the geometry. In case of a parallel projection all these lines are parallel, i.e. have the same direction. Now, lines, ray-trace, do you see where this will lead to?
So the raytrace would be something like:
for each pixel {
shoot ray
get level of light in that pixel
project pixel onto an image
}
I'm still unsure of what coordinates the task refers to
Would you get the shape formed by the boundingbox and shoot rays inside its area?
You are getting closer.
For every pixel you shoot a ray. This ray hits some component which has a colour which you can assign to the pixel.
Now you need a function which gives you for each pixel a ray. With parallel projection the direction of the rays is always the same. Left the ray start points.
BTW, there is no "project pixel onto an image". The pixel IS in the image. The image is build from pixels.
Hm, so by setting up a camera which can be transformed or just manually inputting a direction value for the ray you can get different raytraces
So you need a ray origin and direction, right
Exactly. But for GUI 5 it is even easier: You can have a fixed projection (direction) here. No user interaction is required here. The only issue you have to take care for is that the geometry (enclosing box) fits somehow well on the drawing area (QWidged).
To debug this and get this working is GUI 6.
So in the end GUI 5 just has to do with the box formed by the min and max bounding?
In principle yes.
The ray direction can be a hard coded one.
I can't believe I've spent an entire week on just that ...
I would recommend to use rays along a coordinate axis.
This task seems to be much more about understanding how 3D geometry, projection, and ray-trace works than I thought.
If it consoles you: You are the first student who went into these regions :simple_smile:
I woke up this morning adamant that I was too dumb for these tasks and should just give up. That really gives me some comfort
No need to be feel bad. You are outstanding. And, I plan to put your work in our repository, well in the experimental rt^3 branch first.
And, when you are stuck again keep talking with the mentors.
Hi @Daniel Rossberg. May I have a hint for QT task 4, what is meant by "element extends" and how to get them? I can list all the top level elements in Qt window and read their attributes from *.g database (mostly rgb colors) but I could not find any readable dimensions in it. Shall I convert it to ascii first and recalculate all the included .r and .s elements to get the overall size of the object or is there a simpler way I could not see? Thank you.
@Michal Hanus BoundingBoxMinima(), BoundingBoxMaxima() (after selecting the object)
@Mahdi you're tackling one of the hardest and most valuable projects -- you should be proud of what you've already accomplished. You're doing well. :)
Can you help me on "BRL-CAD Alternative GUI 4: Selection of a Combination"? I don't understand what I have to do.
What should be on the window?
From the previous task you already have a filled ConstDatabase. Iterate over the top objects (start with FirstTopaObject()) and build a list of them. Select() one of them, get the bounding box minima and maxima, and print these numbers on the window.
Is there a way to keep history of my code edits? Like SVN, GIT ( Locally)? I frequently get everything messed up, Especially when I have no idea what I am doing.
For local, private use I would recommend git because there is less overhead. Type git init
in your base directory and you are ready to start.
help, getting undefined references when trying to make :confused: . On QT#2.
You have to link with the coreinterface library.
Last updated: Jan 10 2025 at 00:48 UTC