/*
 * Called after a value has changed to trigger highlightning of tree item.
 */
void TreeItem::setHighlight(bool highlight)
{
    m_highlight = highlight;
    m_changed   = false;
    if (highlight) {
        // Update the expires timestamp
        m_highlightExpires = QTime::currentTime().addMSecs(m_highlightTimeMs);

        // Add to highlightmanager
        if (m_highlightManager->add(this)) {
            // Only emit signal if it was added
            emit updateHighlight(this);
        }
    } else if (m_highlightManager->remove(this)) {
        // Only emit signal if it was removed
        emit updateHighlight(this);
    }

    // If we have a parent, call recursively to update highlight status of parents.
    // This will ensure that the root of a leaf that is changed also is highlighted.
    // Only updates that really changes values will trigger highlight of parents.
    if (m_parent) {
        m_parent->setHighlight(highlight);
    }
}
Beispiel #2
0
void FindBar::setVisible(bool visible)
{
    QWidget::setVisible(visible);

    if (!m_associatedWebView)
        return;

    if (visible) {
        const QString selectedText = m_associatedWebView->page()->selectedText();
        if (!hasFocus() && !selectedText.isEmpty()) {
            const QString previousText = m_lineEdit->text();
            m_lineEdit->setText(selectedText);

            if (m_lineEdit->text() != previousText) {
                findPrevious();
            } else {
                updateHighlight();
            }
        } else if (selectedText.isEmpty()) {
            emit searchString(m_lineEdit->text());
        }

        m_lineEdit->setFocus();
        m_lineEdit->selectAll();
    } else {
        updateHighlight();

        // Clear the selection
        m_associatedWebView->page()->findText(QString());
    }
}
Beispiel #3
0
void ConsoleWindow::clearHighlight() {
	_highlightX      = 0;
	_highlightY      = 0;
	_highlightLength = 0;

	updateHighlight();
}
Beispiel #4
0
void FindBar::find(const QString & search)
{
    _lastStringSearched = search;

    updateHighlight();
    findNext();
}
Beispiel #5
0
void ConsoleWindow::highlightWord(int x, int y) {
	clearHighlight();

	float lineX, lineY;
	if (!getPosition(x, y, lineX, lineY))
		return;

	uint32 wX = floor(lineX);
	uint32 wY = floor(lineY);

	highlightClip(wX, wY);

	const Common::UString &line = (wY == 0) ? _input->get() :
	                                          _lines[_lines.size() - wY]->get();
	const uint32 pos = (wY == 0) ? (wX - _prompt->get().size()) : wX;

	uint32 wordStart = findWordStart(line, pos);
	uint32 wordEnd   = findWordEnd  (line, pos);

	_highlightX      = (wY == 0) ? (wordStart + _prompt->get().size()) : wordStart;
	_highlightY      =  wY;
	_highlightLength = wordEnd - wordStart;

	updateHighlight();
}
Beispiel #6
0
void FindBar::findText(const QString &search)
{
    if (!m_associatedWebView)
        return;
    _lastStringSearched = search;
    updateHighlight();
    findNext();
}
Beispiel #7
0
void FindBar::matchCaseUpdate()
{
    Q_ASSERT(m_associatedWebView);

    m_associatedWebView->page()->findText(_lastStringSearched, QWebPage::FindBackward);
    findNext();
    updateHighlight();
}
Beispiel #8
0
void MainWindow::matchCaseUpdate()
{
    if (!currentTab())
        return;

    currentTab()->view()->findText(m_lastSearch, QWebPage::FindBackward);
    findNext();
    updateHighlight();
}
Beispiel #9
0
void MainWindow::find(const QString & search)
{
    if (!currentTab())
        return;
    m_lastSearch = search;

    updateHighlight();
    findNext();
}
Beispiel #10
0
void TreeWidget::unhighlightItem(QTreeWidgetItem* item)
{
    if (item && d.highlightedItems.contains(item)) {
        d.highlightedItems.remove(item);
        if (d.highlightedItems.isEmpty())
            SharedTimer::instance()->unregisterReceiver(this, "blinkItems");
        updateHighlight(item);
    }
}
Beispiel #11
0
void TreeWidget::highlightItem(QTreeWidgetItem* item)
{
    if (item && !d.highlightedItems.contains(item)) {
        if (d.highlightedItems.isEmpty())
            SharedTimer::instance()->registerReceiver(this, "blinkItems");
        d.highlightedItems.insert(item);
        updateHighlight(item);
    }
}
Beispiel #12
0
void FindBar::matchCaseUpdate()
{
    // parent webwindow
    WebWindow *w = qobject_cast<WebWindow *>(parent());

    w->page()->findText(_lastStringSearched, QWebPage::FindBackward);
    findNext();
    updateHighlight();
}
Beispiel #13
0
void FindBar::setVisible(bool visible)
{
    // parent webwindow
    WebWindow *w = qobject_cast<WebWindow *>(parent());

    if (visible
            && w->page()->isOnRekonqPage()
            && w->tabView()->part() != 0)
    {
        // findNext is the slot containing part integration code
        findNext();
        return;
    }

    QWidget::setVisible(visible);

    if (visible)
    {
        const QString selectedText = w->page()->selectedText();
        if (!hasFocus() && !selectedText.isEmpty())
        {
            const QString previousText = m_lineEdit->text();
            m_lineEdit->setText(selectedText);

            if (m_lineEdit->text() != previousText)
                findPrevious();
            else
                updateHighlight();
        }
        else if (selectedText.isEmpty())
        {
            emit searchString(m_lineEdit->text());
        }

        m_lineEdit->setFocus();
        m_lineEdit->selectAll();
    }
    else
    {
        updateHighlight();
    }
}
Beispiel #14
0
void DiffDialog::backClicked()
{
    int newitem;
    if (markeditem == -1)
        return; // internal error (button not disabled)
    else if (markeditem == -2) // past end
        newitem = items.count()-1;
    else
        newitem = markeditem-1;
    updateHighlight(newitem);
}
Beispiel #15
0
void DiffDialog::forwClicked()
{
    int newitem;
    if (markeditem == -2 || (markeditem == -1 && !items.count()))
        return; // internal error (button not disabled)
    else if (markeditem+1 == items.count()) // past end
        newitem = -2;
    else
        newitem = markeditem+1;
    updateHighlight(newitem);
}
Beispiel #16
0
void ConsoleWindow::stopHighlight(int x, int y) {
	float lineX, lineY;
	if (!getPosition(x, y, lineX, lineY))
		return;

	uint32 endX = floor(lineX);

	highlightClip(endX, _highlightY);

	_highlightLength = ((int32) endX) - ((int32) _highlightX);

	updateHighlight();
}
Beispiel #17
0
void ConsoleWindow::startHighlight(int x, int y) {
	clearHighlight();

	float lineX, lineY;
	if (!getPosition(x, y, lineX, lineY))
		return;

	_highlightX = floor(lineX);
	_highlightY = floor(lineY);

	highlightClip(_highlightX, _highlightY);

	updateHighlight();
}
Beispiel #18
0
void ConsoleWindow::highlightLine(int x, int y) {
	clearHighlight();

	float lineX, lineY;
	if (!getPosition(x, y, lineX, lineY))
		return;

	_highlightX = 0;
	_highlightY = floor(lineY);

	highlightClip(_highlightX, _highlightY);

	const Common::UString &line = (_highlightY == 0) ?
		_input->get() : _lines[_lines.size() - _highlightY]->get();
	_highlightLength = line.size();

	updateHighlight();
}
Beispiel #19
0
void Highlighter::setTarget(const VisualizationSelection & selection)
{
    if (m_selection == selection)
    {
        return;
    }

    auto newSelection = selection;
    newSelection.indices.clear();

    for (const auto index : selection.indices)
    {
        if (index >= 0)
        {
            newSelection.indices.push_back(index);
        }
    }

    setTargetInternal(newSelection);

    updateHighlight();
}
    virtual void redraw( void ) {
        static bool first=true;
        static RenderNode rn;

        int i;
        double tbalance;
        GeoLoadManager::ResultT region;
        if (_internalRoot == NullFC)
        {
            initialize();
            showAll();
        }
        _cart->getSFMatrix()->setValue(_navigator.getMatrix());    
        updateHighlight();
        _win->activate();
        _win->frameInit();
        if(first)
        {
            loadManager=new GeoLoadManager(useFaceDistribution);
            first=false;
            rn.determinePerformance(_win);
        }
        if(_win->getPort().size() < (serverCount+1))
        {
            ViewportPtr vp,ovp=_win->getPort(0);
            addRefCP(ovp);
            addRefCP(ovp);
            TileCameraDecoratorPtr deco;
            for(int i=_win->getPort().size()-1;i<serverCount;i++)
            {
                cout << "Add new" << endl;
                loadManager->addRenderNode(rn,i);
                if(simulateRendering)
                {
                    beginEditCP(_win);
                    deco=TileCameraDecorator::create();
                    beginEditCP(deco);
                    deco->setFullWidth ( _win->getWidth() );
                    deco->setFullHeight( _win->getHeight() );
                    deco->setDecoratee( ovp->getCamera() );
                    vp=Viewport::create();
                    beginEditCP(vp);
                    vp->setRoot      ( ovp->getRoot()       );

                    /*
                    SkyBackgroundPtr sky = SkyBackground::create();
                    beginEditCP(sky);
                    sky->setSphereRes(16);
                    
                    sky->getMFSkyColor()->addValue(Color3f(0, 0, .2));
                    sky->getMFSkyAngle()->addValue(Pi / 2);
                    sky->getMFSkyColor()->addValue(Color3f(.6, .6, 1)); 
                    
                    sky->getMFGroundColor()->addValue(Color3f(0, .3, 1));
                    sky->getMFGroundAngle()->addValue(Pi / 2);
                    sky->getMFGroundColor()->addValue(Color3f(1, .3, 0));

                    endEditCP(sky);
                    vp->setBackground( sky );
                    */

                    vp->setBackground( ovp->getBackground() );
                    vp->getMFForegrounds()->setValues( ovp->getForegrounds() );
                    vp->setCamera(deco);
                    _win->addPort(vp);
                    endEditCP(_win);
                    endEditCP(vp);
                    endEditCP(deco);
                }
            }
        }
        tbalance = -getSystemTime();
        loadManager->update(_win->getPort()[0]->getRoot());
        loadManager->balance(_win->getPort()[0],false,region);
        tbalance += getSystemTime();
        if(simulateRendering)
        {
            ViewportPtr vp;
            TileCameraDecoratorPtr deco;
            for(i=0;i<region.size();i+=4)
            {
#if 1
                cout << "Region: " << i << " ";
                cout << region[i+0] << " ";
                cout << region[i+1] << " ";
                cout << region[i+2] << " ";
                cout << region[i+3] << endl;
                if(region[i+0] >= region[i+2]) {
                    cout << "!!!" << endl;
                    region[i+2]++;
                }
                if(region[i+1] >= region[i+3]) {
                    cout << "!!!" << endl;
                    region[i+3]++;
                }
#endif
                vp=_win->getPort()[i/4+1];
                deco=TileCameraDecoratorPtr::dcast(vp->getCamera());
                beginEditCP(deco);
                beginEditCP(vp);
                vp->setSize(region[i+0],
                            region[i+1],
                            region[i+2],
                            region[i+3]);
                deco->setSize(region[i+0]/(float)_win->getWidth(),
                              region[i+1]/(float)_win->getHeight(),
                              region[i+2]/(float)_win->getWidth(),
                              region[i+3]/(float)_win->getHeight());
                endEditCP(deco);
                endEditCP(vp);
            }
        }
        Time t,tmin,tmax;
        for(i=0;i<_win->getPort().size();++i)
        {
            t=-getSystemTime();
            _action->setWindow( _win.getCPtr() );
            _win->getPort(i)->render( _action );
            glFlush();
            t+=getSystemTime();
            if(i==0)
                continue;
            if(i==1)
            {
                tmin=tmax=t;
            }
            else
            {
                if(t<tmin) tmin=t;
                if(t>tmax) tmax=t;
            }
        }
        if(!cache)
            printf("speed %5d %10.6f %10.6f %10.6f\n",_win->getPort().size()-1,
                   tmin,
                   tmax,
                   tbalance);
        glPushAttrib(GL_ALL_ATTRIB_BITS);
        glDisable(GL_SCISSOR_TEST);
        glViewport(0,0,
                   _win->getWidth(),
                   _win->getHeight());
        if(viewVolume)
            loadManager->drawVolumes(_win);
        glPushMatrix();
        glLoadIdentity();
        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
        gluOrtho2D(0,_win->getWidth(),
                   0,_win->getHeight());
        glDisable(GL_DEPTH_TEST);
        glEnable(GL_COLOR_MATERIAL);
        for(i=0;i<region.size();i+=4)
        {
#if 0
            cout << "Region: ";
            cout << region[i+0] << " ";
            cout << region[i+1] << " ";
            cout << region[i+2] << " ";
            cout << region[i+3] << endl;
#endif
            glBegin(GL_LINE_LOOP);
            glColor3f(1, 1, 0);
            glVertex3f(region[i+0],region[i+1],0);
            glVertex3f(region[i+2],region[i+1],0);
            glVertex3f(region[i+2],region[i+3],0);
            glVertex3f(region[i+0],region[i+3],0);
            glEnd();
        }
        glDisable(GL_COLOR_MATERIAL);
        glEnable(GL_DEPTH_TEST);
        glPopMatrix();
        glMatrixMode(GL_MODELVIEW);
        glPopMatrix();
        glPopAttrib();

        if(doSave)
        {
            Int32 w,h;
            w=_win->getPort(0)->getPixelWidth();
            h=_win->getPort(0)->getPixelHeight();
            Image image(Image::OSG_RGB_PF,
                        w,h,1,
                        1,1,0.0,
                        NULL,true);
            ImageFileType *imgTransType=ImageFileHandler::the().getFileType("JPEG");
            char filename[256];
            if(imgTransType==NULL)
            {
                cerr << "Unknown image trans type" << endl;
                return;
            }
            sprintf(filename,"%s_%d.jpg",dumpImage,dumpImageNr++);
            // read buffer data into image
            glPixelStorei(GL_PACK_ALIGNMENT,1);
            glReadPixels(0,0,w,h,
                         GL_RGB,GL_UNSIGNED_BYTE,
                         image.getData());
            imgTransType->write(image,filename);
        }
        _win->swap();
        _win->frameExit();
    }
Beispiel #21
0
void DiffDialog::comboActivated(int index)
{
    updateHighlight(index-1);
}
Beispiel #22
0
void TreeWidget::blinkItems()
{
    foreach (QTreeWidgetItem* item, d.highlightedItems)
        updateHighlight(item);
    d.blink = !d.blink;
}
Beispiel #23
0
void GuiPanel::showMaterialSpecular(){curMaterialFocus = SPECULAR; updateHighlight();emit(followLink());}
Beispiel #24
0
void GuiPanel::showMaterialShader(){curMaterialFocus = SHADERNAME; updateHighlight();emit(followLink());}
Beispiel #25
0
void GuiPanel::showMaterialEnviro(){curMaterialFocus = ENVIRO; updateHighlight();emit(followLink());}
Beispiel #26
0
void GuiPanel::showMaterialBump(){curMaterialFocus = BUMP; updateHighlight();emit(followLink());}
Beispiel #27
0
void GuiPanel::showMaterialDiffuseB(){curMaterialFocus = DIFFUSEB; updateHighlight();emit(followLink());}
void OpenSGNavGrab::updateGrabbing(const gmtl::Matrix44f& wandMatrix)
{
   // The navigation matrix is w_M_vw, so invert it for use here.
   const OSG::Matrix& nav_mat(mSceneTransform->getMatrix());
   OSG::Matrix vw_M_w;
   nav_mat.inverse(vw_M_w);

   // Create a GMTL version of vw_M_w so that we can perform the necessary
   // multiplication.
   gmtl::Matrix44f gmtl_vw_M_w;
   gmtl_vw_M_w.set(vw_M_w.getValues());

   // Transform the wand matrix from real world coordinates into virtual world
   // coordinates.
   const gmtl::Matrix44f wand_matrix = gmtl_vw_M_w * wandMatrix;

   // Extract the wand translation component as an OSG::Pnt3f for use below.
   // It's too bad that gmtl::makeTrans<T,U>() can't take an OSG::Pnt3f as its
   // T (translation type) parameter.
   const gmtl::Vec3f wand_pos = gmtl::makeTrans<gmtl::Vec3f>(wand_matrix);
   const OSG::Pnt3f wand_point(wand_pos[0], wand_pos[1], wand_pos[2]);

   // Only perform the intersection testing when we are not already grabbing
   // an object.
   if ( mGrabbedObj.get() == NULL )
   {
      GrabObjectPtr intersect_obj;

      // Find the first object--if any--in mObjects with which the wand
      // intersects.
      typedef std::vector<GrabObjectPtr>::iterator iter_type;
      for ( iter_type o = mObjects.begin(); o != mObjects.end(); ++o )
      {
         const OSG::DynamicVolume& bbox =
            (*o)->getXformNode().node()->getVolume();

         if ( bbox.intersect(wand_point) )
         {
            intersect_obj = *o;
            break;
         }
      }

      // If the intersected object changed since the last frame, we need to
      // update things.
      if ( intersect_obj != mIntersectedObj )
      {
         // If mIntersectedObj was not NULL, then we need to remove the
         // bounding box rendering that is now out of date.
         if ( mIntersectedObj.get() != NULL )
         {
#if OSG_MAJOR_VERSION < 2
            OSG::CPEditor e(mIntersectedObj->getXformNode().node(),
                            OSG::Node::ChildrenFieldMask);
#endif
            mIntersectedObj->getXformNode().node()->subChild(mHighlightNode);
         }

         mIntersectedObj = intersect_obj;

         // If mIntersectedObj is non-NULL, we have selected a new object.
         // Create a new bounding box around that object.
         if ( mIntersectedObj.get() != NULL )
         {
            mHighlight = mIntersectedObj->getXformNode().node()->getChild(0);

#if OSG_MAJOR_VERSION < 2
            CPEdit(mHighlightMaterial, OSG::SimpleMaterial::DiffuseFieldMask);
            OSG::CPEditor e(mIntersectedObj->getXformNode().node(),
                            OSG::Node::ChildrenFieldMask);
#endif

            // Set the highlight color to mIntersectColor.
            mHighlightMaterial->setDiffuse(mIntersectColor);

            mIntersectedObj->getXformNode().node()->addChild(mHighlightNode);

            updateHighlight();
         }
      }
   }

   // Enable grabbing only when no other object is currently grabbed, when
   // the wand button is intersecting an object, and when button 0 is pressed.
   if ( mIntersectedObj.get() != NULL && mGrabbedObj.get() == NULL &&
        mButton0->getData() == gadget::Digital::ON )
   {
      mGrabbedObj = mIntersectedObj;

#if OSG_MAJOR_VERSION < 2
      CPEdit(mHighlightMaterial, OSG::SimpleMaterial::DiffuseFieldMask);
#endif

      // Set the highlight color to mGrabColor.
      mHighlightMaterial->setDiffuse(mGrabColor);
   }
   // We cannot be grabbing anything unless button 0 is pressed.
   else if ( mButton0->getData() != gadget::Digital::ON )
   {
      // If we are dropping a grabbed object, then set the highlight color
      // back to mIntersectColor.
      if ( mGrabbedObj.get() != NULL )
      {
#if OSG_MAJOR_VERSION < 2
      CPEdit(mHighlightMaterial, OSG::SimpleMaterial::DiffuseFieldMask);
#endif

         mHighlightMaterial->setDiffuse(mIntersectColor);
      }

      mGrabbedObj = GrabObjectPtr();
   }

   // If mGrabbedObj is non-NULL, then we are grabbing the object pointed at
   // by mGrabbedObj.
   if ( mGrabbedObj.get() != NULL )
   {
#if OSG_MAJOR_VERSION < 2
      OSG::TransformPtr core = mGrabbedObj->getXformNode();
      CPEdit(core, OSG::Transform::MatrixFieldMask);
      mGrabbedObj->getXformNode()->getMatrix().setTranslate(wand_point);
#else
      mGrabbedObj->getXformNode()->editMatrix().setTranslate(wand_point);
#endif
   }
}
void TreeItem::removeHighlight()
{
    m_highlight = false;
    emit updateHighlight(this);
}