I use Graphviz (mainly dot and fdp) to automatically generate some diagrams that I need. For these diagrams I need some special arrowheads that are not a part of the standard collection of arrows: A small black triangle inside a large white triangle, and the same with the black triangle pointing downwards.
What is the best way to add such arrowheads? I don't mind hacking the source code, if necessary. Where should I start?
You have to change to source code for that. Take a look at "lib/common/arrows.c".
You will find that you have to:
Add a #define like ARR_TYPE_YOURARROWNAME
add a entry in Arrownames[] with the name you will use in the code for your arrow and the define.
write the prototype of your arrow function (see around row 115), read the points below
add your function in the Arrowtypes[] array an entry with the define you wrote previously, the pen width, the name of your arrow function which will be something like arrow_type_yourarrowname
write your own arrow function.
In order to write your function take a look at arrow_type_normal(), it takes 6 parameters: job (you don't have to care about this, just use it like in this function), two points ('p' and 'u'), arrowsize, penwidth and flag.
If you don't care about making different versions of your arrowhead, or if you wish to ignore the modifiers (inverted arrows and the like) ignore the flag parameter.
Then, the function basically takes the two points p and u (which are structures with 'x' and 'y' attributes in them) and combines them creating an array called a[] passed to gvrender_polygon() which will finally render your arrow shape.
arrow_type_normal() also mess with the penwidth and arrowwidth.
Summarizing: prepare graphviz to accept your arrow name doing the first steps then create a function that will create the arrow shape and that will call gvrender_polygon or gvrender_polyline (if you wish).
I didn't try yet, but it should work.
Related
I'm trying to plot a grid of squares given in the following format
{'p0a0': [[1255.1929931640625, 1430.1819458007812, 1428.170166015625, 1253.1811828613281, 1255.1929931640625], [407.78900146484375, 409.629638671875, 600.617431640625, 598.7767791748047, 407.78900146484375]], 'p0a1': ....} and once plotted it should look like this
I'm trying to pyqtgraph.PlotDataItem.setData() method. My idea was to use a for loop to iterate over all the keys in the dictionary and plot all the grid points (squares) in the same plot but, the setData() method inherently any clears previous data before plotting. Resulting in giving me the following output only one square is highlighted instead of all 64 squares
So, my question is how do I bypass the built-in resting when I call .setData() method? or If that can't be done, would anyone have a suggestion to go arround it?
I tryed giving the whole dictionary but, it didn't work. also I tried other ploting items but, couldn't find anything that works for my requiremnts.
In some Ruby code which uses Cairo, I need to draw a number of fills over a single path. This is part of a graphics application, where multiple fills may be stacked on top of each other using different blend modes.
Each fill is drawn using fill_preserve to preserve the path so that the next fill can occur over the same path without retracing it. This is done somewhat like so:
rectangle_data.each do |rectangle_datum|
context.rectangle(*rectangle_datum.rectangle)
fill_data.each do |fill_datum|
context.set_source_rgba(*fill_datum.color)
context.fill_preserve
end
end
The problem is that this leaves the path even after all fills have taken place, which means that individual shapes are just drawn as one huge filled shape.
To solve this, I'd simply need to clear the current path manually, but I can't figure out how to do this. I've had a look through the documentation for Cairo::Context through Google Translate but I can't find it. (The docs are in Japanese!)
How can I manually clear a Cairo context's current path?
I had a look over Cairo::Context#methods and found #new_path, which does just what I'm after. So you can do:
rectangle_data.each do |rectangle_datum|
context.rectangle(*rectangle_datum.rectangle)
fill_data.each do |fill_datum|
context.set_source_rgba(*fill_datum.color)
context.fill_preserve
end
context.new_path
end
Does anyone know of macro or custom command I can make to quickly annotate the area of a polyline in autocad?
I'm doing a project where I need to measure the lot and house size of several city blocks. I've got a drawing going but I don't want to measure and write out the area of each site, that will take to long. I've seen custom commands in the past that quickly do this kind of thing but I don't know how to make my own.
And I'm desperately avoiding doing it by hand one at a time as most likely I will need to make adjustments to my design later on.
The best method I can think of is to utilize the MTEXT command and use a FIELD to link the Area of the Polyline to the MTEXT box.
Type FIELD at the command line, choose Object, select your Polyline and you will see the Area property.
Here is a link on the CADTutor site that covers it a bit more in depth along with a link to a forum post that has this automated via a Lisp routine.
http://www.cadtutor.net/forum/archive/index.php/t-46628.html
I tried searching but couldn't find a function which can create a shape by calculating difference of two NSBezier Paths or two CGPaths. Is there a function that can establish this in cocoa ?
Thanks.
See "Winding Rules" with NSBezierPath. You'll make a compound path by appending your two source paths to it. The resulting shape will depend upon the winding rule you set.
Finally did it by creating a bigger tracking area to enclose the whole shape and then tracking mouse moved events inside this tracking area.
I need to plot and display several jpeg images in a single combined display (or canvas?). For example, suppose I have images {a,b,c,d}.jpg, each of different size, and I would like to plot them on one page in a 2x2 grid. It would be also nice to be able to set a title for each subplot.
I've been thoroughly looking for a solution, but couldn't find out how to do it, so any ideas would really help. I would preferably use a solution that is based on the EBImage package.
There are two ways how to arrange several plots with base graph functions, namely par(mfrow=c(rows,columns)) (substitute rows and columns with integers) and layout(mat) where mat is a matrix like matrix(c(1,2,3,4)).
For further info see ?par, ?layout, and especially Quick-R: Combining Plots.
However, as your question is about images I don't know if it helps you at all. If not, I am sorry for misinterpreting your question.
To add to Henriks solution, a rather convenient way of using the par() function is:
jpeg(filename="somefile.jpg")
op <- par(mfrow=c(2,2)
#plot the plots you want
par(op)
dev.off()
This way, you put the parameters back to the old state after you ran the code. Be aware of the fact this is NOT true if one of the plots gave an error.
Be aware of the fact that R always put the plots in the same order. Using mfrow fills the grid row by row. If you use mfcol instead of mfrow in the code, you fill up column by column.
Layout is a whole different story. Here you can define in which order the plots have to be placed. So layout(matrix(1:4,nrow=2) does the same as par(mfcol=c(2,2)). But layout(matrix(c(1,4,3,2),ncol=2)) places the first plot lefttop, the next one rightbottom, the third one righttop, and the last one leftbottom.
Every plot is completely independent, so the titles you specify using the option main are printed as well. If you want to have more flexibility, you should take a look at lattice plots.
If you do not want the images in a regular grid (the different sizes could imply this), then you might consider using the subplot function from the TeachingDemos package. The last example in the help page shows using an image as a plotting character, just modify to use your different images and sizes/locations.
The ms.image function (same package) used with my.symbols is another possibility.