|
vivekphlp wrote: i think its better...
I was merely giving options, not opinions.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
ok sorry
Proud To Be an Indian
|
|
|
|
|
Hi everone,
I'm developing an Internet Explorer add-on,which will put an extra image on the document's specified location.Everything works fine,but Internet Explorer won't display the image if it is located in the local system (the user's computer,i mean).Since I'm sure the image url (formed as 'file://c:/folder/image.gif ') is correct and IE displays images on the internet,I think it's a kind of security feature of IE.
Does anyone have any idea on how I can put a local image on the document without asking the user to alter security settings?
|
|
|
|
|
I have created an SDI application. There i have created 3 dockable toolbars without using Rebars. The problem is that all toolbars appears in a separate line. I want them to be on after the another. How to do this.
Please help me.
Anurag Gandhi.
|
|
|
|
|
Hi,
Could you please specify the styles CBRS_* used while creating and docking it.
Best Regards
Raj
|
|
|
|
|
Following is the complete functiom:
Similar is the function for other two toolbars also.
bool CMainFrame::AddMarginToolbar()<br />
{<br />
if (!m_MarginToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP<br />
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||<br />
!m_MarginToolBar.LoadToolBar(IDR_MARGIN))<br />
{<br />
TRACE0("Failed to create Case toolbar\n");<br />
return false;
}<br />
m_MarginToolBar.SetWindowTextW(_T("Margin"));<br />
<br />
m_MarginToolBar.EnableDocking(CBRS_ALIGN_ANY);<br />
EnableDocking(CBRS_ALIGN_ANY);<br />
DockControlBar(&m_MarginToolBar);<br />
return true;<br />
}
I want that next toolbar should appear automatically previous first toolbar.
Thanks a lot in advance.
Anurag Gandhi.
|
|
|
|
|
Hi,
You need some thing more to get this, you need to use the full parameters of
DockControlBar();
for instance if you want to set the toolbar before the first tool bar aligned on top
you can do this,
DockControlBar(&m_MarginToolBar);
RecalcLayout();
CRect rect;<br />
m_MarginToolBar.GetWindowRect(&rect);<br />
rect.OffsetRect(1,0);
<br />
<br />
DockControlBar(&m_wndToolBarSecond, AFX_IDW_DOCKBAR_TOP, rect );
think and modify alignment according to your requirement.
Best Regards
Raj
-- modified at 9:54 Monday 4th June, 2007
|
|
|
|
|
Thanks a lot Raj.
I have implemented it and it is working fine.
Anurag Gandhi.
|
|
|
|
|
Hi. Ok slightly long explaination, I apologise!
I am currently developing a 3d drawing system and am having a few problems with storing the vertexes of each line.
Basically there are two objects that I am using to construct a drawing: points and lines. A point stores the x y z coordinate of a vertex. Each point that is drawn is stored in a global vector of points. A line consists of many points and consists of a vector that stores a reference to each pointer in the global vector.
The problem I am having is that the vector of pointers in the line object start off pointing to the vertex in the global array but when another point is added to the global array it can no longer find it instead it comes back with the vertex being at some strange position, the most common coordinate being -1.5883997e38. I can see it may be something to do with how the global vector stores the point objects.
Ive checked:
The actual values of the pointers in the line vector do not change value
The global vector containing the points stores the points ok
Is this explanation enough or do I need to post code?
Kevin
|
|
|
|
|
Me think your design suck; I don't think it's efficient (or doable) to keep reference to vector items.
create a struct/class for your coordinate.
make an base class called Geometry (or whatever you like), make a class Point, make a class Line both derived from the base class Geometry.
Create a vector of pointer to Geometry.
something like :
struct Coordinate { double x, y, z;};
class Geometry
{
void Draw()=0;
};
class Point : public Geometry
{
Coordinate m_Coordinate;
void Draw(){};
};
class Line : public Geometry
{
Coordinate m_Start, m_End;
void Draw();
};
std::vector < Geometry* > m_GeometryVector;
|
|
|
|
|
kevinbrydon wrote: Is this explanation enough or do I need to post code?
Maybe posting the relevant code will help.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi,
First of all your approach of using STL classes for 3D drawing system is not so good.
3D graphics being a expensive operation on computer, experts are using hardware accelerated methods like using graphics library like DirectX, openGL.
stl::Vector is an expensive array is inefficient for such application.
Then, what do you mean by reference, reference to vector item.
please post some code snippet.
|
|
|
|
|
Ok thanks for replying
Max:
Thats basically the design I have but without the geometry class. I am never going to be able to draw a point, it is simply used to construct a line (the system is only going to be able to draw lines)
Pallini, Rajkumar:
Heres some code:
---------------------------------
// holds all the lines
std::vector <line> lines;
// holds all the points
std::vector <point> allpoints;
struct Point
{
public:
GLfloat x, y, z;
bool selected;
/* constructors */
Point()
{
}
Point(const GLfloat & xval, const GLfloat & yval, const GLfloat & zval)
{
}
Point(const Point & from)
{
}
};
/* a class to describe a line in 3 dimensional space */
class Line
{
public:
// each pointer in this vector should point to a Point object in allpoints
std::vector <point*> points;
bool selected;
// Initializes variables
Line()
{
}
Line(int typein)
{
}
// Functions
void addPoint(Point & p)
{
points.push_back(&p);
}
void draw() // ive only included part of it
{
Point current;
glLineWidth(thickness);
glColor3fv(color);
glBegin(GL_LINE_STRIP);
for (int i = 0; i < points.size(); i++)
{
current = *(points[i]);
glVertex3f(current.x, current.y, current.z);
}
glEnd();
}
};
-----------------------------
the reason for storing all the points in one big data structure and then referencing them makes it easier to select the lines and points later on. the "allpoints" in the final implementation is really a vector
std::vector <point> sector[GRID_SIZE][5][GRID_SIZE];
when a point is created it is assigned to a sector based on its x, y, z coordinates (forget about that for now)
when a point is selected i want it to flag "selected = true" by changing its value through the allpoints vector. then when the line is drawn it checks the value of each of its points to see if any has been selected (this is why i use pointers so it checks the actual point and not a copy of it), if so it will change to a different colour.
Rajkumar:
I am using opengl with sdl and im not all that bothered about how fast the system runs as its only really a proof of concept. when i wasnt using pointers the system ran fast (but not using pointers meant that things couldnt be selected)
thanks
kevin
|
|
|
|
|
This approach won't work if you store the addresses of pointers which are in an STL structure rather than indexes into the structure. STL moves the pointers around when you add stuff because it tends to store stuff in red/black balanced trees internally. As soon as it moves things around to keep its trees balanced your pointers to pointers become pointers to garbage. In other words you have to treat STL containers as black boxes and not make assumptions about how they store stuff. Once you put something in a std::vector or std::map the std::vector or std::map owns it and can do what it wants.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
ah right, thanks very much. would it be sensible to create my own data structure then?
|
|
|
|
|
I would Most people will advise you to use the stl constainers because they are fast and reliable. I think for an experimental app like this you'd learn more by creating your own data structures. It's not as hard as you'd think.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
|
I cannot understand completely you code (maybe some <pre> TAGs probably will help),
however IMHO you may have some troubles if memory reallocation happens (and it can happen) in the global vector, beacause the pointers stored in your Line class loose sense.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
yeh i think its a memory reallocation issue. im new to this whole pointers thing, ill get it eventually!
|
|
|
|
|
Rajkumar_R wrote: First of all your approach of using STL classes for 3D drawing system is not so good.
STL is not a graphic API, but we still need to keep our data somewhere before sending it to OpenGL or DirectX.
|
|
|
|
|
Hi,
sure STL is not graphic API,
These data structure has tradeoffs for speed and also memory consumption is high.
consider accessing a item of vector; it involves more than one indirection of reference and more than one call path
vector<char> vecObj; char c = vecObj[3] is very slow compared to a simple
char Array[10]; char c = Array[3];
For 3D graphics, rendering millions of triangles in fraction of second,
the data structure that keeps the data should be fast,
When you get time try using directX, they use their own data structure's for these purpose which is usually a buffer, and also possibly they manage to keep data in hardware cache.
Best Regards
Raj
|
|
|
|
|
unfortunately time is something I dont have, this is a research project so I have to finish the program off by the end of the month at the latest so I can get onto writing a report.
fortunately I dont require millions of triangles to be rendered, only a few thousand. Its a simple 3d sketching package.
thanks for everyone's input
|
|
|
|
|
There is nothing wrong with using std::vector s. Contrary to what some people have been saying, in most cases using a vector is just as fast as using raw memory allocation functions.
Steve
|
|
|
|
|
Stephen Hewitt wrote: Contrary to what some people have been saying, in most cases using a vector is just as fast as using raw memory allocation functions.
Hey Stephen, I just stumbled upon this old thread. In general or specifically for business apps STL is more than adequate. However I do have some minor experience in Console Gaming development and for the graphics rendering I do believe the point being made about DirectX for example might be valid. Rendering, several years back when I was involved, was a huge bottleneck and some advances have been made in that area and I seem to remember reading about what Rajkumar_R is talking about in DirectX. For production graphics I would think one would certainly want to use the current approach being supported by any particular graphics platform.
led mike
|
|
|
|
|
Rajkumar_R wrote: vector<char> vecObj; char c = vecObj[3] is very slow compared to a simple
char Array[10]; char c = Array[3];
Nonsense. All of a std::vector s functions are small inline functions. Using a vector is, in most cases, just as efficient.
Steve
|
|
|
|