void
RenderFrameParent::BuildViewMap()
{
  ViewMap newContentViews;
  // BuildViewMap assumes we have a primary frame, which may not be the case.
  if (GetRootLayer() && mFrameLoader->GetPrimaryFrameOfOwningContent()) {
    // Some of the content views in our hash map may no longer be active. To
    // tag them as inactive and to remove any chance of them using a dangling
    // pointer, we set mContentView to NULL.
    //
    // BuildViewMap will restore mFrameLoader if the content view is still
    // in our hash table.

    for (ViewMap::const_iterator iter = mContentViews.begin();
         iter != mContentViews.end();
         ++iter) {
      iter->second->mFrameLoader = NULL;
    }

    mozilla::layout::BuildViewMap(mContentViews, newContentViews, mFrameLoader, GetRootLayer());
  }

  // Here, we guarantee that *only* the root view is preserved in
  // case we couldn't build a new view map above. This is important because
  // the content view map should only contain the root view and content
  // views that are present in the layer tree.
  if (newContentViews.empty()) {
    newContentViews[FrameMetrics::ROOT_SCROLL_ID] =
      FindViewForId(mContentViews, FrameMetrics::ROOT_SCROLL_ID);
  }

  mContentViews = newContentViews;
}
Пример #2
0
void Operators::reset(bool removeStrokes)
{
	ViewMap *vm = ViewMap::getInstance();
	if (!vm) {
		cerr << "Error: no ViewMap computed yet" << endl;
		return;
	}
	_current_view_edges_set.clear();
	for (I1DContainer::iterator it = _current_chains_set.begin(); it != _current_chains_set.end(); ++it)
		delete *it;
	_current_chains_set.clear();

	ViewMap::viewedges_container& vedges = vm->ViewEdges();
	ViewMap::viewedges_container::iterator ve = vedges.begin(), veend = vedges.end();
	for (; ve != veend; ++ve) {
		if ((*ve)->getLength2D() < M_EPSILON)
			continue;
		_current_view_edges_set.push_back(*ve);
	}
	_current_set = &_current_view_edges_set;
	if (removeStrokes)
		_current_strokes_set.clear();
}
Пример #3
0
void PMainWindow::slotConfig() {
    /*
     * have a tab with the possible views
     * a tab for globals image cache size.. scaled loading
     * and one tab for the  KeyConfigs
     */
    QDialog dlg(this, 0, true);
    dlg.setCaption( tr("Opie Eye - Config" ) );

    QHBoxLayout *lay = new QHBoxLayout(&dlg);
    Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg );
    lay->addWidget( wid );

    BaseSetup*bSetup = new BaseSetup(m_cfg,wid);
    wid->addTab(bSetup,"SettingsIcon","Basics setup");

    ViewMap *vM = viewMap();
    ViewMap::Iterator _it = vM->begin();
    QMap<PDirView*, QWidget*> lst;

    for( ; _it != vM->end(); ++_it ) {
        PDirView *view = (_it.data())(*m_cfg);
        PInterfaceInfo *inf =  view->interfaceInfo();
        QWidget *_wid = inf->configWidget( *m_cfg );
        if (!_wid) continue;
        _wid->reparent(wid, QPoint() );
        lst.insert( view, _wid );
        wid->addTab( _wid, "fileopen", inf->name() );
    }

    /*
     * Add the KeyConfigWidget
     */
    Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" );
    keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue );
    keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
    QWidget*w = m_stack->visibleWidget();

    bool reminfo = false;
    if ( !m_info ) {
        reminfo = true;
        initInfo();
        m_info->hide();
    }
    keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() );

    bool remdisp = false;
    if ( !m_disp ) {
        remdisp = true;
        initDisp();
        m_disp->hide();
    }
    keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() );

    keyWid->load();
    wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
    wid->setCurrentTab(0);
    bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );

    /*
     * clean up
     *apply changes
     */

    QMap<PDirView*, QWidget*>::Iterator it;
    for ( it = lst.begin(); it != lst.end(); ++it ) {
        if ( act )
            it.key()->interfaceInfo()->writeConfig(it.data(),  *m_cfg);
        delete it.key();
    }


    if ( act ) {
        keyWid->save();
        m_disp->manager()->save();
        m_info->manager()->save();
        m_view->manager()->save();
        bSetup->save_values();
        m_view->resetView();
        readConfig();
    }
    delete keyWid;

    m_stack->raiseWidget(w);
    if (remdisp) {
        m_disp->hide();
    }
    if (reminfo) {
        m_info->hide();
    }
    if (m_disp) {
        m_disp->setIntensity(m_Intensity,true);
    }
}
Пример #4
0
void CulledOccluderSource::cullViewEdges(ViewMap& viewMap, bool extensiveFEdgeSearch)
{
	// Cull view edges by marking them as non-displayable.
	// This avoids the complications of trying to delete edges from the ViewMap.

	// Non-displayable view edges will be skipped over during visibility calculation.

	// View edges will be culled according to their position w.r.t. the viewport proscenium (viewport + 5% border,
	// or some such).

	// Get proscenium boundary for culling
	real viewProscenium[4];
	GridHelpers::getDefaultViewProscenium(viewProscenium);
	real prosceniumOrigin[2];
	prosceniumOrigin[0] = (viewProscenium[1] - viewProscenium[0]) / 2.0;
	prosceniumOrigin[1] = (viewProscenium[3] - viewProscenium[2]) / 2.0;
	if (G.debug & G_DEBUG_FREESTYLE) {
		cout << "Proscenium culling:" << endl;
		cout << "Proscenium: [" << viewProscenium[0] << ", " << viewProscenium[1] << ", " << viewProscenium[2] <<
		        ", " << viewProscenium[3] << "]"<< endl;
		cout << "Origin: [" << prosceniumOrigin[0] << ", " << prosceniumOrigin[1] << "]"<< endl;
	}

	// A separate occluder proscenium will also be maintained, starting out the same as the viewport proscenium, and
	// expanding as necessary so that it encompasses the center point of at least one feature edge in each
	// retained view edge.
	// The occluder proscenium will be used later to cull occluding triangles before they are inserted into the Grid.
	// The occluder proscenium starts out the same size as the view proscenium
	GridHelpers::getDefaultViewProscenium(occluderProscenium);

	// XXX Freestyle is inconsistent in its use of ViewMap::viewedges_container and vector<ViewEdge*>::iterator.
	// Probably all occurences of vector<ViewEdge*>::iterator should be replaced ViewMap::viewedges_container
	// throughout the code.
	// For each view edge
	ViewMap::viewedges_container::iterator ve, veend;

	for (ve = viewMap.ViewEdges().begin(), veend = viewMap.ViewEdges().end(); ve != veend; ve++) {
		// Overview:
		//    Search for a visible feature edge
		//    If none: mark view edge as non-displayable
		//    Otherwise:
		//        Find a feature edge with center point inside occluder proscenium.
		//        If none exists, find the feature edge with center point closest to viewport origin.
		//            Expand occluder proscenium to enclose center point.

		// For each feature edge, while bestOccluderTarget not found and view edge not visibile
		bool bestOccluderTargetFound = false;
		FEdge *bestOccluderTarget = NULL;
		real bestOccluderDistance = 0.0;
		FEdge *festart = (*ve)->fedgeA();
		FEdge *fe = festart;
		// All ViewEdges start culled
		(*ve)->setIsInImage(false);

		// For simple visibility calculation: mark a feature edge that is known to have a center point inside
		// the occluder proscenium. Cull all other feature edges.
		do {
			// All FEdges start culled
			fe->setIsInImage(false);

			// Look for the visible edge that can most easily be included in the occluder proscenium.
			if (!bestOccluderTargetFound) {
				// If center point is inside occluder proscenium,
				if (insideProscenium(occluderProscenium, fe->center2d())) {
					// Use this feature edge for visibility deterimination
					fe->setIsInImage(true);
					expandGridSpaceOccluderProscenium(fe);
					// Mark bestOccluderTarget as found
					bestOccluderTargetFound = true;
					bestOccluderTarget = fe;
				}
				else {
					real d = distance2D(fe->center2d(), prosceniumOrigin);
					// If center point is closer to viewport origin than current target
					if (bestOccluderTarget == NULL || d < bestOccluderDistance) {
						// Then store as bestOccluderTarget
						bestOccluderDistance = d;
						bestOccluderTarget = fe;
					}
				}
			}

			// If feature edge crosses the view proscenium
			if (!(*ve)->isInImage() && crossesProscenium(viewProscenium, fe)) {
				// Then the view edge will be included in the image
				(*ve)->setIsInImage(true);
			}
			fe = fe->nextEdge();
		} while (fe != NULL && fe != festart && !(bestOccluderTargetFound && (*ve)->isInImage()));

		// Either we have run out of FEdges, or we already have the one edge we need to determine visibility
		// Cull all remaining edges.
		while (fe != NULL && fe != festart) {
			fe->setIsInImage(false);
			fe = fe->nextEdge();
		}

		// If bestOccluderTarget was not found inside the occluder proscenium, 
		// we need to expand the occluder proscenium to include it.
		if ((*ve)->isInImage() && bestOccluderTarget != NULL && ! bestOccluderTargetFound) {
			// Expand occluder proscenium to enclose bestOccluderTarget
			Vec3r point = bestOccluderTarget->center2d();
			if (point[0] < occluderProscenium[0]) {
				occluderProscenium[0] = point[0];
			}
			else if (point[0] > occluderProscenium[1]) {
				occluderProscenium[1] = point[0];
			}
			if (point[1] < occluderProscenium[2]) {
				occluderProscenium[2] = point[1];
			}
			else if (point[1] > occluderProscenium[3]) {
				occluderProscenium[3] = point[1];
			}
			// Use bestOccluderTarget for visibility determination
			bestOccluderTarget->setIsInImage(true);
		}
	}

	// We are done calculating the occluder proscenium.
	// Expand the occluder proscenium by an epsilon to avoid rounding errors.
	const real epsilon = 1.0e-6;
	occluderProscenium[0] -= epsilon;
	occluderProscenium[1] += epsilon;
	occluderProscenium[2] -= epsilon;
	occluderProscenium[3] += epsilon;

	// For "Normal" or "Fast" style visibility computation only:

	// For more detailed visibility calculation, make a second pass through the view map, marking all feature edges
	// with center points inside the final occluder proscenium. All of these feature edges can be considered during
	// visibility calculation.

	// So far we have only found one FEdge per ViewEdge. The "Normal" and "Fast" styles of visibility computation
	// want to consider many FEdges for each ViewEdge.
	// Here we re-scan the view map to find any usable FEdges that we skipped on the first pass, or that have become
	// usable because the occluder proscenium has been expanded since the edge was visited on the first pass.
	if (extensiveFEdgeSearch) {
		// For each view edge,
		for (ve = viewMap.ViewEdges().begin(), veend = viewMap.ViewEdges().end(); ve != veend; ve++) {
			if (!(*ve)->isInImage()) {
				continue;
			}
			// For each feature edge,
			FEdge *festart = (*ve)->fedgeA();
			FEdge *fe = festart;
			do {
				// If not (already) visible and center point inside occluder proscenium, 
				if (!fe->isInImage() && insideProscenium(occluderProscenium, fe->center2d())) {
					// Use the feature edge for visibility determination
					fe->setIsInImage(true);
					expandGridSpaceOccluderProscenium(fe);
				}
				fe = fe->nextEdge();
			} while (fe != NULL && fe != festart);
		}
	}

	// Up until now, all calculations have been done in camera space.
	// However, the occluder source's iteration and the grid that consumes the occluders both work in gridspace,
	// so we need a version of the occluder proscenium in gridspace.
	// Set the gridspace occlude proscenium
}
Пример #5
0
real SVertex::GetIsophoteDistance(real isovalue, int maxDistance) const
{
  if (_sourceVertex == NULL && _sourceEdge == NULL)
    return -1; // not handling the case of intersection SVertices yet

  if (!(getNature() & Nature::SILHOUETTE)) // only handle silhouette curves
    return -1;

  Vec3r startPoint = _Point3D;

  set<pair<WFace*,int> > possibleStartEdges;
  real currentNdotV;

  //  if (!(getNature() & Nature::SURFACE_INTERSECTION))
  //    printf("Isophote search Nature: %d\n", getNature());
  if (_sourceVertex != NULL)
    {
      currentNdotV = _sourceVertex->GetSurfaceNdotV();

      //      printf("Starting at vertex with n dot v = %f\n", currentNdotV);

      for(vector<WEdge*>::iterator it = _sourceVertex->GetEdges().begin(); it != _sourceVertex->GetEdges().end(); ++it)
	{
	  WFace * aface = (*it)->GetaFace();
	  WFace * bface = (*it)->GetbFace();
	  if (aface != NULL)
	    possibleStartEdges.insert( pair<WFace*,int>(aface, (aface->GetIndex(_sourceVertex)+1)%3));
	  if (bface != NULL)
	    possibleStartEdges.insert(pair<WFace*,int>(bface, (bface->GetIndex(_sourceVertex)+1)%3));
	}
    }
  else
    {
      currentNdotV = ComputeSurfaceNdotV(_sourceEdge, startPoint);

      WFace * faces[2] = { _sourceEdge->GetaFace(), _sourceEdge->GetbFace() };

      for(int i=0;i<2;i++)
	if (faces[i] != NULL)
	{
	  int v;
	  for(v=0;v<3;v++)
	    if (faces[i]->GetOEdge(v)->GetOwner() == _sourceEdge)
	      break;
	  assert(v<3);
	  
	  possibleStartEdges.insert(pair<WFace*,int>(faces[i], (v+1)%3));
	  possibleStartEdges.insert(pair<WFace*,int>(faces[i], (v+2)%3));
	}
    }

  if (currentNdotV > isovalue)
    return 0;

  if (currentNdotV < -0.001)
    return 0;

  Vec3r currentPoint;
  WEdge * currentEdge = NULL;
  WFace * currentFace = NULL;

  Vec3r lastPoint = startPoint;
  real lastNdotV = currentNdotV;

  for(set<pair<WFace*,int> >::iterator it = possibleStartEdges.begin(); it != possibleStartEdges.end(); ++it)
    {
      WFace * face = (*it).first;
      int e = (*it).second;
      if (AdvanceToEdge( face, startPoint, e, currentPoint))
	{
	  currentNdotV = ComputeSurfaceNdotV(face->GetOEdge(e)->GetOwner(), currentPoint);

	  //	  printf("\tlastNdotV = %f, currentNdotV = %f\n", lastNdotV, currentNdotV);

	  if (currentNdotV < lastNdotV)
	    continue;

	  currentEdge = face->GetOEdge(e)->GetOwner(); 
	  currentFace = face->GetBordingFace(e);

	  assert(GeomUtils::distPointSegment<Vec3r>( currentPoint, currentEdge->GetaVertex()->GetVertex(), currentEdge->GetbVertex()->GetVertex()) < 0.01);
	  break;
	}
    }

  if (currentEdge == NULL)
    return -1;

  // march over the surface
  int numSteps = 0;
  while (currentNdotV < isovalue && currentNdotV > -0.001 && numSteps < 100 && currentFace != NULL && ImageSpaceDistance(startPoint, currentPoint) < maxDistance)
    {
      numSteps ++;
      lastPoint = currentPoint;
      lastNdotV = currentNdotV;

      //      printf("advancing, current NdotV = %f\n", currentNdotV);

      bool result = false;
      int e;
      Vec3r nextPoint;
      for(e=0;e<3;e++)
	{
	  if (currentFace->GetOEdge(e)->GetOwner() == currentEdge)
	    continue;
	  result = AdvanceToEdge(currentFace, currentPoint, e, nextPoint);
	  //	  printf("\t advance result = %s\n", result ? "true" : "false");
	  if (result)
	    break;
	}
      
      assert(result);
      
      currentPoint = nextPoint;
      currentEdge = currentFace->GetOEdge(e)->GetOwner();
      currentNdotV = ComputeSurfaceNdotV(currentEdge, currentPoint);
      currentFace = currentFace->GetBordingFace(e);
    }

  Vec3r endpoint;

  if (currentNdotV > isovalue)
    {
      real t = (isovalue - lastNdotV)/(currentNdotV - lastNdotV);
      endpoint = (1-t) * lastPoint + t * currentPoint;
    }
  else
    if (currentNdotV < -0.001)
      {
	real t = -lastNdotV/(currentNdotV - lastNdotV);  // endpoint is the zero-crossing
	endpoint = (1-t)*lastPoint + t * currentPoint;
      }
    else
      endpoint = currentPoint;

  ViewMap * vm = ViewMap::getInstance();

  vm->addDebugPoint(DebugPoint::ISOPHOTE, endpoint, startPoint);

  real dist = ImageSpaceDistance(startPoint, endpoint);

  //  printf("\t result: dist = %f, lastNdotV = %f, currentNdotV = %f, numSteps = %d, currentFace = %08X\n", dist, lastNdotV, currentNdotV, numSteps, currentFace);

  return dist;
}