Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Wrong colors of std members when including OpenCV
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

fsgs
Junior Member

16 Posts

Posted - Feb 27 2012 :  11:19:32 AM  Show Profile  Reply with Quote
Hello,

I'm using latest build of VAX in VS2010. I noticed several problems with highlighting in my project. I.e. std::vector is highlighted as a method (brown instead of blue) and std::transform is highlighted vice versa (see image).

When I click "Go to Implementation" (Alt+G) on "vector" or "transform" I get in core.hpp file of OpenCV library. And I have no such problems in project which is not using OpenCV. So seems like OpenCV headers are ruining VAX parser.



accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Feb 27 2012 :  5:38:50 PM  Show Profile  Reply with Quote
I've downloaded OpenCV, set the include path, included
#include <vector>

and
#include "opencv2\\core\\core.hpp"

and used
using namespace std;

but wasn't able to reproduce the problem. What opencv2 and std includes do you have in the file where you are seeing this problem?
Go to Top of Page

fsgs
Junior Member

16 Posts

Posted - Feb 28 2012 :  03:58:49 AM  Show Profile  Reply with Quote
There are lots of includes, of course. Not counting my internal files, I have these includes in stdafx.h:

// SDK includes
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/squared_distance_2.h>

// STL includes
#include <vector>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iterator>
#include <tuple>
Go to Top of Page

fsgs
Junior Member

16 Posts

Posted - Feb 28 2012 :  04:23:01 AM  Show Profile  Reply with Quote
I've just tried to rebuild VAX database. Now wrong colors are displayed only for vector, and some other containers as well (see image).



However, "Go to Implementation" on all containers is now resolving to correct definitions inside STL. Update: after writing this post I checked "Go to Implementation" on vector again and now it points to core.hpp in OpenCV like before. Seems like VAX has done some additional parsing.

In core.hpp it points on "using std::vector;" line, and when click Alt+G on this vector again, I finally get in <vector> file in STL. Inside this file, "vector" is highlighted with blue. The moment I open <vector> file in Visual Studio "vector" is brown, and the moment after it immediately turns blue. When switch back from <vector> file effect is the opposite: the moment I open my file, it is blue, the moment after it turns brown. The effect is stable.
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Feb 28 2012 :  5:38:54 PM  Show Profile  Reply with Quote
Visual Assist's code colorizer is not 100% accurate because it does not do strict context checking to be able to color the code fast, so it can keep up even with rapid scrolling.
The coloring of symbols is done as a per file basis, so if you have a different type in the same file with the name "vector", it will be used for coloring.
If you do a search in your file for "vector", with match case and match whole word enabled, are you able to find any other local or global symbol definition with the name "vector"?
When it happens, the symbol color changes as you switch between the files, like you had mentioned.
Go to Top of Page

fsgs
Junior Member

16 Posts

Posted - Feb 29 2012 :  03:16:56 AM  Show Profile  Reply with Quote
I've compiled my file with /P directive to handle all includes and preprocessing and done Ctrl+F of "vector" in resulting .i file. Matches of interest might be as following (not counting lots of matches in STL <vector> file).

opencv/core/core.hpp:
namespace cv {
...
using std::vector;
...
...
class CV_EXPORTS Mat
{
public:
    ...
    template<typename _Tp> operator vector<_Tp>() const;
    ...
};
...
...
template<typename _Tp> class  Mat_ : public Mat
{
public:
    ...
    operator vector<_Tp>() const;
    ...
};
...
}


CGAL\\v3.9\\include\\cgal\\direction_2.h:

namespace CGAL {
...
template <class R_>
class Direction_2 : public R_::Kernel_base::Direction_2
{
public:
    ...
    Vector_2 vector() const { ... } // This function is then used many times
    ...
};
...
}


CGAL\\v3.9\\include\\cgal\\internal\\intersections_3\\triangle_3_line_3_intersection.h

namespace CGAL {
namespace internal {

template <class K>
typename K::Point_3
t3l3_intersection_coplanar_aux(const typename K::Line_3& l,
                               const typename K::Point_3& a,
                               const typename K::Point_3& b,
                               const K& k)
{
    ...
    typename K::Construct_vector_3 vector =
      k.construct_vector_3_object();
    ...
};
...
}}


So you may have a look at given CGAL include files as well.
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Mar 02 2012 :  8:22:35 PM  Show Profile  Reply with Quote
Thank you for the elaborated answer. Unfortunately the problem seems to be caused by
operator vector<_Tp>() const;

Visual Assist find the above line, so globally, it handles vector as a function, but when you open the <vector> file VA overwrites the coloring, since as I said before, VA handles coloring per file. When you switch to an other file (where vector is not directly defined in the file itself), VA uses the global version of the definition.

In other words, this is because of the limited context checking that VA uses so colorization can be done in real-time, without any lag or delayed coloring whatsoever.

So, unfortunately this is a known problem, but the fix is not trivial:

case=660

I kind of saw that your problem is related to the above case number, but wanted to understand what is happening in your specific case to see if it really is the same problem or there might be quick fix for the problem.
Go to Top of Page

fsgs
Junior Member

16 Posts

Posted - Mar 03 2012 :  03:46:24 AM  Show Profile  Reply with Quote
quote:
Originally posted by accord


So, unfortunately this is a known problem, but the fix is not trivial:
case=660



Where can I find details on this problem? I tried here: http://www.wholetomato.com/support/problems.asp, but wasn't able to find issues list.

And what if I include <vector> before <core.hpp>? In this case, Visual Assist will (or not?) see vector class first. Update: tried it, no result.

Edited by - fsgs on Mar 03 2012 04:00:04 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19179 Posts

Posted - Mar 05 2012 :  6:19:19 PM  Show Profile  Reply with Quote
Unfortunately you cannot check the case directly. You can ask, and someone will check on the case status for you. This thread should be updated when the case is fixed, and fixed cases are also listed in the release notes when a new build is posted.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000