Mohammed,

1. (-30, -30) to (-100,-100) isn'nt in your viewport's area, is it?
The Y values are wrong.

2. scale(0, -1) is also wrong for sure: (1) all x values will be
mapped on 0 and (2) I think you shouldn't flip your coordinate system
before translating, or otherwise take it into account while
calculating your translation vector. Order of transformations matters!

3. you're calculating a WTransform but you're not doing anything with it

4. Pick one: either define your transformation yourself, OR use
.setViewport. In your case, gHeight should be negative (but it's not
even documented that Wt actually supports this - I assume it does)

Also, it's very easy to make mistakes against all of this, so pls
don't shoot me if I have a sign wrong here or there.

Fourthly
Wim.

2011/1/12 Mohammed Rashad <[email protected]>:
> will you please check if this code is correct. I didnt get anything in the
> paintedwidget
>  WPainter painter(paintDevice);
>   painter.setRenderHint(WPainter::Antialiasing);
>
>   WPen pen;
>   pen.setWidth(0.25);
>   pen.setWidth(30);
>   painter.setPen(pen);
> painter.scale(0,-1);
>  double xMin = -63.5551;
>  double yMin = -20.6821;
>  double xMax = -40.053;
>  double yMax = -3.03993;
>  double gWidth = xMax - xMin;
>  double gHeight = yMax - yMin;
>  WTransform viewTransform = WTransform();
>  double scaleX = gWidth / 480;
>  double scaleY = gHeight / 640;
>  viewTransform.translate(xMin, yMin);
>  viewTransform.scale(scaleX, scaleY);
>  painter.setViewPort(xMin, yMin, gWidth, gHeight);
> painter.drawLine(-30,-30,-100,-100);
> On Wed, Jan 12, 2011 at 6:11 PM, Wim Dumon <[email protected]> wrote:
>>
>> Mohammed,
>>
>> Looks like you flip both X and Y axises, by specifying a -1 for scale,
>> while only Y needs to be flipped.
>>
>> After a quick look at your code and the screenshots, I propose this code:
>>
>>  double xMin = -63.5551;
>>  double yMin = -20.6821
>>  double xMax = -40.053;
>>  double yMax = -3.03993;
>>  double gWidth = xMax - xMin;
>>  double gHeight = yMax - yMin;
>>
>> To define the viewport transformation manually:
>>  WTransform viewTransform = WTransform();
>>
>>  double scaleX = gWidth / width();
>>  double scaleY = -gHeight / height(); // scale and flip Y axis
>>
>>  viewTransform.translate(xMin, yMin);
>>  viewTransform.scale(scaleX, scaleY);
>>
>> Or, by using the viewport function:
>>  painter.setViewPort(xMin, yMin, gWidth, -gHeight);
>> The setViewPort() in your code assumes that it's parameters are (x1,
>> y1, x2, y2), while it's really (x, y, width, height)
>>
>> BR,
>> Wim.
>>
>> 2011/1/12 Mohammed Rashad <[email protected]>:
>> > Hi Wim,
>> > I didnt suceed with my code i had attached my source code with this
>> > mail.
>> > first screenshot (Screenshot.png is from wt application and second
>> > screenshot Screenshot-1.png is from qgis(An open source GIS application
>> > for
>> > desktop). you can see the differences.
>> >
>> > when we compare the points are rendered correctly. the rendering does
>> > not
>> > need any translation or scaling but only problem is setting bounds. for
>> > the
>> > qgis project bounds is -63.5551,-20.6821,-40.053,-3.03993 and for wt I
>> > can't
>> > set this bounds.
>> > everything will be fine if it sets the bounds. I had also attached a
>> > opengl
>> > version of simple shapefile viewer which uses opengl for rendering and
>> > set
>> > the bounds using glOrtho . So can you help me out once more. :(
>> >
>> > On Wed, Jan 12, 2011 at 4:08 PM, Wim Dumon <[email protected]> wrote:
>> >>
>> >> 2011/1/12 Mohammed Rashad <[email protected]>:
>> >> >
>> >> >
>> >> >> xMin and yMin is to become the new origin, so you'll need to
>> >> >> translate
>> >> >> over that distance (actually, this may change if you had to flip
>> >> >> axis
>> >> >> the axis system for the reason mentioned above).
>> >> >
>> >> > First of all thanks. how can i set the xMin and yMin as new orgin?
>> >>
>> >> Let (X, Y) be your point in GIS coordinates. If X=xMin and Y=yMin, you
>> >> want them to become (0,0) on the painter. So the right operation would
>> >> be to render (X - xMin, Y - yMin). This is a translation over (-xMin,
>> >> -yMin).
>> >>
>> >> I noticed I sent the previous mail to you privately, I wanted to
>> >> respond to the mailing list.
>> >>
>> >> Wim.
>> >
>> >
>> >
>> > --
>> > Rashad
>> >
>
>
>
> --
> Rashad
>

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to